Noise Modeler Library  0.1
Library for procedurally generating noise-based terrains and other content
 All Classes Files Functions Variables Enumerations Enumerator Groups Pages
nm::TypeManager Class Reference

The top-level entity of a noise model. Encapsulates several user types as well as built-in types. More...

#include <typemanager.hpp>

Inheritance diagram for nm::TypeManager:
nm::UserDataProvider

Public Member Functions

 TypeManager ()
 Creates a new TypeManager. More...
 
bool addUserType (std::unique_ptr< ModuleType > moduleType)
 Add an existing user type to the TypeManager. More...
 
ModuleTypecreateUserType (std::string desiredName)
 try to create a new usertype with the given name More...
 
const ModuleTypegetType (std::string name) const
 Search for a module type with the given name. More...
 
const ModuleTypegetBuiltinType (std::string name) const
 Search for a built-in type with the given name.
 
const ModuleTypegetUserType (std::string name) const
 Search for a user type with the given name.
 
ModuleTypegetUserType (std::string name)
 Search for a user type with the given name.
 
void initBuiltinTypes ()
 Populate the list of built-in module types.
 
unsigned int numBuiltinTypes () const
 
const ModuleTypegetBuiltinType (unsigned int index) const
 
unsigned int numUserTypes () const
 
const ModuleTypegetUserType (unsigned int index) const
 
- Public Member Functions inherited from nm::UserDataProvider
void * getUserData () const
 
void setUserData (void *userData)
 

Public Attributes

signal< void(TypeManager &)> destroying
 This signal is emitted before the TypeManager is destroyed.
 
signal< void(TypeManager &)> userTypesChanged
 This signal is emitted when the list of user type changes.
 

Detailed Description

The top-level entity of a noise model. Encapsulates several user types as well as built-in types.

A type manager is the top-level entity in the model hierarchy.

Two lists of ModuleTypes are maintained in a TypeManager, the user types, and the built-in types.

A user type may be constructed explicitly, or may be returned from a Parser in the form of a unique_ptr.

New user types can conveniently be added to the type manager, using the method createUserType().

A TypeManager owns the ModuleTypes it manages.

Constructor & Destructor Documentation

nm::TypeManager::TypeManager ( )

Creates a new TypeManager.

Note that initBuiltinTypes method has to be called explicitly to populate the list of buil-in types.

Member Function Documentation

bool nm::TypeManager::addUserType ( std::unique_ptr< ModuleType moduleType)

Add an existing user type to the TypeManager.

Returns
true if there was not a naming conflict and the type was added.

To create a new user type, consider using createUserType instead.

ModuleType * nm::TypeManager::createUserType ( std::string  desiredName)

try to create a new usertype with the given name

Returns
If a ModuleType was created, a pointer to it is returned. Note that the ModuleType is still owned by the TypeManager.

If the name is unavailable a different name may be chosen.

const ModuleType * nm::TypeManager::getType ( std::string  name) const

Search for a module type with the given name.

Returns
A pointer to a user type or built-in type, or nullptr if it was not found.

The documentation for this class was generated from the following files: