Switchboard Extension SDK
Loading...
Searching...
No Matches
switchboard::NodeFactory Class Referenceabstract

Creates node instances. More...

#include <NodeFactory.hpp>

Public Types

using NodeCreator = std::function<Node*(const std::map<std::string, std::any>&)>

Public Member Functions

 NodeFactory ()
 NodeFactory constructor.
virtual ~NodeFactory ()
 NodeFactory destructor.
virtual std::string getNodeTypePrefix ()=0
 Returns the prefix of the node type.
virtual std::vector< NodeTypeInfogetNodeTypes ()
 Returns the list of node types that can be created by this factory.
virtual NodecreateNode (const std::string &type, const std::map< std::string, std::any > &config)
 Creates an Node instance based on type information.
void registerNode (const NodeTypeInfo &type, NodeCreator creator)
 Registers a node type with the factory.

Detailed Description

Creates node instances.

NodeFactory class.

Member Function Documentation

◆ createNode()

virtual Node * switchboard::NodeFactory::createNode ( const std::string & type,
const std::map< std::string, std::any > & config )
virtual

Creates an Node instance based on type information.

The returned node instances need to be freed by the user of the NodeFactory.

Parameters
typeThe type of the node.
configConfiguration values for the node.
Returns
A pointer to the created Node instance, or nullptr if the node could not be created.

◆ getNodeTypePrefix()

virtual std::string switchboard::NodeFactory::getNodeTypePrefix ( )
pure virtual

Returns the prefix of the node type.

The prefix is used to identify the node type and it follows the format: <extension name>.<node type>.

Returns
The prefix of the node type.

◆ getNodeTypes()

virtual std::vector< NodeTypeInfo > switchboard::NodeFactory::getNodeTypes ( )
virtual

Returns the list of node types that can be created by this factory.

The node types are returned as a vector of strings, where each string is the type name of the node.

Returns
A vector of strings containing the node types.

◆ registerNode()

void switchboard::NodeFactory::registerNode ( const NodeTypeInfo & type,
NodeCreator creator )

Registers a node type with the factory.

This function allows the factory to create instances of the specified node type.

Parameters
typeThe type information of the node.
creatorA function that creates instances of the node.

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