diff options
Diffstat (limited to 'NodeFactory.h')
-rw-r--r-- | NodeFactory.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/NodeFactory.h b/NodeFactory.h new file mode 100644 index 0000000..3c8c4f4 --- /dev/null +++ b/NodeFactory.h @@ -0,0 +1,31 @@ +#pragma once + +#include <string> +#include <map> + +#include "Node.h" + +using std::string; + +using NodeFactoryMap = std::map<string, const Node *>; + +class NodeFactory { +public: + NodeFactory() = default; + virtual ~NodeFactory() = default; + +public: + static bool has_type(const char * type); + static bool has_type(string type); + static Node * create(string type); + +private: + static void assign(const char * type, const Node * node); + static NodeFactoryMap & get_map(); + static string normalize_type(string type); + static const Node * find_type(string type); + +private: + friend Node; +}; + |