Lumiera
0.pre.03
»edit your freedom«
|
Go to the source code of this file.
Framework for building a configurable factory, to generate families of related objects.
These building blocks are targeted towards the "classical" factory situation: obtaining objects of various kinds, which are related somehow (usually through an common interface). The creation of these objects might be non-trivial, while the number of flavours to be produced and the exact parametrisation isn't known beforehand and needs to be figured out at runtime. As a solution, thus a number of "fabrication lines" is set up, to be selected on invocation through an ID (which may be symbolic, hashed or structural).
Usually, the issue of object and storage management is closely related, while it is desirable to keep the object production logic clean of these rather technical concerns. The implementation built here separates the latter into a policy template invoked as a wrapper, accepting the raw product and either registering it, taking ownership, clone it or use it for more involved wiring. Obviously, the product generated by the installed "fabrication lines" needs to be delivered in a form acceptable by the concrete wrapper; mismatch will be spotted by the compiler on registration of the respective fabrication function.
Definition in file multifact.hpp.
#include "lib/error.hpp"
#include "lib/depend.hpp"
#include "util.hpp"
#include <functional>
#include <utility>
#include <memory>
#include <map>
Classes | |
struct | Build< TAR > |
Policy: use a custom functor to finish the generated product. More... | |
struct | BuildRefcountPtr< RAW > |
Wrapper taking ownership, by wrapping into smart-ptr. More... | |
struct | Fab< SIG, ID > |
Table of registered production functions for MultiFact. More... | |
struct | FabConfig< TY, Wrapper > |
struct | FabConfig< RET(ARGS...), Wrapper > |
class | MultiFact< SIG, ID, Wrapper > |
Factory for creating a family of objects by ID. More... | |
struct | PassAsIs< TAR > |
Dummy "wrapper", to perform the fabrication and return the unaltered product. More... | |
class | MultiFact< SIG, ID, Wrapper >::Singleton< IMP > |
Convenience shortcut for automatically setting up a production line, to fabricate a singleton instance of the given implementation target type (IMP) More... | |
struct | Build< TAR >::Wrapper< RAW > |
Namespaces | |
lib | |
Implementation namespace for support and library code. | |