Factory patterns version 1.2 released

January 20, 2009 by Tor Brede Vekterli

Since nobody has reported that the previous factory pattern code has attempted to physically or verbally assault them in any way (overly verbose template compilation errors do not count), I'm taking that as a good sign. As such, I have spent quite some time working on a new version with several additions and changes (most should be backwards compatible, but be aware of the namespace change). The most prominent additions/changes are:

  • create() can now be called with arguments, which will be forwarded appropriately. Support for argument-forwarding requires only changing the abstract type into a function signature with a pointer return type, e.g. abstract_factory<abstract_foo>abstract_factory<abstract_foo*(const std::string&)>, and then call my_factory.create<abstract_foo>("foo bar brawl");. Concrete factories need not be changed.
  • Added support for constructor argument (re-)binding for concrete factories (think a compile-time version of Boost.Bind for constructors)
  • Added support for dynamic creator functions for concrete factories
  • All factory classes are now contained within the boost::factory namespace to avoid any naming-conflicts. This is especially important since this isn't an official Boost library, and it would be bad mojo to step on the toes of those that are.
  • Moved to proper BoostBook documentation! This is still very much a work in progress, but the tutorial code is fairly complete and should hopefully be descriptive enough for most purposes

The original factory post has been updated, but it should only be seen as an introduction. Please refer to the factory documentation for your various factory cravings, including the download link. If you do not have any factory cravings, but simply like clicking links, it might also be for you.

As before, the code is header-only (except for the unit test file).

Posted in:

Comments

BHW on April 14, 2017

An interesting discussion is worth comment. I
believe that you should publish more about this issue,
it might not be a taboo matter but typically folks don't speak about such topics.
To the next! Best wishes!!

manicure on May 3, 2017

Thank you for sharing your thoughts. I really appreciate your efforts and I
will be waiting for your next write ups thanks once again.

Post a comment