Statistics
| Branch: | Revision:

root / src / scave / commonnodes.h @ e1750c09

History | View | Annotate | Download (3.07 KB)

1 01873262 Georg Kunz
//=========================================================================
2
//  COMMONNODES.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 _COMMONNODES_H_
19
#define _COMMONNODES_H_
20
21
#include <string>
22
#include "node.h"
23
#include "nodetype.h"
24
#include "filereader.h"
25
26
NAMESPACE_BEGIN
27
28
#ifdef _MSC_VER
29
#pragma warning(disable:4355) // 'this' : used in base member initializer list
30
#endif
31
32
33
/**
34
 * Base class for one-port producer nodes.
35
 */
36
class SCAVE_API SingleSourceNode : public Node
37
{
38
    public:
39
        Port out;
40
    public:
41
        SingleSourceNode() : out(this) {}
42
};
43
44
45
/**
46
 * Base class for one-port consumer nodes.
47
 */
48
class SCAVE_API SingleSinkNode : public Node
49
{
50
    public:
51
        Port in;
52
    public:
53
        SingleSinkNode() : in(this) {}
54
};
55
56
57
/**
58
 * Base class for processing nodes with one input and one output port.
59
 */
60
class SCAVE_API FilterNode : public Node
61
{
62
    protected:
63
        virtual bool isFinished() const;
64
    public:
65
        Port in;
66
        Port out;
67
    public:
68
        FilterNode() : in(this), out(this) {}
69
};
70
71
/**
72
 * Base class for reading input from file.
73
 */
74
class SCAVE_API ReaderNode : public Node
75
{
76
    protected:
77
        std::string filename;
78
        FileReader reader;
79
    public:
80
        ReaderNode(const char* filename, size_t bufferSize)
81
            : filename(filename), reader(filename, bufferSize) {}
82
        int64 getFileSize() { return reader.getFileSize(); }
83
        int64 getNumReadBytes() { return reader.getNumReadBytes(); }
84
};
85
86
/**
87
 * NodeType for SingleSourceNode.
88
 */
89
class SCAVE_API SingleSourceNodeType : public NodeType
90
{
91
    public:
92
        virtual const char *getCategory() const {return "single sources";}
93
        virtual bool isHidden() const {return true;}
94
        virtual Port *getPort(Node *node, const char *portname) const;
95
};
96
97
98
/**
99
 * NodeType for SingleSinkNode.
100
 */
101
class SCAVE_API SingleSinkNodeType : public NodeType
102
{
103
    public:
104
        virtual const char *getCategory() const {return "single sinks";}
105
        virtual bool isHidden() const {return true;}
106
        virtual Port *getPort(Node *node, const char *portname) const;
107
};
108
109
110
/**
111
 * NodeType for FilterNode.
112
 */
113
class SCAVE_API FilterNodeType : public NodeType
114
{
115
    public:
116
        virtual const char *getCategory() const {return "filter";}
117
        virtual bool isHidden() const {return false;}
118
        virtual Port *getPort(Node *node, const char *portname) const;
119
};
120
121
/**
122
 * NodeType for ReaderNode.
123
 */
124
class SCAVE_API ReaderNodeType : public NodeType
125
{
126
    public:
127
        virtual const char *getCategory() const {return "reader-node";}
128
        virtual bool isHidden() const {return true;}
129
};
130
131
NAMESPACE_END
132
133
134
#endif
135