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/Config.hpp>
11#include "NodeTypeInfo.hpp"
12#include "Node.hpp"
13
14#include <any>
15#include <vector>
16#include <map>
17#include <string>
18#include <memory>
19
20namespace switchboard {
21
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 std::map<std::string, std::any>& config);
65
66
67 using NodeCreator = std::function<Node*(const std::map<std::string, std::any>&)>;
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.
NodeFactory()
NodeFactory constructor.
virtual std::string getNodeTypePrefix()=0
Returns the prefix of the node type.
virtual Node * createNode(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.
Definition Node.hpp:14
Definition NodeTypeInfo.hpp:23