33 #ifndef DART_COMMON_FACTORY_HPP_
34 #define DART_COMMON_FACTORY_HPP_
38 #include <unordered_map>
39 #include <unordered_set>
60 typename HeldT = std::shared_ptr<BaseT>,
68 using Creator = std::function<HeldT(Args...)>;
69 template <
typename Key>
71 std::is_enum<Key>::value,
74 using CreatorMap = std::unordered_map<KeyT, Creator, HashType<KeyT>>;
86 template <
typename Derived>
102 HeldT
create(
const KeyT& key, Args&&... args);
107 std::unordered_set<KeyT>
getKeys()
const;
110 template <
typename Derived>
122 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:125
FactoryRegistrar(const KeyT &key, Creator creator)
Constructor.
Definition: Factory-impl.hpp:180
typename FactoryType::Creator Creator
Definition: Factory.hpp:130
Implementation of the Abstract Factory Pattern.
Definition: Factory.hpp:63
std::unordered_set< KeyT > getKeys() const
Get a set of the keys that are available for this Creator.
Definition: Factory-impl.hpp:155
std::unordered_map< KeyT, Creator, HashType< KeyT > > CreatorMap
Definition: Factory.hpp:74
bool canCreate(const KeyT &key)
Returns true if an object creator function is registered with the key.
Definition: Factory-impl.hpp:125
std::function< HeldT(Args...)> Creator
Definition: Factory.hpp:68
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:134
void registerCreator(const KeyT &key, Creator creator)
Registers a object creator function with a key.
Definition: Factory-impl.hpp:95
void unregisterCreator(const KeyT &key)
Unregisters the object creator function that is registered with a key.
Definition: Factory-impl.hpp:111
static HeldT defaultCreator(Args &&... args)
Definition: Factory-impl.hpp:167
virtual ~Factory()=default
Destructor.
typename std::conditional< std::is_enum< Key >::value, EnumClassHash, std::hash< Key > >::type HashType
Definition: Factory.hpp:73
void unregisterAllCreators()
Unregisters all the object creator functions.
Definition: Factory-impl.hpp:118
CreatorMap mCreatorMap
Object creator function map.
Definition: Factory.hpp:114
Singleton template class.
Definition: Singleton.hpp:51
Definition: BulletCollisionDetector.cpp:65
Definition: Factory-impl.hpp:85