#include <Dataflow/Core/NodeFactory.hpp>
Public Types | |
using | NodeCreatorFunctor = std::function<std::shared_ptr<Node>( const nlohmann::json& data )> |
using | ContainerType |
Public Member Functions | |
NodeFactory (std::string name) | |
auto | name () const -> std::string |
template<typename T > | |
auto | register_node_creator (NodeCreatorFunctor nodeCreator, const std::string &nodeCategory="RadiumNodes") -> bool |
template<typename T > | |
auto | register_node_creator (const std::string &instanceNamePrefix, const std::string &nodeCategory="RadiumNodes") -> bool |
auto | register_node_creator (const std::string &nodeType, NodeCreatorFunctor nodeCreator, const std::string &nodeCategory="RadiumNodes") -> bool |
auto | create_node (const std::string &nodeType, const nlohmann::json &data, DataflowGraph *owningGraph=nullptr) -> std::shared_ptr< Node > |
auto | factory_map () const -> const ContainerType & |
NodeFactory store a set of functions allowing to dynamically create dataflow nodes. A NodeFactory is used when loading a node graph from a json representation of the graph to instantiate all the loaded nodes.
Definition at line 26 of file NodeFactory.hpp.
The type of the associative container used to store the factory this container associate a concrete node type name to a pair <concrete instantiation functor, name of the node category> The name of the node category is helpful for graphical NodeGraph editor. By default this is set to be "RadiumNodes"
Definition at line 99 of file NodeFactory.hpp.
using Ra::Dataflow::Core::NodeFactory::NodeCreatorFunctor = std::function<std::shared_ptr<Node>( const nlohmann::json& data )> |
Function that creates and initialize a node. Typical implementation of such a function should do the following : { auto node = new ConcreteNodeType( unique_instance_name ); node->fromJson( data); return node; }
Definition at line 42 of file NodeFactory.hpp.
|
explicit |
Creates an empty factory with the given name
Definition at line 13 of file NodeFactory.cpp.
|
nodiscard |
Create a node of the requested type. The node is filled with the given json content. If owningGraph is non null, the node is added to this graph
nodeType | Type name of the node to be created. |
data | json representation of the node data (might be empty) |
owningGraph | if non null, the node is added to ths graph |
Definition at line 19 of file NodeFactory.cpp.
|
inlinenodiscard |
Get a const reference on the associative map
Definition at line 278 of file NodeFactory.hpp.
|
nodiscard |
Definition at line 15 of file NodeFactory.cpp.
auto Ra::Dataflow::Core::NodeFactory::register_node_creator | ( | const std::string & | instanceNamePrefix, |
const std::string & | nodeCategory = "RadiumNodes" ) -> bool |
Associate, for a given concrete node type, a generic NodeCreatorFunctor
T | Concrete node type identifier |
instanceNamePrefix | prefix of the node instance name (will be called "prefix_i" with i a unique number. |
nodeCategory | Category of the node. |
Definition at line 259 of file NodeFactory.hpp.
auto Ra::Dataflow::Core::NodeFactory::register_node_creator | ( | const std::string & | nodeType, |
NodeCreatorFunctor | nodeCreator, | ||
const std::string & | nodeCategory = "RadiumNodes" ) -> bool |
Associate, for a given concrete node type name, a NodeCreatorFunctor
nodeType | the name of the concrete type (the same as what is obtained by T::node_typename() on a node of type T) |
nodeCreator | Functor to create an node of the corresponding concrete node type. |
Definition at line 30 of file NodeFactory.cpp.
auto Ra::Dataflow::Core::NodeFactory::register_node_creator | ( | NodeCreatorFunctor | nodeCreator, |
const std::string & | nodeCategory = "RadiumNodes" ) -> bool |
Associate, for a given concrete node type, a custom NodeCreatorFunctor
T | Concrete node type identifier |
nodeCreator | Functor to create an node of the corresponding concrete node type. |
nodeCategory | Category of the node. |
Definition at line 253 of file NodeFactory.hpp.