I'm sure it comes up all the time a project has too much data simply keeping them in files that are edited by hand, but not so complicated that a big fancy tool like a DB is necessary.

I have considered many options and even had a generic editor that worked well for 'flat' data. Problem is, it chokes when it comes to any complex objects and it seems to be a virtually insurmountable problem unless I break down and code separate editors instead of being generic.

My new idea is to make a base class for all data objects to inherit from. This contains all data as strings with methods to get them as the proper type, then the subclass will define the proper getters and setters that work in a human friendly way. It also contains the metadata about the objects, as well.

Things would be easier if C++ had reflection, but the serialization element is trivial and the reflection libraries I have seen all have some critical drawbacks or flaw that makes them not worth using or not possible to use.

So the basic idea seems to work but there is a difficulty. How do I fill in the meta data for these objects?

Every time I create an object I need it to have the proper meta data description. So somewhere, each subclass needs to define this.

the meta data is:

1. unique object name.
2. array of childObjectNames (other objects that compose this object, just the names not the data)
3. array of FieldDescriptors. This is composed of the field name and the field type for each simple part of the object.


I guess I can put that in the constructor of each object, but you can see it's all shared data so it would be nice to be able to share it all somehow or at least keep it in one place.


The second issue is I need to be able to create a new one of the appropriate subclass.

So, I have this editor code, and the user clicks add new. Now all the editor has access to is a generic array of the base object. It has to be that way pretty much, unfortunately. Worse, the array can be empty so ultimately I can't use virtual methods in any way here. I do have the name of the object, though, which the metadata goes by.

So I am thinking/hoping that this dovetails into some design pattern or something. I have read up on builder pattern and factory pattern etc. but something about them never seems to really sink in. So if it is something like that, please be clear about how to apply it here. Thanks.