boost::excessive_syntax
Apologies to the majority of people who have no idea what this is about.
class YourBrain { public: Â Â Â Â Â YourBrain(); Â Â Â Â Â virtual ~YourBrain(); Â Â Â Â Â Â YourBrain* Get() Â Â Â Â Â { Â Â Â Â Â Â Â Â Â Â Â return this; Â Â Â Â Â } Â Â Â Â Â Â static YourBrain* Create() Â Â Â Â Â { Â Â Â Â Â Â Â Â Â Â Â return new YourBrain(); Â Â Â Â Â } }; Â class YourBrainDerived : public YourBrain { public: Â Â Â Â Â YourBrainDerived *Get() Â Â Â Â Â { Â Â Â Â Â Â Â Â Â Â Â return this; Â Â Â Â Â } Â Â Â Â Â Â static YourBrainDerived* Create() Â Â Â Â Â { Â Â Â Â Â Â Â Â Â Â Â return new YourBrainDerived(); Â Â Â Â Â } }; Â std::vector<YourBrain *> GetListOfYourBrain() { Â Â Â Â Â std::vector<YourBrain *> oList; Â Â Â Â Â oList.push_back(YourBrain::Create()); Â Â Â Â Â oList.push_back(YourBrainDerived::Create()); Â Â Â Â Â return oList; } Â #include <boost/shared_ptr.hpp> #include <boost/enable_shared_from_this.hpp> Â class YourBrainOnSharedPointers : public boost::enable_shared_from_this<YourBrainOnSharedPointers> { public: Â Â Â Â Â YourBrainOnSharedPointers(); Â Â Â Â Â virtual ~YourBrainOnSharedPointers(); Â Â Â Â Â Â boost::shared_ptr<YourBrainOnSharedPointers> Get() Â Â Â Â Â { Â Â Â Â Â Â Â Â Â Â Â return shared_from_this(); Â Â Â Â Â } Â Â Â Â Â Â static boost::shared_ptr<YourBrainOnSharedPointers> Create() Â Â Â Â Â { Â Â Â Â Â Â Â Â Â Â Â return boost::shared_ptr<YourBrainOnSharedPointers>(new YourBrainOnSharedPointers()); Â Â Â Â Â } }; Â class YourBrainOnSharedPointersDerived : public YourBrainOnSharedPointers { public: Â Â Â Â Â boost::shared_ptr<YourBrainOnSharedPointersDerived> Get() Â Â Â Â Â { Â Â Â Â Â Â Â Â Â Â Â return boost::dynamic_pointer_cast<YourBrainOnSharedPointersDerived>(shared_from_this()); Â Â Â Â Â } Â Â Â Â Â Â static boost::shared_ptr<YourBrainOnSharedPointersDerived> Create() Â Â Â Â Â { Â Â Â Â Â Â Â Â Â Â Â return boost::shared_ptr<YourBrainOnSharedPointersDerived>(new YourBrainOnSharedPointersDerived()); Â Â Â Â Â } }; Â std::vector<boost::shared_ptr<YourBrainOnSharedPointers> > GetListOfYourBrainOnSharedPointers() { Â Â Â Â Â std::vector<boost::shared_ptr<YourBrainOnSharedPointers>> oList; Â Â Â Â Â oList.push_back(boost::shared_ptr<YourBrainOnSharedPointers>(YourBrainOnSharedPointers::Create())); Â Â Â Â Â oList.push_back(boost::shared_ptr<YourBrainOnSharedPointersDerived>(YourBrainOnSharedPointersDerived::Create())); Â Â Â Â Â return oList; }
Any Questions?
(If the post just looks like an unreadable pile of punctuation, that's kind of the point).