Ignore:
Timestamp:
Jan 4, 2011, 5:15:14 PM (15 years ago)
Author:
Frederik Heber <heber@…>
Children:
1afcbe
Parents:
746ff1
git-author:
Frederik Heber <heber@…> (01/04/11 15:57:33)
git-committer:
Frederik Heber <heber@…> (01/04/11 17:15:14)
Message:

Factory know has an additional type table and stubs have been refactored.

  • CommonStub.?pp contains basic classes with a int counter inside.
  • Library version is now 2:1:0, API is 1.0.3.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Patterns/Factory.hpp

    r746ff1 r724564  
    1515
    1616#include <map>
     17#include <typeinfo>
     18
     19#include "Assert.hpp"
    1720
    1821#include "Creator.hpp"
     
    285288  }
    286289
     290  /** Getter for desired type of product.
     291   *
     292   * @param type_info object of the desired type
     293   * @return reference to copy of current type product or NULL if type mismatch
     294   */
     295  T* getProduct(const std::type_info &instance_type_info) const
     296  {
     297    ASSERT(types.count(instance_type_info.name()) != 0,
     298        "Factory<"+toString(typeid(T).name())+">::getProduct() - type info name "+instance_type_info.name()+" is not registered.");
     299    return PrototypeTable[ types[instance_type_info.name()] ]->create();
     300  }
    287301
    288302  /** Getter for current type of product.
     
    330344  void FillEnumTable();
    331345
     346  typedef std::map<
     347      std::string,
     348      TypeList
     349      > TypeMap;
    332350  typedef std::map<
    333351      std::string,
     
    344362
    345363  static TypeList currenttype;
     364  static TypeMap types;
    346365  static EnumMap enums;
    347366  static InstanceTable PrototypeTable;
     
    350369
    351370template <class T> typename Factory<T>::TypeList Factory<T>::currenttype = (typename Factory<T>::TypeList)0;
     371template <class T> typename Factory<T>::TypeMap Factory<T>::types;
    352372template <class T> typename Factory<T>::EnumMap Factory<T>::enums;
    353373template <class T> typename Factory<T>::NameMap Factory<T>::names;
Note: See TracChangeset for help on using the changeset viewer.