Changeset d76c105


Ignore:
Timestamp:
Jan 5, 2011, 1:48:15 PM (15 years ago)
Author:
Frederik Heber <heber@…>
Children:
567640
Parents:
1afcbe
git-author:
Frederik Heber <heber@…> (01/05/11 11:26:48)
git-committer:
Frederik Heber <heber@…> (01/05/11 13:48:15)
Message:

Added Prototype Factory pattern.

  • the Prototype Factory basically stores Clone instead of Creator patterns in its lookup tables to produce.
  • Clone has not protected cstor/dstor but is friend with CloneTest and PrototypeFactoryStub to grant them access.
  • also these prototypes may be manipulated by befriended classes.
  • added unit test and stub.
  • Library version is now 3:0:0, API version is 1.0.5.
Files:
8 added
5 edited

Legend:

Unmodified
Added
Removed
  • configure.ac

    r1afcbe rd76c105  
    33
    44AC_PREREQ([2.65])
    5 AC_INIT([CodePatterns], [1.0.4], [heber@ins.uni-bonn.de], [codepatterns], [http://trac.ins.uni-bonn.de/projects/CodePatterns/])
     5AC_INIT([CodePatterns], [1.0.5], [heber@ins.uni-bonn.de], [codepatterns], [http://trac.ins.uni-bonn.de/projects/CodePatterns/])
    66AC_CONFIG_AUX_DIR(config)
    77AC_CONFIG_SRCDIR([src/Patterns/Singleton_impl.hpp])
     
    2525# refer to the libtool manual, section "Updating library version information":
    2626# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
    27 AC_SUBST([CODEPATTERNS_SO_VERSION], [2:2:0])
    28 AC_SUBST([CODEPATTERNS_API_VERSION], [1.0.4])
     27AC_SUBST([CODEPATTERNS_SO_VERSION], [3:0:0])
     28AC_SUBST([CODEPATTERNS_API_VERSION], [1.0.5])
    2929
    3030# Checks for libraries.
  • src/Makefile.am

    r1afcbe rd76c105  
    4444        Patterns/ObservedIterator.hpp \
    4545        Patterns/Observer.hpp \
     46        Patterns/PrototypeFactory.hpp \
     47        Patterns/PrototypeFactory_impl.hpp \
    4648        Patterns/Registry.hpp \
    4749        Patterns/Singleton.hpp
  • src/Patterns/Factory_impl.hpp

    r1afcbe rd76c105  
    7272 *
    7373 */
    74 #define seqitems_as_enum_key_map(z,n,seq_with_elements, map, keytype, name_space, suffix) \
    75   map [ \
    76   BOOST_PP_SEQ_ELEM(n, seq_with_elements) \
    77   ] = keytype< name_space BOOST_PP_SEQ_ELEM(n, seq_with_elements) suffix > ();
     74#define seqitems_as_enum_key_map(z,n,_seq_with_elements, _map, _keytype, _key_name_space, _type_name_space, _type_suffix) \
     75  _map [ _key_name_space \
     76  BOOST_PP_SEQ_ELEM(n, _seq_with_elements) \
     77  ] = _keytype< _type_name_space BOOST_PP_SEQ_ELEM(n, _seq_with_elements) _type_suffix > ();
    7878
    7979/** Functions that allows to print a given seq of elements in the way of
     
    105105 * EnumMap[ "four" ] = test:: four;
    106106 */
    107 #define seqitems_as_enum_value_map(z,n,seq_with_elements, map, type_specifier, type_suffix, enum_name_space) \
    108   map [ type_specifier  \
    109   BOOST_PP_SEQ_ELEM(n, seq_with_elements) \
    110   type_suffix \
    111   ] = enum_name_space BOOST_PP_SEQ_ELEM(n, seq_with_elements);
     107#define seqitems_as_enum_value_map(z,n,_seq_with_elements, _map, _type_specifier, _type_suffix, _enum_name_space) \
     108  _map [ _type_specifier  \
     109  BOOST_PP_SEQ_ELEM(n, _seq_with_elements) \
     110  _type_suffix \
     111  ] = _enum_name_space BOOST_PP_SEQ_ELEM(n, _seq_with_elements);
    112112
    113113
     
    137137{
    138138  // fill PrototypeTable
    139 #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 > )
     139#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 > )
    140140#define BOOST_PP_LOCAL_LIMITS  (0, BOOST_PP_SEQ_SIZE(type_seq)-1 )
    141141#include BOOST_PP_LOCAL_ITERATE()
  • src/Patterns/unittests/Makefile.am

    r1afcbe rd76c105  
    1414  FactoryUnitTest \
    1515  ObserverUnitTest \
     16  PrototypeFactoryUnitTest \
    1617  RegistryUnitTest \
    1718  SingletonUnitTest
     
    7374ObserverUnitTest_LDADD = $(TESTLIBS)
    7475
     76PrototypeFactoryUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
     77        PrototypeFactoryUnitTest.cpp \
     78        PrototypeFactoryUnitTest.hpp \
     79        stubs/CloneStub.cpp \
     80        stubs/CloneStub.hpp \
     81        stubs/CommonStub.cpp \
     82        stubs/CommonStub.hpp \
     83        stubs/PrototypeFactoryStub.hpp \
     84        stubs/PrototypeFactoryStub.cpp \
     85        ../PrototypeFactory.hpp \
     86        ../FactoryTypeList.hpp \
     87        ../PrototypeFactory_impl.hpp
     88PrototypeFactoryUnitTest_LDADD = $(TESTLIBS)
     89
    7590RegistryUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
    7691        RegistryUnitTest.cpp \
  • src/Patterns/unittests/stubs/CloneStub.hpp

    r1afcbe rd76c105  
    2424};
    2525
     26class CloneTest;
     27class PrototypeFactoryStub;
     28
    2629template <class T>
    2730class Prototype :
     
    2932  public Clone<IPrototype>
    3033{
    31 public:
     34    /**
     35     * Prototype Factory is friend because it needs to access protected cstor
     36     * to instantiate prototypes.
     37     */
     38    friend class PrototypeFactoryStub;
     39
     40    /**
     41     * Test is friend such that it can access protected cstor.
     42     */
     43    friend class CloneTest;
     44
     45protected:
    3246    Prototype() {
    3347      member.setcount(0);
     
    3549    ~Prototype() {};
    3650
     51public:
    3752    void count() {
    3853      member.count();
Note: See TracChangeset for help on using the changeset viewer.