Project

General

Profile

Statistics
| Branch: | Revision:

root / src / scave / nodetyperegistry.h @ 81ad8b66

History | View | Annotate | Download (2.12 KB)

1 01873262 Georg Kunz
//=========================================================================
2
//  NODETYPEREGISTRY.H - part of
3
//                  OMNeT++/OMNEST
4
//           Discrete System Simulation in C++
5
//
6
//  Author: Andras Varga
7
//
8
//=========================================================================
9
10
/*--------------------------------------------------------------*
11
  Copyright (C) 1992-2008 Andras Varga
12
  Copyright (C) 2006-2008 OpenSim Ltd.
13

14
  This file is distributed WITHOUT ANY WARRANTY. See the file
15
  `license' for details on this and other legal matters.
16
*--------------------------------------------------------------*/
17
18
#ifndef _NODETYPEREGISTRY_H_
19
#define _NODETYPEREGISTRY_H_
20
21
#include <map>
22
#include <vector>
23
#include <string>
24
#include "node.h"
25
#include "nodetype.h"
26
27
NAMESPACE_BEGIN
28
29
class DataflowManager;
30
31
typedef std::vector<NodeType*> NodeTypeVector;
32
33
34
/**
35
 * Factory for all available node types.
36
 *
37
 * @see NodeType, Node
38
 */
39
class SCAVE_API NodeTypeRegistry
40
{
41
    protected:
42
        static NodeTypeRegistry *inst;
43
        typedef std::map<std::string,NodeType*> NodeTypeMap;
44
        NodeTypeMap nodeTypeMap;
45
46
        NodeTypeRegistry();
47
        ~NodeTypeRegistry();
48
49
    public:
50
        /** Access to singleton instance */
51
        static NodeTypeRegistry *getInstance();
52
53
        /** Returns list of node types */
54
        NodeTypeVector getNodeTypes();
55
56
        /** True if a node type with the given name exists */
57
        bool exists(const char *name);
58
59
        /** Returns a node type by name */
60
        NodeType *getNodeType(const char *name);
61
62
        /** Parse filter spec, and create the corresponding node */
63
        Node *createNode(const char *filterSpec, DataflowManager *mgr);
64
65
        /**
66
         * Parse the given string in form "name(arg1,arg2,...)" into a
67
         * filter name and filter args list.
68
         */
69
        static void parseFilterSpec(const char *filterSpec, std::string& name, std::vector<std::string>& args);
70
71
        /** Add a node type to the factory */
72
        void add(NodeType *nodetype);
73
74
        /** Remove a node type from the factory */
75
        void remove(NodeType *nodetype);
76
77
};
78
79
NAMESPACE_END
80
81
82
#endif