My exact Problem is a bit difficult to explain so heres a simplified Version: I have various Types of Animals (Modules) and a Shelter (ModuleManager). These include Dogs, Cats and Birds. A Owner (Parent) is able to call a function of a shelter which includes a String of the type of Animal he wants to adopt and a List of Generic Items (References) to make the Animals life easier. The List of Items is variable, but must include all and only the required items a spoecific animal needs, which varies from Animal to animal (A dog needs a collar and a leash, A cat needs a cattree and a litterbox a bird needs a cage etc..). This list also includes a reference back to the owner, so the animals knows who it belongs to.
Basicly its should look like this:
Animal * getAnimal(String name, void * Items, int size_items)
//From Customer Class
Parrot * lester=dynamic_cast<Parrot*>(getAnimal("parrot", [this, new Cage()]))
Now what I need is an automated factory pattern which can somehow store Classes in a Key Value array and is able to create instances of them using their constructors which would look like this:
Parrot(void * items)
It should later be possible for a programmer to add new types of Animals to the Shelter during runtime by calling
addAnimal(String Key, Class type)
I hope that explains my problem accurately. Basicly I need a way to create standardized subclasses of a parentclass, where users can add more subclasses without going back to the classic
if x=="Parrot" then return new Parrot(a)