NeoGraph 0.10.0
A C++17 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
loader.h
Go to the documentation of this file.
1
12#pragma once
13
14#include <neograph/api.h>
16#include <unordered_map>
17#include <memory>
18#include <string>
19#include <vector>
20
21namespace neograph::graph {
22
23class GraphNode;
24
56class NEOGRAPH_API ReducerRegistry {
57public:
61
67 void register_reducer(const std::string& name, ReducerFn fn);
68
74 ReducerFn get(const std::string& name) const;
75
84 std::vector<std::string> names() const;
85
86private:
88 std::unordered_map<std::string, ReducerFn> registry_;
89};
90
104class NEOGRAPH_API ConditionRegistry {
105public:
109
115 void register_condition(const std::string& name, ConditionFn fn);
116
122 ConditionFn get(const std::string& name) const;
123
132 std::vector<std::string> names() const;
133
134private:
136 std::unordered_map<std::string, ConditionFn> registry_;
137};
138
146using NodeFactoryFn = std::function<std::unique_ptr<GraphNode>(
147 const std::string& name,
148 const json& config,
149 const NodeContext& ctx)>;
150
165class NEOGRAPH_API NodeFactory {
166public:
170
183 void register_type(const std::string& type, NodeFactoryFn fn);
184
196 void register_type(const std::string& type, NodeFactoryFn fn,
197 json config_schema);
198
207 std::unique_ptr<GraphNode> create(const std::string& type,
208 const std::string& name,
209 const json& config,
210 const NodeContext& ctx) const;
211
216 std::vector<std::string> registered_types() const;
217
246 json export_schema() const;
247
248private:
249 NodeFactory();
250 std::unordered_map<std::string, NodeFactoryFn> registry_;
251 std::unordered_map<std::string, json> schemas_;
252};
253
254} // namespace neograph::graph
NEOGRAPH_API export/import macro for shared-library builds.
Singleton registry for conditional edge routing functions.
Definition loader.h:104
ConditionFn get(const std::string &name) const
Look up a condition by name.
static ConditionRegistry & instance()
Get the singleton instance.
std::vector< std::string > names() const
List all registered condition names, sorted.
void register_condition(const std::string &name, ConditionFn fn)
Register a named condition function.
Singleton factory for creating graph nodes by type name.
Definition loader.h:165
void register_type(const std::string &type, NodeFactoryFn fn, json config_schema)
Register a custom node type with a declared config schema.
json export_schema() const
Export a machine-readable description of the topology JSON format this engine accepts.
void register_type(const std::string &type, NodeFactoryFn fn)
Register a custom node type.
std::unique_ptr< GraphNode > create(const std::string &type, const std::string &name, const json &config, const NodeContext &ctx) const
Create a node by type name.
std::vector< std::string > registered_types() const
List all registered node type names, sorted.
static NodeFactory & instance()
Get the singleton instance.
Singleton registry for channel reducer functions.
Definition loader.h:56
ReducerFn get(const std::string &name) const
Look up a reducer by name.
std::vector< std::string > names() const
List all registered reducer names, sorted.
void register_reducer(const std::string &name, ReducerFn fn)
Register a named reducer function.
static ReducerRegistry & instance()
Get the singleton instance.
Graph engine type definitions: channels, edges, nodes, events, and control flow.
std::function< json(const json &current, const json &incoming)> ReducerFn
Custom reducer function signature.
Definition types.h:65
std::function< std::string(const GraphState &)> ConditionFn
Condition function signature for conditional edge routing.
Definition types.h:314
std::function< std::unique_ptr< GraphNode >(const std::string &name, const json &config, const NodeContext &ctx)> NodeFactoryFn
Factory function signature for creating graph nodes.
Definition loader.h:149
Dependency injection context passed to nodes during construction.
Definition types.h:251