Project

General

Profile

Statistics
| Branch: | Revision:

root / src / scave / nodetype.h @ a3be1d55

History | View | Annotate | Download (3.03 KB)

1 01873262 Georg Kunz
//=========================================================================
2
//  NODETYPE.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 _NODETYPE_H_
19
#define _NODETYPE_H_
20
21
#include <map>
22
#include <string>
23
#include <vector>
24
#include "dataflowmanager.h"
25
26
NAMESPACE_BEGIN
27
28
class Node;
29
class Port;
30
31
typedef std::map<std::string,std::string> StringMap;
32
typedef std::vector<std::string> StringVector;
33
34
35
/**
36
 * Describes properties of a node class.
37
 *
38
 * @see Node, NodeTypeRegistry
39
 */
40
class SCAVE_API NodeType
41
{
42
    protected:
43
        void checkAttrNames(const StringMap& attr) const;
44
45
    public:
46
        NodeType() {}
47
        virtual ~NodeType() {}
48
49
        /**
50
         * Returns type name as displayed on the UI (e.g. "mean" or "winavg")
51
         */
52
        virtual const char *getName() const = 0;
53
54
        /**
55
         * Returns the category of the getNode(source, sink, filter, etc.)
56
         */
57
        virtual const char *getCategory() const = 0;
58
59
        /**
60
         * Returns the description of the getNode(this can be displayed on the UI.)
61
         */
62
        virtual const char *getDescription() const = 0;
63
64
        /**
65
         * Returns true if this node should not appear in the UI.
66
         */
67
        virtual bool isHidden() const = 0;
68
69
        /**
70
         * Fills the string map with the names of all accepted attributes
71
         * and their descriptions.
72
         */
73
        virtual void getAttributes(StringMap& attrs) const = 0;
74
75
        /**
76
         * Fills the string map with attribute names and their default values.
77
         * (Does not necessarily supply default value for every attribute).
78
         */
79
        virtual void getAttrDefaults(StringMap& attrs) const {}
80
81
        /**
82
         * Throws exception if something is not OK. The message in the
83
         * exception is shown to the user.
84
         */
85
        virtual void validateAttrValues(const StringMap& attrs) const {}
86
87
        /**
88
         * Create a node instance of this type. Also adds the node to the
89
         * data-flow network, so you do not need to call mgr->addNode() afterwards.
90
         */
91
        virtual Node *create(DataflowManager *mgr, StringMap& attrs) const = 0;
92
93
        /**
94
         * Get the named port of the give node instance.
95
         */
96
        virtual Port *getPort(Node *node, const char *portname) const = 0;
97
98
        /**
99
         * Maps input vector attributes to output vector attributes.
100
         * This method is called for filter nodes only.
101
         */
102
        virtual void mapVectorAttributes(/*inout*/StringMap &attrs, /*out*/StringVector &warnings) const;
103
};
104
105
106
NAMESPACE_END
107
108
109
#endif