Atoms Crowd  7.0.0
NodeFactory.h
1 #pragma once
2 // ===========================================================================
3 // Copyright (c) 2015 Toolchefs Ltd. All rights reserved.
4 //
5 // Use of this software is subject to the terms of the Toolchefs license
6 // agreement provided at the time of installation or download, or which
7 // otherwise accompanies this software in either electronic or hard copy form.
8 // ===========================================================================
9 
10 #include <AtomsGraph/Globals.h>
11 #include <AtomsGraph/Node.h>
12 #include <string>
13 #include <map>
14 #include <vector>
15 
16 namespace AtomsGraph
17 {
19 
23  class ATOMSGRAPH_EXPORT NodeFactory
24  {
25  public:
26 
27  typedef Node* (*creatorFn)();
28 
30  static NodeFactory& instance();
31 
33 
36  template<class T>
37  T* createNode(const std::string& typeName);
38 
40 
43  Node* createNode(const std::string& typeName);
44 
46 
50  void registerNode(const std::string& name, creatorFn funct);
51 
53 
56  void deregisterNode(const std::string& name);
57 
59  std::vector<std::string> getRegisteredNodes();
60 
62  bool isRegistered(const std::string& name);
63 
64  private:
65 
67  NodeFactory();
68 
70  ~NodeFactory();
71 
73  NodeFactory(const NodeFactory&);
74 
76  NodeFactory& operator=(const NodeFactory&);
77 
78  typedef std::map<std::string, creatorFn> FactoryMap;
79 
81  FactoryMap m_factoryMap;
82  };
83 }
84 
85 #include "NodeFactory.impl.h"
Node factory.
Definition: NodeFactory.h:24
static NodeFactory & instance()
Singleton access.
bool isRegistered(const std::string &name)
Checks if a node type is registered.
Node * createNode(const std::string &typeName)
Creates a new node.
std::vector< std::string > getRegisteredNodes()
Gets a list of all the node type registered.
void registerNode(const std::string &name, creatorFn funct)
Registers a node type.
void deregisterNode(const std::string &name)
Deregisters a node type.
Definition: Node.h:31
AtomsGraph namespace.
Definition: PosePort.h:15