6 #ifndef MATERIALX_FACTORY_H
7 #define MATERIALX_FACTORY_H
21 using Ptr = shared_ptr<T>;
23 using CreatorMap = std::unordered_map<string, CreatorFunction>;
29 _creatorMap[typeName] =
f;
35 return _creatorMap.find(typeName) != _creatorMap.end();
41 auto it = _creatorMap.find(typeName);
42 if (it != _creatorMap.end())
44 _creatorMap.erase(it);
52 auto it = _creatorMap.find(typeName);
53 return (it != _creatorMap.end() ? it->second() :
nullptr);
62 #endif // MATERIALX_FACTORY_H
Ptr create(const string &typeName) const
#define MATERIALX_NAMESPACE_BEGIN
shared_ptr< ShaderNodeImpl > Ptr
std::unordered_map< string, CreatorFunction > CreatorMap
bool classRegistered(const string &typeName) const
Determine if a class has been registered for a type name.
void unregisterClass(const string &typeName)
Unregister a registered class.
void registerClass(const string &typeName, CreatorFunction f)
#define MATERIALX_NAMESPACE_END