Mirror reflection library 0.5.13

mirror::factory_maker< Manufacturer, Suppliers, Enumerator, SourceTraits > Struct Template Reference

Helper class for more convenient instantiation of the factory template. More...

#include <mirror/factory.hpp>

Classes

struct  factory
 This meta-function creates a factory creating the Product. More...

Detailed Description

template<template< class, class > class Manufacturer, template< class, class > class Suppliers, template< class, class > class Enumerator, class SourceTraits>
struct mirror::factory_maker< Manufacturer, Suppliers, Enumerator, SourceTraits >

Helper class for more convenient instantiation of the factory template.

This template class can be used for a convenient creation of factories of the same kind but generating different types. If one wants to use the same kind of factory (i.e. using the same Manufacturer, Suppliers and Enumerator templates and the same SourceTraits parameter) to create different products, this template can be used in the following way:

  // implement the class which will be passed as the SourceTraits parameter
  class my_factory_param
  { ... some implementation ... };

  // implement the parameter manufacturer template
  template <class Product, class Param>
  class my_manufacturer
  { ... some implementation ... };

  // implement the parameter supplier(s) template
  template <class Product, class Param>
  class my_suppliers
  { ... some implementation ... };

  // implement the parameter enumerator template
  template <class Product, class Param>
  class my_enumerator
  { ... some implementation ... };

  // use the factory_maker template to define a custom factory maker
  typedef factory_maker<
      my_manufacturer,
      my_suppliers,
      my_enumerator,
      my_factory_param
  > my_maker;

  // use the maker to create some factories
  my_maker::factory<my_type_1>::type my_type_1_factory;
  my_maker::factory<my_type_2>::type my_type_2_factory;
  my_maker::factory<my_type_2>::type my_type_3_factory;

  my_type_1* x1 = my_type_1_factory.new_();
  my_type_2* x2 = my_type_2_factory.new_();
  my_type_3* x3 = my_type_3_factory.new_();
Template Parameters:
Manufacturera class template which knows how to construct the parametes for the constructors. this template can for example use this factory template recursivelly for elaborated types and specify how to construct and initialize instances of the native C++ types.
Suppliersa class template which knows how to get existing instances to be supplied as parameters to the constructors.
Enumeratora class template which knows how to get enumerated values from external representations, like their names or values.
SourceTraitsa parameter for the Manufacturer, Suppliers and Enumerator templates, which can be used for further configuration and fine-tuning of the generated factory.
See also:
factory
Examples:

mirror/example/factories/random_tetrahedron.cpp.


The documentation for this struct was generated from the following file:

Copyright © 2006-2011 Matus Chochlik, University of Zilina, Zilina, Slovakia.
<matus.chochlik -at- fri.uniza.sk>
<chochlik -at -gmail.com>
Documentation generated on Fri Dec 16 2011 by Doxygen (version 1.7.3).
Important note: Although the 'boostified' version of Mirror uses the Boost C++ libraries Coding Guidelines and is implemented inside of the boost namespace, it IS NOT an officially reviewed and accepted Boost library. Mirror is being developed with the intention to be submitted for review for inclusion to the Boost C++ libraries.