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::ModuleType Class Reference

Describes a recipe for a module and its inputs and outputs. More...

#include <moduletype.hpp>

Inheritance diagram for nm::ModuleType:
nm::NonCopyable nm::UserDataProvider

Public Types

enum  Category { Category::Primitive, Category::Composite, Category::GraphInput, Category::GraphOutput }
 Module type category. More...
 

Public Member Functions

 ModuleType (std::string name, std::string description)
 Simple Constructor for composite module types. More...
 
 ModuleType (std::string name, Category category=Category::Composite, std::string description="")
 
std::string getName () const
 A unique identifier for the module type.
 
void setName (std::string name)
 
std::string getDescription () const
 
void setDescription (std::string description)
 
bool isBuiltin () const
 A built-in module type is part of nmlib, and not created by the user.
 
bool isComposite () const
 A composite module type is built from a graph of modules of other types.
 
bool isPrimitive () const
 A primitive module type, is the opposite of a composite type.
 
bool isRemovable () const
 Some modules, like the ones representing inputs and outputs, may not be removed from their graphs. More...
 
bool isGraphInput () const
 A graph input module type represents the inputs of a composite module type.
 
bool isGraphOutput () const
 A graph output module type represents the outputs of a composite module type.
 
void setRemovable (bool removable)
 Change whether modules of this type may be removed from graphs or not.
 
unsigned int numInputs () const
 
const ModuleInputgetInput (std::string name) const
 
ModuleInputgetInput (std::string name)
 
const ModuleInputgetInput (unsigned int index) const
 
ModuleInputgetInput (unsigned int index)
 
void eachModuleInput (std::function< void(const ModuleInput &)> f) const
 Iterate over the inputs using the provided callback.
 
void eachModuleInput (std::function< void(ModuleInput &)> f)
 Iterate over the inputs using the provided callback.
 
ModuleInputaddInput (std::string name, SignalType signalType)
 Add a new input to the module type. More...
 
ModuleInputaddInput (std::string name, SignalValue defaultValue)
 Add a new input to the module type. More...
 
bool removeInput (ModuleInput *moduleInput)
 Removes an input from this module type. More...
 
unsigned int numOutputs () const
 
const ModuleOutputgetOutput (std::string name) const
 
ModuleOutputgetOutput (std::string name)
 
const ModuleOutputgetOutput (unsigned int index) const
 
ModuleOutputgetOutput (unsigned int index)
 
void eachModuleOutput (std::function< void(const ModuleOutput &)> f) const
 Iterate over the outputs using the provided callback.
 
void eachModuleOutput (std::function< void(ModuleOutput &)> f)
 Iterate over the outputs using the provided callback.
 
ModuleOutputaddOutput (std::string name, SignalType signalType)
 Add a new output to the module type. More...
 
bool removeOutput (ModuleOutput *moduleOutput)
 Removes an output from this module type. More...
 
GraphgetGraph ()
 Accessor for the graph of a composite module type. More...
 
const GraphgetGraph () const
 Accessor for the graph of a composite module type. More...
 
ModulegetInputModule ()
 Accessor for the input module of a composite module type.
 
const ModulegetInputModule () const
 Accessor for the input module of a composite module type. More...
 
ModulegetOutputModule ()
 Accessor for the output module of a composite module type.
 
const ModulegetOutputModule () const
 Accessor for the output module of a composite module type. More...
 
ModuleOutputexportInternalOutput (OutputLink &outputLink, std::string externalName)
 Convenience method for exposing a part of the module graph as a new external output. More...
 
- Public Member Functions inherited from nm::UserDataProvider
void * getUserData () const
 
void setUserData (void *userData)
 

Public Attributes

signal< void(ModuleType
&, const std::string &)> 
nameChanged
 This signal is emitted when the name of the moduleType changes.
 
signal< void(ModuleType
&, const std::string &)> 
descriptionChanged
 This signal is emitted when the description of the moduleType changes.
 
signal< void(ModuleInput &)> inputAdded
 This signal is emitted after an input has been added.
 
