I have a component system - I users of my engine can create their own components by sub-classing Component class - and then each entity has a list of components
When I'm serializing/de-serializing components, considering that when I am deserializing I need to allocate any sub-classed component classes in the engine loading code without actually knowing the sub-class type (user defined) - what is a good way to do this so that the engine user does not have to rewrite any engine code?
IE in the engine i have a Component class with pure virtual functions "serialize(FileStream & fStream)" and "deserialize(FileStream & fStream)"
so that the engine user has to write their own versions of these functions - this works great for serializing to file - but how do I deserialize?
If the engine code is something like
for each component in entity
for each component found in save file
Component * toAdd = new Component() (How do I allocate custom user defined components?)
entity->addComponent(Component * toAdd)
Thanks for any help