[prev in list] [next in list] [prev in thread] [next in thread] 

List:       boost
Subject:    [boost] Interest check: factory patterns
From:       Tor Brede Vekterli <vekterli () arcticinteractive ! com>
Date:       2009-02-27 18:43:46
Message-ID: d959617b0902271043r455bae1cl8ef4cb1f3cfe7af () mail ! gmail ! com
[Download RAW message or body]

Hi all

I've been working on a "Modern C++ Design"-inspired factory/abstract
factory pattern implementation for a while now, and was wondering if
there was any interest in having it as a Boost library at some point?
If my understanding of the existing Boost.Functional/Factory is
correct, then this should not really clash with its area of operation.

Factory features
  - Configurable identifier, mapping, error policy types
  - Function storage type can be overridden by the user on a per-factory basis

Abstract factory features:
  - Auto-generation of class hierarchies (a-la Loki)--allows passing
as individual factory fields
  - Passing of construction-arguments to the concrete type "creators"
(operator new by default, but extensible)
  - Prototypes
  - Easy (re-)binding of constructor arguments
  - Boost.Functions if none of the above are appropriate or flexible enough
  - Mixing and matching creators for concrete factories. i.e., allows
to use a prototype for one concrete type, Boost.Function for another,
operator new for the third and so on
  - Easily specify if the created object should be returned as a raw
pointer or a smart pointer (any type with a nested element_type is
automatically recognized)
  - Almost everything is policy-specifyable

Somewhat contrived example:

  typedef abstract_factory<
      // Want object created with no args, returned as raw pointer
      abstract_foo*
      // Want object created with std::string const ref, float by
value args; returned as auto_ptr
    , std::auto_ptr<abstract_bar>(const std::string&, float)
  > abstract_factory_t;

  concrete_factory<
      // Concrete factory for abstract_factory_t
      abstract_factory_t
      // Concrete creator for abstract_foo; prototype
    , prototype<>
      // Concrete creator for abstract_bar; operator new creator
(default when it's a regular type)
    , bar_impl
  > cf;

  // Set prototype for abstract_foo (takes ownership of raw pointers)
  cf.prototype<abstract_foo>(new fancy_foo_impl);

  const abstract_factory_t& af = cf;

  // By default invoke clone() on the stored prototype
  abstract_foo* foobj = af.create<abstract_foo>();

  // Forward args to creator, in this case operator new -->
constructor of bar_impl
  std::auto_ptr<abstract_bar> barobj = af.create<abstract_bar>("hello
boost", 1234.5f);

Preliminary documentation and download link can be found here:
http://arcticinteractive.com/static/boost/libs/factory/doc/html/index.html

I've yet to request any vault/sandbox access, because I first would
really like to get some input on what people who are far more
knowledgeable and experienced in C++ and software design than myself
think of it :). Critique, comments, suggestions etc. are very welcome
on all aspects of the library (code, design, documentation,...)

Regards,
Tor Brede Vekterli
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic