Noise Modeler Library  0.1
Library for procedurally generating noise-based terrains and other content
 All Classes Files Functions Variables Enumerations Enumerator Groups Pages
typemanager.hpp
1 #ifndef NM_TYPEMANAGER_HPP
2 #define NM_TYPEMANAGER_HPP
3 
4 #include <nmlib/model/moduletype.hpp>
5 
6 #include <map>
7 #include <memory>
8 #include <vector>
9 
10 namespace nm {
11 
32 {
33 public:
40  TypeManager();
41  ~TypeManager();
48  bool addUserType(std::unique_ptr<ModuleType> moduleType);
56  ModuleType* createUserType(std::string desiredName);
62  const ModuleType *getType(std::string name) const;
64  const ModuleType *getBuiltinType(std::string name) const;
66  const ModuleType *getUserType(std::string name) const;
68  ModuleType *getUserType(std::string name);
70  void initBuiltinTypes();
71 
72  //index accessors
73  unsigned int numBuiltinTypes() const { return m_builtinTypes.size(); }
74  const ModuleType *getBuiltinType(unsigned int index) const { return m_builtinTypes.at(index).get(); }
75  unsigned int numUserTypes() const { return m_userTypes.size(); }
76  const ModuleType *getUserType(unsigned int index) const { return m_userTypes.at(index).get(); }
77 
78  //signals
80  signal<void(TypeManager&)> destroying;
82  signal<void(TypeManager&)> userTypesChanged;
83 
84 private:
85  void addBuiltinType(std::unique_ptr<const ModuleType> moduleType);
86  std::vector<std::unique_ptr<ModuleType>> m_userTypes;
87  std::vector<std::unique_ptr<const ModuleType>> m_builtinTypes;
88 };
89 
90 } // namespace nm
91 
92 #endif // NM_TYPEMANAGER_HPP
Base class for stuff that needs to provide user data in form of a void* pointer.
Definition: userdataprovider.hpp:10
The top-level entity of a noise model. Encapsulates several user types as well as built-in types...
Definition: typemanager.hpp:31
const ModuleType * getType(std::string name) const
Search for a module type with the given name.
Definition: typemanager.cpp:60
ModuleType * createUserType(std::string desiredName)
try to create a new usertype with the given name
Definition: typemanager.cpp:42
signal< void(TypeManager &)> userTypesChanged
This signal is emitted when the list of user type changes.
Definition: typemanager.hpp:82
bool addUserType(std::unique_ptr< ModuleType > moduleType)
Add an existing user type to the TypeManager.
Definition: typemanager.cpp:31
TypeManager()
Creates a new TypeManager.
Definition: typemanager.cpp:17
Describes a recipe for a module and its inputs and outputs.
Definition: moduletype.hpp:37
const ModuleType * getUserType(std::string name) const
Search for a user type with the given name.
Definition: typemanager.cpp:78
void initBuiltinTypes()
Populate the list of built-in module types.
Definition: typemanager.cpp:366
const ModuleType * getBuiltinType(std::string name) const
Search for a built-in type with the given name.
Definition: typemanager.cpp:70
signal< void(TypeManager &)> destroying
This signal is emitted before the TypeManager is destroyed.
Definition: typemanager.hpp:80