signal< void(ModuleInput &)> removingInput
 This signal is emitted before an input is removed.
 
signal< void(ModuleType &)> inputRemoved
 This signal is emitted after an input has been removed.
 
signal< void(ModuleOutput &)> outputAdded
 This signal is emitted after an output has been added.
 
signal< void(ModuleOutput &)> removingOutput
 This signal is emitted before an output is removed.
 
signal< void(ModuleType &)> outputRemoved
 This signal is emitted after an output has been removed.
 
signal< void(ModuleType &)> destroying
 This signal is emitted before the type is destroyed.
 

Detailed Description

Describes a recipe for a module and its inputs and outputs.

A module type may be thought of as a blueprint for a module. When a module is created, it is created according to a module type definition.

There are two main categories of module types, primitive and composite Composite module types, are built implemented as a graph of modules of other module types. Primitive module types are the lowest level building blocks of composite module types. They are defined by the library itself.

Member Enumeration Documentation

Module type category.

Enumerator
Primitive 

A low-level module type, without a graph

Composite 

A high-level module type, created as a composition of modules in a graph

GraphInput 

A special module type for inputs of a graph

GraphOutput 

A special module type for outputs of a graph

Constructor & Destructor Documentation

nm::ModuleType::ModuleType ( std::string  name,
std::string  description 
)
explicit

Simple Constructor for composite module types.

Parameters
nameA unique identifier for the module type
descriptionA comment or description of what kind of function the module type represents.
nm::ModuleType::ModuleType ( std::string  name,
ModuleType::Category  category = Category::Composite,
std::string  description = "" 
)
explicit
Parameters
nameA unique identifier for the module type
categoryWhether to create a composite, primitive, or special module type
descriptionA comment or description of what kind of function the module type represents.

Member Function Documentation

ModuleInput * nm::ModuleType::addInput ( std::string  name,
SignalType  signalType 
)

Add a new input to the module type.

Parameters
nameThe name to give the new input
signalTypeThe type of the new input

The default value for this input is set to zero

ModuleInput * nm::ModuleType::addInput ( std::string  name,
SignalValue  defaultValue 
)

Add a new input to the module type.

Parameters
nameThe name to give the new input
defaultValueThe default value for the new input

The type of the new input is inferred from the value

ModuleOutput * nm::ModuleType::addOutput ( std::string  name,
SignalType  signalType 
)

Add a new output to the module type.

Parameters
nameThe name to give the new output
signalTypeThe type of the new output

The default value for this output is set to zero

ModuleOutput * nm::ModuleType::exportInternalOutput ( OutputLink outputLink,
std::string  externalName 
)

Convenience method for exposing a part of the module graph as a new external output.

This method only works for composite module types.

Graph* nm::ModuleType::getGraph ( )
inline

Accessor for the graph of a composite module type.

Returns
Returns a pointer to the Graph corresponding to this module type, or nullptr if this is not a composite module type
const Graph* nm::ModuleType::getGraph ( ) const
inline

Accessor for the graph of a composite module type.

Returns
Returns a pointer to the Graph corresponding to this module type, or nullptr if this is not a composite module type
const Module * nm::ModuleType::getInputModule ( ) const

Accessor for the input module of a composite module type.

const Module * nm::ModuleType::getOutputModule ( ) const

Accessor for the output module of a composite module type.

bool nm::ModuleType::isRemovable ( ) const
inline

Some modules, like the ones representing inputs and outputs, may not be removed from their graphs.

Returns
Whether modules of this type may be removed from their graphs
bool nm::ModuleType::removeInput ( ModuleInput moduleInput)

Removes an input from this module type.

Parameters
moduleInputA pointer to one of this ModuleType's inputs
Returns
true if an input was removed

Instantiated Modules of this type are notified of this, and their corresponding InputLinks are automatically removed.

bool nm::ModuleType::removeOutput ( ModuleOutput moduleOutput)

Removes an output from this module type.

Parameters
moduleOutputA pointer to one of this ModuleType's outputs
Returns
true if an output was removed

Instantiated Modules of this type are notified of this, and their corresponding OutputLinks are automatically removed.


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