Switchboard Extension SDK
Loading...
Searching...
No Matches
NodeFactory.hpp
1//
2// NodeFactory.hpp
3// SwitchboardSDK
4//
5// Created by Balazs Kiss on 2023. 07. 05..
6//
7
8#pragma once
9
10#include <switchboard/export.h>
11#include <switchboard_core/NodeTypeInfo.hpp>
12#include <switchboard_core/Node.hpp>
13
14#include <any>
15#include <vector>
16#include <map>
17#include <string>
18#include <memory>
19
20namespace switchboard {
21
26class SWITCHBOARDSDK_EXPORT NodeFactory {
27public:
28
33
37 virtual ~NodeFactory();
38
45 virtual std::string getNodeTypePrefix() = 0;
46
53 virtual std::vector<NodeTypeInfo> getNodeTypes();
54
64 virtual Node* createNode(const std::string& type, const SBAnyMap& config);
65
66
67 using NodeCreator = std::function<Node*(const SBAnyMap&)>;
68
76 void registerNode(const NodeTypeInfo& type, NodeCreator creator);
77
78private:
79 class Impl;
80 std::unique_ptr<Impl> pImpl;
81};
82
83}
virtual std::vector< NodeTypeInfo > getNodeTypes()
Returns the list of node types that can be created by this factory.
virtual ~NodeFactory()
NodeFactory destructor.
virtual Node * createNode(const std::string &type, const SBAnyMap &config)
Creates an Node instance based on type information.
NodeFactory()
NodeFactory constructor.
virtual std::string getNodeTypePrefix()=0
Returns the prefix of the node type.
void registerNode(const NodeTypeInfo &type, NodeCreator creator)
Registers a node type with the factory.
Definition Node.hpp:15
Definition NodeTypeInfo.hpp:24