Changeset 724564 for src/Patterns/Factory.hpp
- Timestamp:
- Jan 4, 2011, 5:15:14 PM (15 years ago)
- 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Patterns/Factory.hpp
r746ff1 r724564 15 15 16 16 #include <map> 17 #include <typeinfo> 18 19 #include "Assert.hpp" 17 20 18 21 #include "Creator.hpp" … … 285 288 } 286 289 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 } 287 301 288 302 /** Getter for current type of product. … … 330 344 void FillEnumTable(); 331 345 346 typedef std::map< 347 std::string, 348 TypeList 349 > TypeMap; 332 350 typedef std::map< 333 351 std::string, … … 344 362 345 363 static TypeList currenttype; 364 static TypeMap types; 346 365 static EnumMap enums; 347 366 static InstanceTable PrototypeTable; … … 350 369 351 370 template <class T> typename Factory<T>::TypeList Factory<T>::currenttype = (typename Factory<T>::TypeList)0; 371 template <class T> typename Factory<T>::TypeMap Factory<T>::types; 352 372 template <class T> typename Factory<T>::EnumMap Factory<T>::enums; 353 373 template <class T> typename Factory<T>::NameMap Factory<T>::names;
Note:
See TracChangeset
for help on using the changeset viewer.