33#ifndef DART_COMMON_FACTORY_HPP_
34#define DART_COMMON_FACTORY_HPP_
37#include <unordered_map>
56template <
typename KeyT,
58 typename HeldT = std::shared_ptr<BaseT>,
66 using Creator = std::function<HeldT(Args...)>;
67 template <
typename Key>
70 using CreatorMap = std::unordered_map<KeyT, Creator, HashType<KeyT>>;
82 template <
typename Derived>
98 HeldT
create(
const KeyT& key, Args&&... args);
103 template <
typename Derived>
111template <
typename KeyT,
114 typename HeldT = std::shared_ptr<BaseT>,
std::string type
Definition SdfParser.cpp:82
Helper class to register a object creator function to the Singleton.
Definition Factory.hpp:117
typename FactoryType::Creator Creator
Definition Factory.hpp:122
Implementation of the Abstract Factory Pattern.
Definition Factory.hpp:61
std::unordered_map< KeyT, Creator, HashType< KeyT > > CreatorMap
Definition Factory.hpp:70
bool canCreate(const KeyT &key)
Returns true if an object creator function is registered with the key.
Definition Factory-impl.hpp:148
std::function< HeldT(Args...)> Creator
Definition Factory.hpp:66
Factory()=default
Default constructor.
HeldT create(const KeyT &key, Args &&... args)
Creates an object of the class that is registered with a key.
Definition Factory-impl.hpp:160
void registerCreator(const KeyT &key, Creator creator)
Registers a object creator function with a key.
Definition Factory-impl.hpp:101
void unregisterCreator(const KeyT &key)
Unregisters the object creator function that is registered with a key.
Definition Factory-impl.hpp:127
static HeldT defaultCreator(Args &&... args)
Definition Factory-impl.hpp:185
virtual ~Factory()=default
Destructor.
typename std::conditional< std::is_enum< Key >::value, EnumClassHash, std::hash< Key > >::type HashType
Definition Factory.hpp:69
void unregisterAllCreators()
Unregisters all the object creator functions.
Definition Factory-impl.hpp:138
CreatorMap mCreatorMap
Object creator function map.
Definition Factory.hpp:107
Singleton template class.
Definition Singleton.hpp:51
Definition BulletCollisionDetector.cpp:63
Definition Factory-impl.hpp:88