Index: configure.ac
===================================================================
--- configure.ac	(revision 1afcbe8522d371fe4aec395a771af07becac8248)
+++ configure.ac	(revision d76c105521eae2cb351abe774baa0111bf43e75c)
@@ -3,5 +3,5 @@
 
 AC_PREREQ([2.65])
-AC_INIT([CodePatterns], [1.0.4], [heber@ins.uni-bonn.de], [codepatterns], [http://trac.ins.uni-bonn.de/projects/CodePatterns/])
+AC_INIT([CodePatterns], [1.0.5], [heber@ins.uni-bonn.de], [codepatterns], [http://trac.ins.uni-bonn.de/projects/CodePatterns/])
 AC_CONFIG_AUX_DIR(config)
 AC_CONFIG_SRCDIR([src/Patterns/Singleton_impl.hpp])
@@ -25,6 +25,6 @@
 # refer to the libtool manual, section "Updating library version information":
 # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
-AC_SUBST([CODEPATTERNS_SO_VERSION], [2:2:0])
-AC_SUBST([CODEPATTERNS_API_VERSION], [1.0.4])
+AC_SUBST([CODEPATTERNS_SO_VERSION], [3:0:0])
+AC_SUBST([CODEPATTERNS_API_VERSION], [1.0.5])
 
 # Checks for libraries.
Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision 1afcbe8522d371fe4aec395a771af07becac8248)
+++ src/Makefile.am	(revision d76c105521eae2cb351abe774baa0111bf43e75c)
@@ -44,4 +44,6 @@
 	Patterns/ObservedIterator.hpp \
 	Patterns/Observer.hpp \
+	Patterns/PrototypeFactory.hpp \
+	Patterns/PrototypeFactory_impl.hpp \
 	Patterns/Registry.hpp \
 	Patterns/Singleton.hpp
Index: src/Patterns/Factory_impl.hpp
===================================================================
--- src/Patterns/Factory_impl.hpp	(revision 1afcbe8522d371fe4aec395a771af07becac8248)
+++ src/Patterns/Factory_impl.hpp	(revision d76c105521eae2cb351abe774baa0111bf43e75c)
@@ -72,8 +72,8 @@
  *
  */
-#define seqitems_as_enum_key_map(z,n,seq_with_elements, map, keytype, name_space, suffix) \
-  map [ \
-  BOOST_PP_SEQ_ELEM(n, seq_with_elements) \
-  ] = keytype< name_space BOOST_PP_SEQ_ELEM(n, seq_with_elements) suffix > ();
+#define seqitems_as_enum_key_map(z,n,_seq_with_elements, _map, _keytype, _key_name_space, _type_name_space, _type_suffix) \
+  _map [ _key_name_space \
+  BOOST_PP_SEQ_ELEM(n, _seq_with_elements) \
+  ] = _keytype< _type_name_space BOOST_PP_SEQ_ELEM(n, _seq_with_elements) _type_suffix > ();
 
 /** Functions that allows to print a given seq of elements in the way of
@@ -105,9 +105,9 @@
  * EnumMap[ "four" ] = test:: four;
  */
-#define seqitems_as_enum_value_map(z,n,seq_with_elements, map, type_specifier, type_suffix, enum_name_space) \
-  map [ type_specifier  \
-  BOOST_PP_SEQ_ELEM(n, seq_with_elements) \
-  type_suffix \
-  ] = enum_name_space BOOST_PP_SEQ_ELEM(n, seq_with_elements);
+#define seqitems_as_enum_value_map(z,n,_seq_with_elements, _map, _type_specifier, _type_suffix, _enum_name_space) \
+  _map [ _type_specifier  \
+  BOOST_PP_SEQ_ELEM(n, _seq_with_elements) \
+  _type_suffix \
+  ] = _enum_name_space BOOST_PP_SEQ_ELEM(n, _seq_with_elements);
 
 
@@ -137,5 +137,5 @@
 {
   // fill PrototypeTable
-#define BOOST_PP_LOCAL_MACRO(n) seqitems_as_enum_key_map(~, n, type_seq, PrototypeTable, new Creator< Abstract_Interface_Class BOOST_PP_COMMA() Abstract_Encapsulation_Class, type_name_space, type_name_space_suffix > )
+#define BOOST_PP_LOCAL_MACRO(n) seqitems_as_enum_key_map(~, n, type_seq, PrototypeTable, new Creator< Abstract_Interface_Class BOOST_PP_COMMA() Abstract_Encapsulation_Class, FactoryTypeList<Abstract_Interface_Class>::, type_name_space, type_name_space_suffix > )
 #define BOOST_PP_LOCAL_LIMITS  (0, BOOST_PP_SEQ_SIZE(type_seq)-1 )
 #include BOOST_PP_LOCAL_ITERATE()
Index: src/Patterns/PrototypeFactory.hpp
===================================================================
--- src/Patterns/PrototypeFactory.hpp	(revision d76c105521eae2cb351abe774baa0111bf43e75c)
+++ src/Patterns/PrototypeFactory.hpp	(revision d76c105521eae2cb351abe774baa0111bf43e75c)
@@ -0,0 +1,483 @@
+/*
+ * PrototypeFactory.hpp
+ *
+ *  Created on: Jan 3, 2011
+ *      Author: heber
+ */
+
+#ifndef PROTOTYPEFACTORY_HPP_
+#define PROTOTYPEFACTORY_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <map>
+#include <typeinfo>
+
+#include "Assert.hpp"
+
+#include "Clone.hpp"
+
+class PrototypeFactoryTest;
+
+/** \section <PrototypeFactory> (Prototype Factory Howto)
+ *
+ * This template produces the generic prototype factory pattern.
+ *
+ * <h2> Introduction </h2>
+ *
+ * The prototype factory is very similar to the factory pattern with one
+ * important difference: An prototype factory contains prototypes that are
+ * cloned, whereas a factory contains creation wrappers that just create
+ * a new object (i.e. without copying any additional information).
+ *
+ * A prototype factory is a class that instantiates other types. In order to be
+ * able to do so the following prerequisites must be met:
+ * -# there is a list of types the factory should be able to produce
+ * -# these types have to implement the Clone pattern, i.e. derive from it and
+ *    implement a function clone(), see @ref <Clone> ''(Clone)''.
+ * -# they all must be derived from a common class (e.g. an interface) which is
+ *    the type of the reference the factory returned the newly created objects
+ *    as.
+ *
+ * The reason for the last one is that it is not possible -- except by an ugly
+ * static_cast -- to retrieve the particular type and if nonetheless needed,
+ * factory is probably the wrong pattern. After all what a factory does is
+ * hiding the specifics of a certain subtype, e.g. to control a motor it is not
+ * necessary to know how fast it goes and what it precisely does, you just need
+ * need the throttle as a control and some kind of rpm feedback. This control
+ * and feedback would be the stuff abstracted into the interface class.
+ *
+ * <h2>How to make a class Prototype Factory</h2>
+ *
+ * If you want to make a class a Prototype Factory you can use the following
+ * sequence of steps.
+ *
+ * Before we begin, we assume the following #defines to represent ...
+ * - Abstract_Interface_Class: the aforementioned common interface of all
+ *    particular types the factory should produce.
+ * - Abstract_Encapsulation_Class: we need to connect the interface class (which
+ *    must not be a template) with the types to put into the factory. Hence, we
+ *    need this (templated) class that encapsulates each possible type as its
+ *    template argument while deriving from (and implementing) the abstract
+ *    interface as well.
+ * - MyPrototypeFactory: Your specific factory that spills out references to
+ *    Abstract_Interface_Class that are embodied by
+ *    Abstract_Encapsulation_Class instances.
+ *
+ * For present code, have a look at RandomNumberDistributionFactory.def,
+ * RandomNumberDistribution_Encapsulation.hpp and
+ * RandomNumberDistributionFactory.hpp.
+ *
+ * @attention{
+ * One last \b warning before we begin: Your types should reside in a distinct
+ * (and not the global) namespace, otherwise you may get strange errors such
+ * as
+ * \verbatim
+ * /usr/include/boost/preprocessor/iteration/detail/local.hpp:34: error: type/value mismatch at argument 1 in template parameter list for âtemplate<class T> class stubâ
+ * /usr/include/boost/preprocessor/iteration/detail/local.hpp:34: error:   expected a type, got â(FactoryTypeList::ListOfKnownTypes)0uâ
+ * \endverbatim
+ * i.e. the compiler cannot discern between the enumerated types and the true
+ * types due.
+ * @remarks But having your particular types in their own name space is always
+ *          a good idea.
+ * }
+ *
+ * Now beginning, first remember that all we need is a list of already present
+ * types, i.e. implemented classes. The rest is the stuff below which is all
+ * you need (and although it looks like quite a lot, it is actually not).
+ *
+ * Then, do the following steps:
+ * - create a file "RandomNumberDistributionFactory.def" containing only
+ *   preprocessor defines as follows:
+ *   @code
+ *   #ifndef RANDOMNUMBERDISTRIBUTIONPROTOTYPEFACTORY_DEF_
+ *   #define RANDOMNUMBERDISTRIBUTIONPROTOTYPEFACTORY_DEF_
+ *
+ *   #define type_seq (uniform_smallint)(uniform_int)
+ *   #define Abstract_Interface_Class RandomNumberDistribution
+ *   #define Abstract_Encapsulation_Class RandomNumberDistribution_Encapsulation
+ *   #define type_name_space boost::
+ *   #undef type_suffix
+ *
+ *   #endif //RANDOMNUMBERDISTRIBUTIONPROTOTYPEFACTORY_DEF_
+ *   @endcode
+ *   where \a type_seq is the list of types, each element in round brackets,
+ *   \a Abstract_Interface_Class is the class name of the abstract base class
+ *   which a reference to the factory spills out, and
+ *   \a Abstract_Encapsulation_Class is the class name of the (templated)
+ *   encapsulation class of each type. Optionally, these types may reside in
+ *   some other name_space, define this one via type_name_space (with suffixes
+ *   double colons!). If you need to add something to the types such as "<>",
+ *   do so in type_suffix.
+ *   Note that the first two and the last line are just to avoid double
+ *   inclusion, also the define made therein is used for the following step ...
+ * - create the undefine file "RandomNumberDistributionFactory.undef" which
+ *   undefines all the previously made definitions to allow for more factories
+ *   created without the danger of the various defines getting in the way of
+ *   each other:
+ *   @code
+ *   #ifdef RANDOMNUMBERDISTRIBUTIONPROTOTYPEFACTORY_DEF_
+ *
+ *   #undef type_seq
+ *   #undef type_seq_size
+ *   #undef Abstract_Interface_Class
+ *   #undef Abstract_Encapsulation_Class
+ *   #undef type_name_space
+ *   #undef type_suffix
+ *
+ *   #undef RANDOMNUMBERDISTRIBUTIONPROTOTYPEFACTORY_DEF_
+ *   #endif
+ *   @endcode
+ * - Create the encapsulation of the desired types, listed in the above define
+ *   type_seq via a templated class:
+ *   @code
+ *    #include "Clone.hpp"  // the creator wrapper
+ *    #include "RandomNumberDistribution.hpp" // the abstract interface class
+ *    template <class type>
+ *    class RandomNumberDistribution_Encapsulation :
+ *      public RandomNumberDistribution,  // inherit from abstract interface
+ *      public Clone<RandomNumberDistribution> // the specialized clone pattern
+ *    {
+ *      // Our Prototype Factory is friend because it needs to access protected cstor
+ *      // to instantiate prototypes.
+ *      friend class RandomNumberDistributionFactory;
+ *
+ *    protected: // no one except factory and ourselves should be allowed to call them
+ *      RandomNumberDistribution_Encapsulation() {} // constructor
+ *      virtual ~RandomNumberDistribution_Encapsulation() {} // virtual destructor
+ *    public:
+ *      // ... some interface functions here with template implementation ...
+ *      // i.e. those defined as virtual functions in the abstract interface
+ *      RandomNumberDistribution* clone() {
+ *        // .. instantiate a clone of this instance ..
+ *        return MyClone;
+ *      };
+ *    private:
+ *      type encapsulated_type; // the instance of the type to encapsulate
+ *    };
+ *   @endcode
+ * - in the header of your factory put these before any declaration:
+ *   @code
+ *   // has to be appear BEFORE PrototypeFactory.hpp is included!
+ *   #include "RandomNumberDistributionFactory.def"
+ *   #include "CodePatterns/FactoryTypeList.hpp"
+ *   #include "RandomNumberDistributionFactory.undef"
+ *   #include "CodePatterns/PrototypeFactory.hpp"
+ *   @endcode
+ *   Then declare your factory by inheriting from Factory<Abstract_Interface_Class>
+ *   @code
+ *   class RandomNumberDistributionFactory :
+ *     public Factory<RandomNumberDistribution>
+ *   {
+ *    // place here all other classes as friends that are allowed to access
+ *    // Factory<RandomNumberDistribution>::getPrototypeManipulator()
+ *   public:
+ *     void FillPrototypeTable(); // these are defined automatically
+ *     void EmptyPrototypeTable(); // you don't have to implement them
+ *
+ *     RandomNumberDistributionFactory();
+ *     virtual ~RandomNumberDistributionFactory();
+ *
+ *   };
+ *   #include "RandomNumberDistributionFactory.undef"
+ *   @endcode
+ *   where the last includes undefines the defines made in the first step and
+ *   assures that another factory can be created without any old defines
+ *   getting in the way.
+ *   @note FactoryTypeList.hpp is necessary as we can't have a forward
+ *         declaration of an enum which we need in the header of
+ *         PrototypeFactory<T>. Hence, there is an extra class the wraps the
+ *         enum which we inherit.
+ * - finally implement the prototype factory by:
+ *   @code
+ *   #include "RandomNumberDistribution_Encapsulation.hpp"
+ *   #include "RandomNumberDistributionFactory.hpp"
+ *   // has to be included BEFORE PrototypeFactory_impl.hpp!
+ *   #include "RandomNumberDistributionFactory.def"
+ *   #include "CodePatterns/PrototypeFactory_impl.hpp"
+ *
+ *   RandomNumberDistributionFactory::RandomNumberDistributionFactory() {
+ *    FillPrototypeTable();
+ *   }
+ *   RandomNumberDistributionFactory::~RandomNumberDistributionFactory() {
+ *    EmptyPrototypeTable();
+ *   }
+ *
+ *   CONSTRUCT_SINGLETON(RandomNumberDistributionFactory)
+ *   CONSTRUCT_PROTOTYPEFACTORY(RandomNumberDistribution)
+ *
+ *   #include "RandomNumberDistributionFactory.undef"
+ *   @endcode
+ *   @note the two functions within the constructor that fill and empty the
+ *   prototype table are constructed automatically but you have to call them
+ *   because only you (that is RandomNumberDistributionFactory in our case)
+ *   is a true friend of RandomNumberDistribution_Encapsulation and can access
+ *   its cstor and dstor.
+ *
+ * That's all.
+ */
+template <class T>
+class PrototypeFactory : public FactoryTypeList<T>
+{
+public:
+  /** Constructor of class PrototypeFactory.
+   *
+   */
+  PrototypeFactory()
+  {
+    FillEnumTable();
+//    FillPrototypeTable();
+  }
+
+  /** (virtual) Destructor of class PrototypeFactory.
+   *
+   */
+  virtual ~PrototypeFactory()
+  {
+    // clear out factories map to allow boost::shared_ptr to do their work (i.e. to release mem)
+    // this is necessary as factory is an object
+    enums.clear();
+    names.clear();
+//    EmptyPrototypeTable();
+//    PrototypeTable.clear();
+  }
+
+
+  /** Typedef of enumeration of all types known to this factory
+   *
+   * @note The true enumeration has to be stored in a wrapper class
+   * FactoryTypeList because enumerations cannot be forward declared as is
+   * necessary here.
+   */
+  typedef enum FactoryTypeList<T>::ListOfKnownTypes TypeList;
+
+  /** Setter for currenttype to produce.
+   *
+   * @param instance_name name of type
+   */
+  void setCurrentType(const std::string instance_name)
+  {
+    ASSERT(enums.count(instance_name) != 0,
+        "PrototypeFactory<"+toString(typeid(T).name())+">::setCurrentType() - type "+instance_name+" is not registered.");
+    currenttype = enums[instance_name];
+  }
+
+  /** Setter for currenttype to produce.
+   *
+   * @param instance_type enumeration index of type
+   */
+  void setCurrentType(TypeList instance_type)
+  {
+    ASSERT(names.count(instance_type) != 0,
+        "PrototypeFactory<"+toString(typeid(T).name())+">::setCurrentType() - enum type "+toString(instance_type)+" is not registered.");
+    currenttype = instance_type;
+  }
+
+  /** Getter for currenttype to produce.
+   *
+   * @return name of currenttype
+   */
+  const std::string & getCurrentTypeName() const
+  {
+    return names[currenttype];
+  }
+
+  /** Getter for currenttype to produce.
+   *
+   * @return enumeration index of currenttype
+   */
+  TypeList getCurrentTypeEnum() const
+  {
+    return currenttype;
+  }
+
+  /** Getter for desired type of product.
+   *
+   * @param enumeration index of product
+   * @return reference to copy of product
+   */
+  T* getProduct(TypeList instance_type) const
+  {
+    ASSERT(names.count(instance_type) != 0,
+        "PrototypeFactory<"+toString(typeid(T).name())+">::getProduct() - enum type "+toString(instance_type)+" is not registered.");
+    return PrototypeTable[instance_type]->clone();
+  }
+
+  /** Getter for desired type of product.
+   *
+   * @param instance_name name of product
+   * @return reference to copy of product
+   */
+  T* getProduct(const std::string instance_name) const
+  {
+    ASSERT(enums.count(instance_name) != 0,
+        "PrototypeFactory<"+toString(typeid(T).name())+">::getProduct() - type name "+instance_name+" is not registered.");
+    return PrototypeTable[ enums[instance_name] ]->clone();
+  }
+
+  /** Getter for desired type of product.
+   *
+   * @param instance_type_info object of the desired type
+   * @return reference to copy of current type product or NULL if type mismatch
+   */
+  T* getProduct(const std::type_info &instance_type_info) const
+  {
+    ASSERT(types.count(instance_type_info.name()) != 0,
+        "PrototypeFactory<"+toString(typeid(T).name())+">::getProduct() - type info name "+instance_type_info.name()+" is not registered.");
+    return PrototypeTable[ types[instance_type_info.name()] ]->clone();
+  }
+
+  /** Getter for current type of product.
+   *
+   * @return reference to copy of current type product
+   */
+  T* getProduct() const
+  {
+    return PrototypeTable[currenttype]->create();
+  }
+
+  /** Getter for the name of the desired type of product.
+   *
+   * @return name of distribution
+   */
+  const std::string &getName(TypeList instance_type) const
+  {
+    ASSERT(names.count(instance_type) != 0,
+        "PrototypeFactory<"+toString(typeid(T).name())+">::getName() - enum type "+toString(instance_type)+" is not registered.");
+    return names[instance_type];
+  }
+
+  /** Getter for the enumeration index of the desired type of product.
+   *
+   * @return enum of distribution
+   */
+  TypeList getEnum(const std::string instance_name) const
+  {
+   ASSERT(enums.count(instance_name) != 0,
+       "PrototypeFactory<"+toString(typeid(T).name())+">::getEnum() - type name "+instance_name+" is not registered.");
+   return enums[instance_name];
+  }
+
+
+protected:
+  /** Getter for the true prototype of the product.
+  *
+  * @warning This method is \b intentionally protected such that only
+  * specific friends are allowed to access it.
+  * @warning This method performs a dynamic_cast from Clone<IPrototype>* to
+  * IPrototype*. This prevents also that prototype is cloneable outside of
+  * factory.
+  *
+  * @param instance_name name of product
+  * @return reference to prototype stored in this factory
+  */
+  T* getPrototypeManipulator(const std::string instance_name)
+  {
+    ASSERT(enums.count(instance_name) != 0,
+        "PrototypeFactory<"+toString(typeid(T).name())+">::getProduct() - type name "+instance_name+" is not registered.");
+    return dynamic_cast<T *>(PrototypeTable[ enums[instance_name] ]);
+  }
+
+  /** Getter for the true prototype of the product.
+  *
+  * @warning This method is \b intentionally protected such that only
+  * specific friends are allowed to access it.
+  *
+  * @param enumeration index of product
+  * @return reference to prototype stored in this factory
+  */
+  T* getPrototypeManipulator(TypeList instance_type)
+  {
+    ASSERT(names.count(instance_type) != 0,
+        "PrototypeFactory<"+toString(typeid(T).name())+">::getProduct() - enum type "+toString(instance_type)+" is not registered.");
+    return dynamic_cast<T *>(PrototypeTable[instance_type]);
+  }
+
+  /** Getter for the true prototype of the product.
+  *
+  * @warning This method is \b intentionally protected such that only
+  * specific friends are allowed to access it.
+  *
+  * @param instance_type_info object of the desired type
+  * @return reference to prototype stored in this factory
+  */
+  T* getPrototypeManipulator(const std::type_info &instance_type_info)
+  {
+    ASSERT(types.count(instance_type_info.name()) != 0,
+        "PrototypeFactory<"+toString(typeid(T).name())+">::getProduct() - type info name "+instance_type_info.name()+" is not registered.");
+    return dynamic_cast<T *>(PrototypeTable[ types[instance_type_info.name()] ]);
+  }
+
+  /** Creates instances of all possible distribution types
+   *  and stores them in \a DistributionPrototypeTable.
+   *
+   *  @note This has to be handed down to the actual implementation of the
+   *  desired prototype factory class as cstor and dstor of the abstract
+   *  encapsulation class are protected (of a @ref <Clone> (Clone)) and hence
+   *  cannot be accessed from this class (because we cannot befriend it from
+   *  here).
+   */
+  virtual void FillPrototypeTable() = 0;
+
+  /** Removes all prototypes from \a PrototypeTable and free's memory.
+   *
+   *  \sa FillPrototypeTable()
+   */
+  virtual void EmptyPrototypeTable() = 0;
+
+  /** Create association for enums to strings and vice versa
+   *  and stores them in \a distributions tables.
+   */
+  void FillEnumTable();
+
+  typedef std::map<
+      std::string,
+      TypeList
+      > TypeMap;
+  typedef std::map<
+      std::string,
+      TypeList
+      > EnumMap;
+  typedef std::map<
+      TypeList,
+      Clone<T> *
+      > InstanceTable;
+  typedef std::map<
+      TypeList,
+      std::string
+      > NameMap;
+
+  static TypeList currenttype;
+  static TypeMap types;
+  static EnumMap enums;
+  static InstanceTable PrototypeTable;
+  static NameMap names;
+};
+
+template <class T> typename PrototypeFactory<T>::TypeList PrototypeFactory<T>::currenttype = (typename PrototypeFactory<T>::TypeList)0;
+template <class T> typename PrototypeFactory<T>::TypeMap PrototypeFactory<T>::types;
+template <class T> typename PrototypeFactory<T>::EnumMap PrototypeFactory<T>::enums;
+template <class T> typename PrototypeFactory<T>::NameMap PrototypeFactory<T>::names;
+template <class T> typename PrototypeFactory<T>::InstanceTable PrototypeFactory<T>::PrototypeTable;
+
+/**
+ * This define allows simple instantiation of the necessary factory functions
+ * at a chosen place.
+ */
+#define CONSTRUCT_PROTOTYPEFACTORY(InstanceType) \
+    template PrototypeFactory<InstanceType>::PrototypeFactory(); \
+    template PrototypeFactory<InstanceType>::~PrototypeFactory(); \
+    template void PrototypeFactory<InstanceType>::setCurrentType(const std::string instance_name); \
+    template void PrototypeFactory<InstanceType>::setCurrentType(TypeList instance_type); \
+    template const std::string & PrototypeFactory<InstanceType>::getCurrentTypeName() const; \
+    template PrototypeFactory<InstanceType>::TypeList PrototypeFactory<InstanceType>::getCurrentTypeEnum() const; \
+    template InstanceType* PrototypeFactory<InstanceType>::getProduct(TypeList instance_type) const; \
+    template InstanceType* PrototypeFactory<InstanceType>::getProduct(const std::string instance_name) const; \
+    template const std::string &PrototypeFactory<InstanceType>::getName(TypeList instance_type) const; \
+    template PrototypeFactory<InstanceType>::TypeList PrototypeFactory<InstanceType>::getEnum(const std::string instance_name) const;
+
+
+#endif /* PROTOTYPEFACTORY_HPP_ */
Index: src/Patterns/PrototypeFactory_impl.hpp
===================================================================
--- src/Patterns/PrototypeFactory_impl.hpp	(revision d76c105521eae2cb351abe774baa0111bf43e75c)
+++ src/Patterns/PrototypeFactory_impl.hpp	(revision d76c105521eae2cb351abe774baa0111bf43e75c)
@@ -0,0 +1,159 @@
+/*
+ * PrototypeFactory_impl.hpp
+ *
+ *  Created on: Jan 3, 2011
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <boost/preprocessor/debug/assert.hpp>
+#include <boost/preprocessor/facilities/empty.hpp>
+#include <boost/preprocessor/iteration/local.hpp>
+#include <boost/preprocessor/punctuation/comma.hpp>
+#include <boost/preprocessor/punctuation/comma_if.hpp>
+#include <boost/preprocessor/punctuation/paren.hpp>
+#include <boost/preprocessor/seq/elem.hpp>
+#include <boost/preprocessor/seq/size.hpp>
+#include <boost/preprocessor/stringize.hpp>
+
+// check for required type_seq
+#ifdef type_seq
+#define type_seq_size BOOST_PP_SEQ_SIZE(type_seq)
+#else
+BOOST_PP_ASSERT_MSG( 0 , \
+    "std::cout << \"missing type_seq for creating PrototypeFactory<T>\" << std::endl")
+#define type_seq ()
+#endif
+
+// check for required FactoryNAME
+#ifndef FactoryNAME
+    BOOST_PP_ASSERT_MSG( 0 , \
+        "std::cout << \"missing FactoryNAME for creating PrototypeFactory<T>\" << std::endl")
+#define FactoryNAME NONE
+#endif
+
+// check for required Abstract_Interface_Class
+#ifndef Abstract_Interface_Class
+    BOOST_PP_ASSERT_MSG( 0 , \
+        "std::cout << \"missing Abstract_Interface_Class for creating PrototypeFactory<T>\" << std::endl")
+#define Abstract_Interface_Class NONE
+#endif
+
+// check for required Abstract_Encapsulation_Class
+#ifndef Abstract_Encapsulation_Class
+    BOOST_PP_ASSERT_MSG( 0 , \
+        "std::cout << \"missing Abstract_Encapsulation_Class for creating PrototypeFactory<T>\" << std::endl")
+#define Abstract_Encapsulation_Class NONE
+#endif
+
+// check for type_name_space, is only optional
+#ifndef type_name_space
+#define type_name_space BOOST_PP_EMPTY()
+#endif
+
+#ifndef type_name_space_suffix
+#define type_name_space_suffix BOOST_PP_EMPTY()
+#endif
+
+
+/** Functions that allows to print a given seq of elements in the way of
+ *  std::map from strings to enums.
+ *
+ * e.g. let "seq" be defined as
+ * #define seq (one)(two)(three)(four)
+ *
+ * then we use
+ * #define BOOST_PP_LOCAL_MACRO(n) seqitems_as_enum_key_map(seqsize, n, seq, EnumMap, test::)
+ * #define BOOST_PP_LOCAL_LIMITS  (0, BOOST_PP_SEQ_SIZE(seq)-1 )
+ * #include BOOST_PP_LOCAL_ITERATE()
+ *
+ * which expands by the preprocessor to:
+ * EnumMap[one] = test::one;
+ * EnumMap[two] = test::two;
+ * EnumMap[three] = test::three;
+ * EnumMap[four] = test::four;
+ *
+ */
+#define seqitems_as_enum_key_map(z,n,_seq_with_elements, _map, _keytype, _key_name_space, _type_name_space, _type_suffix) \
+  _map [ _key_name_space \
+  BOOST_PP_SEQ_ELEM(n, _seq_with_elements) \
+  ] = _keytype< _type_name_space BOOST_PP_SEQ_ELEM(n, _seq_with_elements) _type_suffix > ();
+
+/** Functions that allows to print a given seq of elements in the way of
+ *  std::map from strings to enums.
+ *
+ * e.g. let "seq" be defined as
+ * #define seq (one)(two)(three)(four)
+ *
+ * then we use
+ * #define BOOST_PP_LOCAL_MACRO(n) seqitems_as_enum_value_map(seqsize, n, seq, EnumMap, typid BOOST_PP_LPAREN() super:: , BOOST_PP_RPAREN().name() , test::)
+ * #define BOOST_PP_LOCAL_LIMITS  (0, BOOST_PP_SEQ_SIZE(seq)-1 )
+ * #include BOOST_PP_LOCAL_ITERATE()
+ *
+ * which expands by the preprocessor to:
+ * EnumMap[ typeid ( super:: one ) .name() ] = test::one;
+ * EnumMap[ typeid ( super:: two ) .name() ] = test::two;
+ * EnumMap[ typeid ( super:: three ) .name() ] = test::three;
+ * EnumMap[ typeid ( super:: four ) .name() ] = test::four;
+ *
+ * or we use
+ * #define BOOST_PP_LOCAL_MACRO(n) seqitems_as_enum_value_map(seqsize, n, seq, EnumMap, BOOST_PP_STRINGIZE BOOST_PP_LPAREN() , BOOST_PP_RPAREN() , test::)
+ * #define BOOST_PP_LOCAL_LIMITS  (0, BOOST_PP_SEQ_SIZE(seq)-1 )
+ * #include BOOST_PP_LOCAL_ITERATE()
+ *
+ * which expands by the preprocessor to:
+ * EnumMap[ "one" ] = test:: one;
+ * EnumMap[ "two" ] = test:: two;
+ * EnumMap[ "three" ] = test:: three;
+ * EnumMap[ "four" ] = test:: four;
+ */
+#define seqitems_as_enum_value_map(z,n,_seq_with_elements, _map, _type_specifier, _type_suffix, _enum_name_space) \
+  _map [ _type_specifier  \
+  BOOST_PP_SEQ_ELEM(n, _seq_with_elements) \
+  _type_suffix \
+  ] = _enum_name_space BOOST_PP_SEQ_ELEM(n, _seq_with_elements);
+
+
+template <>
+void PrototypeFactory<Abstract_Interface_Class>::FillEnumTable()
+{
+  // insert all known (enum, string) keys
+#define BOOST_PP_LOCAL_MACRO(n) seqitems_as_enum_value_map(~, n, type_seq, enums, BOOST_PP_STRINGIZE BOOST_PP_LPAREN() , BOOST_PP_RPAREN() , FactoryTypeList<Abstract_Interface_Class>::)
+#define BOOST_PP_LOCAL_LIMITS  (0, BOOST_PP_SEQ_SIZE(type_seq)-1 )
+#include BOOST_PP_LOCAL_ITERATE()
+
+  // insert all known (type, enum) keys
+#define BOOST_PP_LOCAL_MACRO(n) seqitems_as_enum_value_map(~, n, type_seq, types, typeid BOOST_PP_LPAREN() type_name_space , type_name_space_suffix BOOST_PP_RPAREN() .name(), FactoryTypeList<Abstract_Interface_Class>::)
+#define BOOST_PP_LOCAL_LIMITS  (0, BOOST_PP_SEQ_SIZE(type_seq)-1 )
+#include BOOST_PP_LOCAL_ITERATE()
+
+  // create invert mapping (string, enum)
+  for (PrototypeFactory<Abstract_Interface_Class>::EnumMap::const_iterator iter = enums.begin();
+      iter != enums.end();
+      ++iter) {
+    names.insert(make_pair(iter->second, iter->first));
+  }
+}
+
+void FactoryNAME::FillPrototypeTable()
+{
+  // fill PrototypeTable
+#define BOOST_PP_LOCAL_MACRO(n) seqitems_as_enum_key_map(~, n, type_seq, PrototypeTable, new Abstract_Encapsulation_Class , FactoryTypeList<Abstract_Interface_Class>::, type_name_space, type_name_space_suffix )
+#define BOOST_PP_LOCAL_LIMITS  (0, BOOST_PP_SEQ_SIZE(type_seq)-1 )
+#include BOOST_PP_LOCAL_ITERATE()
+}
+
+void FactoryNAME::EmptyPrototypeTable()
+{
+  for (InstanceTable::iterator iter = PrototypeTable.begin();
+      !PrototypeTable.empty();
+      iter = PrototypeTable.begin()) {
+    delete (iter->second);
+    PrototypeTable.erase(iter);
+  }
+  PrototypeTable.clear();
+}
Index: src/Patterns/unittests/Makefile.am
===================================================================
--- src/Patterns/unittests/Makefile.am	(revision 1afcbe8522d371fe4aec395a771af07becac8248)
+++ src/Patterns/unittests/Makefile.am	(revision d76c105521eae2cb351abe774baa0111bf43e75c)
@@ -14,4 +14,5 @@
   FactoryUnitTest \
   ObserverUnitTest \
+  PrototypeFactoryUnitTest \
   RegistryUnitTest \
   SingletonUnitTest
@@ -73,4 +74,18 @@
 ObserverUnitTest_LDADD = $(TESTLIBS)
 
+PrototypeFactoryUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
+	PrototypeFactoryUnitTest.cpp \
+	PrototypeFactoryUnitTest.hpp \
+	stubs/CloneStub.cpp \
+	stubs/CloneStub.hpp \
+	stubs/CommonStub.cpp \
+	stubs/CommonStub.hpp \
+	stubs/PrototypeFactoryStub.hpp \
+	stubs/PrototypeFactoryStub.cpp \
+	../PrototypeFactory.hpp \
+	../FactoryTypeList.hpp \
+	../PrototypeFactory_impl.hpp
+PrototypeFactoryUnitTest_LDADD = $(TESTLIBS)
+
 RegistryUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
 	RegistryUnitTest.cpp \
Index: src/Patterns/unittests/PrototypeFactoryUnitTest.cpp
===================================================================
--- src/Patterns/unittests/PrototypeFactoryUnitTest.cpp	(revision d76c105521eae2cb351abe774baa0111bf43e75c)
+++ src/Patterns/unittests/PrototypeFactoryUnitTest.cpp	(revision d76c105521eae2cb351abe774baa0111bf43e75c)
@@ -0,0 +1,184 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+/*
+ * PrototypeFactoryUnitTest.cpp
+ *
+ *  Created on: Jan 03, 2011
+ *      Author: heber
+ */
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+#include "Assert.hpp"
+
+#include "PrototypeFactoryUnitTest.hpp"
+
+#include "stubs/CommonStub.hpp"
+#include "stubs/PrototypeFactoryStub.hpp"
+
+#include <boost/nondet_random.hpp>
+#include <boost/random.hpp>
+#include <boost/random/additive_combine.hpp>
+#include <boost/random/discard_block.hpp>
+#include <boost/random/inversive_congruential.hpp>
+#include <boost/random/lagged_fibonacci.hpp>
+#include <boost/random/linear_congruential.hpp>
+#include <boost/random/linear_feedback_shift.hpp>
+#include <boost/random/mersenne_twister.hpp>
+#include <boost/random/random_number_generator.hpp>
+#include <boost/random/ranlux.hpp>
+#include <boost/random/shuffle_output.hpp>
+#include <boost/random/subtract_with_carry.hpp>
+#include <boost/random/xor_combine.hpp>
+#include <boost/random/bernoulli_distribution.hpp>
+#include <boost/random/binomial_distribution.hpp>
+#include <boost/random/cauchy_distribution.hpp>
+#include <boost/random/exponential_distribution.hpp>
+#include <boost/random/gamma_distribution.hpp>
+#include <boost/random/geometric_distribution.hpp>
+#include <boost/random/linear_congruential.hpp>
+#include <boost/random/lognormal_distribution.hpp>
+#include <boost/random/normal_distribution.hpp>
+#include <boost/random/poisson_distribution.hpp>
+#include <boost/random/triangle_distribution.hpp>
+#include <boost/random/uniform_01.hpp>
+#include <boost/random/uniform_int.hpp>
+#include <boost/random/uniform_on_sphere.hpp>
+#include <boost/random/uniform_real.hpp>
+#include <boost/random/uniform_smallint.hpp>
+
+#include <typeinfo>
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( PrototypeFactoryTest );
+
+void PrototypeFactoryTest::setUp()
+{
+  rndA =
+      PrototypeFactoryStub::getInstance().
+      PrototypeTable[PrototypeFactoryStub::Aclass]->clone();
+  CPPUNIT_ASSERT_EQUAL( 0,  rndA->getcount() );
+  rndB =
+      PrototypeFactoryStub::getInstance().
+      PrototypeTable[PrototypeFactoryStub::Bclass]->clone();
+  CPPUNIT_ASSERT_EQUAL( 0,  rndB->getcount() );
+
+  rndA_1 = NULL;
+  rndA_2 = NULL;
+  rndA_3 = NULL;
+}
+
+void PrototypeFactoryTest::tearDown()
+{
+  delete rndA;
+  delete rndA_1;
+  delete rndA_2;
+  delete rndA_3;
+  delete rndB;
+  PrototypeFactoryStub::purgeInstance();
+}
+
+void PrototypeFactoryTest::DistributionTest()
+{
+  // check the injectiveness of enum and string map
+  for (PrototypeFactoryStub::NameMap::const_iterator
+      iter = PrototypeFactoryStub::getInstance().names.begin();
+      iter != PrototypeFactoryStub::getInstance().names.end();
+      ++iter) {
+    CPPUNIT_ASSERT_EQUAL(
+        iter->second,
+        PrototypeFactoryStub::getInstance().getName(
+            PrototypeFactoryStub::getInstance().getEnum(
+                iter->second
+            )
+        )
+    );
+  }
+
+  // check distributions in the table
+  CPPUNIT_ASSERT_EQUAL(
+      std::string(typeid(Prototype<teststubs::Aclass>).name()),
+      std::string(typeid(*rndA).name())
+  );
+  CPPUNIT_ASSERT_EQUAL(
+      std::string(typeid(Prototype<teststubs::Bclass>).name()),
+      std::string(typeid(*rndB).name())
+  );
+}
+
+void PrototypeFactoryTest::getProductEnumTest()
+{
+  rndA_1 =
+      PrototypeFactoryStub::getInstance().getProduct(PrototypeFactoryStub::Aclass);
+  CPPUNIT_ASSERT( typeid(*rndA) == typeid(*rndA_1) );
+}
+
+void PrototypeFactoryTest::getProductNameTest()
+{
+  rndA_1 =
+      PrototypeFactoryStub::getInstance().getProduct(std::string("Aclass"));
+  CPPUNIT_ASSERT( typeid(*rndA) == typeid(*rndA_1) );
+}
+
+void PrototypeFactoryTest::getProductTypeTest()
+{
+  rndA_1 =
+      PrototypeFactoryStub::getInstance().getProduct( typeid(teststubs::Aclass) );
+  CPPUNIT_ASSERT( typeid(*rndA) == typeid(*rndA_1) );
+}
+
+void PrototypeFactoryTest::Individualitytest()
+{
+  // increasing this does not change the prototype
+  rndA->count();
+
+  rndA_1 = PrototypeFactoryStub::getInstance().getProduct(PrototypeFactoryStub::Aclass);
+  CPPUNIT_ASSERT_EQUAL( 0,  rndA_1->getcount() );
+  CPPUNIT_ASSERT( rndA->getcount() != rndA_1->getcount() );
+  rndA_1->count();
+  CPPUNIT_ASSERT( rndA->getcount() == rndA_1->getcount() );
+
+  rndA_2 = PrototypeFactoryStub::getInstance().getProduct(PrototypeFactoryStub::Aclass);
+  CPPUNIT_ASSERT_EQUAL( 0,  rndA_2->getcount() );
+  CPPUNIT_ASSERT( rndA->getcount() != rndA_2->getcount() );
+  rndA_2->count();
+  CPPUNIT_ASSERT( rndA->getcount() == rndA_2->getcount() );
+  CPPUNIT_ASSERT( rndA_1->getcount() == rndA_2->getcount() );
+}
+
+void PrototypeFactoryTest::PrototypeManipulatortest()
+{
+  // this method is protected and only friends may access it.
+  IPrototype *rndA_1 = PrototypeFactoryStub::getInstance().getPrototypeManipulator(std::string("Aclass"));
+
+  // do something with the prototype.
+  rndA_1->setcount(256);
+
+  // clone the type and check whether new default values holds
+  rndA_2 = PrototypeFactoryStub::getInstance().getProduct(PrototypeFactoryStub::Aclass);
+  CPPUNIT_ASSERT_EQUAL( 256, rndA_2->getcount() );
+
+  // rndA has been cloned before we have manipulated the prototype
+  CPPUNIT_ASSERT( rndA->getcount() != rndA_2->getcount() );
+
+  // do something with the prototype.
+  rndA_1->setcount(0);
+
+  rndA_3 = PrototypeFactoryStub::getInstance().getProduct(PrototypeFactoryStub::Aclass);
+  CPPUNIT_ASSERT_EQUAL( 0, rndA_3->getcount() );
+  CPPUNIT_ASSERT( rndA->getcount() == rndA_3->getcount() );
+}
Index: src/Patterns/unittests/PrototypeFactoryUnitTest.hpp
===================================================================
--- src/Patterns/unittests/PrototypeFactoryUnitTest.hpp	(revision d76c105521eae2cb351abe774baa0111bf43e75c)
+++ src/Patterns/unittests/PrototypeFactoryUnitTest.hpp	(revision d76c105521eae2cb351abe774baa0111bf43e75c)
@@ -0,0 +1,50 @@
+/*
+ * PrototypeFactoryUnitTest.hpp
+ *
+ *  Created on: Jan 03, 2011
+ *      Author: heber
+ */
+
+#ifndef PROTOTYPEFACTORYUNITTEST_HPP_
+#define PROTOTYPEFACTORYUNITTEST_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "stubs/CloneStub.hpp"
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class PrototypeFactoryTest : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( PrototypeFactoryTest );
+  CPPUNIT_TEST ( DistributionTest );
+  CPPUNIT_TEST ( getProductEnumTest );
+  CPPUNIT_TEST ( getProductNameTest );
+  CPPUNIT_TEST ( getProductTypeTest );
+  CPPUNIT_TEST ( Individualitytest );
+  CPPUNIT_TEST ( PrototypeManipulatortest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void DistributionTest();
+  void getProductEnumTest();
+  void getProductNameTest();
+  void getProductTypeTest();
+  void Individualitytest();
+  void PrototypeManipulatortest();
+
+private:
+  IPrototype* rndA;
+  IPrototype* rndA_1;
+  IPrototype* rndA_2;
+  IPrototype* rndA_3;
+  IPrototype* rndB;
+};
+
+#endif /* PROTOTYPEFACTORYUNITTEST_HPP_ */
Index: src/Patterns/unittests/stubs/CloneStub.hpp
===================================================================
--- src/Patterns/unittests/stubs/CloneStub.hpp	(revision 1afcbe8522d371fe4aec395a771af07becac8248)
+++ src/Patterns/unittests/stubs/CloneStub.hpp	(revision d76c105521eae2cb351abe774baa0111bf43e75c)
@@ -24,4 +24,7 @@
 };
 
+class CloneTest;
+class PrototypeFactoryStub;
+
 template <class T>
 class Prototype :
@@ -29,5 +32,16 @@
   public Clone<IPrototype>
 {
-public:
+    /**
+     * Prototype Factory is friend because it needs to access protected cstor
+     * to instantiate prototypes.
+     */
+    friend class PrototypeFactoryStub;
+
+    /**
+     * Test is friend such that it can access protected cstor.
+     */
+    friend class CloneTest;
+
+protected:
     Prototype() {
       member.setcount(0);
@@ -35,4 +49,5 @@
     ~Prototype() {};
 
+public:
     void count() {
       member.count();
Index: src/Patterns/unittests/stubs/PrototypeFactoryStub.cpp
===================================================================
--- src/Patterns/unittests/stubs/PrototypeFactoryStub.cpp	(revision d76c105521eae2cb351abe774baa0111bf43e75c)
+++ src/Patterns/unittests/stubs/PrototypeFactoryStub.cpp	(revision d76c105521eae2cb351abe774baa0111bf43e75c)
@@ -0,0 +1,41 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * PrototypeFactoryStub.cpp
+ *
+ *  Created on: Jan 4, 2011
+   Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Singleton_impl.hpp"
+
+#include "CommonStub.hpp"
+#include "PrototypeFactoryStub.hpp"
+
+// has to be included BEFORE PrototypeFactory_impl.hpp!
+#include "PrototypeFactoryStub.def"
+#include "PrototypeFactory_impl.hpp"
+
+
+PrototypeFactoryStub::PrototypeFactoryStub() {
+  FillPrototypeTable();
+}
+
+PrototypeFactoryStub::~PrototypeFactoryStub() {
+  EmptyPrototypeTable();
+}
+
+CONSTRUCT_SINGLETON(PrototypeFactoryStub)
+CONSTRUCT_PROTOTYPEFACTORY(IPrototype)
+
+#include "PrototypeFactoryStub.undef"
Index: src/Patterns/unittests/stubs/PrototypeFactoryStub.def
===================================================================
--- src/Patterns/unittests/stubs/PrototypeFactoryStub.def	(revision d76c105521eae2cb351abe774baa0111bf43e75c)
+++ src/Patterns/unittests/stubs/PrototypeFactoryStub.def	(revision d76c105521eae2cb351abe774baa0111bf43e75c)
@@ -0,0 +1,11 @@
+#ifndef ABSTRACTFACTORYSTUB_DEF_
+#define ABSTRACTFACTORYSTUB_DEF_
+
+#define type_seq (Aclass)(Bclass)
+#define FactoryNAME PrototypeFactoryStub
+#define Abstract_Interface_Class IPrototype
+#define Abstract_Encapsulation_Class Prototype
+#define type_name_space teststubs::
+#undef type_suffix
+
+#endif //ABSTRACTFACTORYSTUB_DEF_
Index: src/Patterns/unittests/stubs/PrototypeFactoryStub.hpp
===================================================================
--- src/Patterns/unittests/stubs/PrototypeFactoryStub.hpp	(revision d76c105521eae2cb351abe774baa0111bf43e75c)
+++ src/Patterns/unittests/stubs/PrototypeFactoryStub.hpp	(revision d76c105521eae2cb351abe774baa0111bf43e75c)
@@ -0,0 +1,42 @@
+/*
+ * PrototypeFactoryStub.hpp
+ *
+ *  Created on: Jan 4, 2011
+   Author: heber
+ */
+
+#ifndef PROTOTYPEFACTORYSTUB_HPP_
+#define PROTOTYPEFACTORYSTUB_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CloneStub.hpp"
+
+// triple has to be appear BEFORE PrototypeFactory.hpp is included!
+#include "PrototypeFactoryStub.def"
+#include "FactoryTypeList.hpp"
+#include "PrototypeFactoryStub.undef"
+
+#include "PrototypeFactory.hpp"
+
+#include "Singleton.hpp"
+
+class PrototypeFactoryStub :
+  public Singleton<PrototypeFactoryStub>,
+  public PrototypeFactory<IPrototype>
+{
+  friend class Singleton<PrototypeFactoryStub>;
+  friend class PrototypeFactoryTest;
+
+protected:
+  void FillPrototypeTable();
+  void EmptyPrototypeTable();
+
+  PrototypeFactoryStub();
+  virtual ~PrototypeFactoryStub();
+};
+
+#endif /* PROTOTYPEFACTORYSTUB_HPP_ */
Index: src/Patterns/unittests/stubs/PrototypeFactoryStub.undef
===================================================================
--- src/Patterns/unittests/stubs/PrototypeFactoryStub.undef	(revision d76c105521eae2cb351abe774baa0111bf43e75c)
+++ src/Patterns/unittests/stubs/PrototypeFactoryStub.undef	(revision d76c105521eae2cb351abe774baa0111bf43e75c)
@@ -0,0 +1,11 @@
+#ifdef ABSTRACTFACTORYSTUB_DEF_
+
+#undef type_seq
+#undef type_seq_size
+#undef FactoryNAME
+#undef Abstract_Interface_Class
+#undef Abstract_Encapsulation_Class
+#undef type_name_space
+
+#undef ABSTRACTFACTORYSTUB_DEF_
+#endif
