c++ - The "Self-Factory" Pattern -
I do not know if there is an official name for this, but what I want to call is "self-factory" pattern In this, it happens when an abstract base class acts as a factory for itself. Explain to me:
I have FU objects and bar objects in my system, which are used through the interface FuFFFF and Bar Interfaces. I need to give the right type of fu and bar to my customers. The concrete few object is decided at compile time. For example, if you compile on Win32, you only want to create Win32Foo objects, and if you compile on OSX, you only want to create OSXFoo objects and so on. But, on the basis of a solid string, which is intended to make a solid bar object, it is built on the runtime.
Now, my question is the best way to implement this plan in one way I use regular factories:
shared_ptr
Another method I call "self-factories":
shared_ptr
From the perspective of usability and from the Vastu perspective, what are the pros and cons of each approach?
Comments
Post a Comment