Statistics
| Branch: | Revision:

root / include / envirext.h @ 47c4b975

History | View | Annotate | Download (7.88 KB)

1
//==========================================================================
2
//  ENVIREXT.H - part of
3
//                     OMNeT++/OMNEST
4
//            Discrete System Simulation in C++
5
//
6
//
7
//  Declaration of the following classes:
8
//    cOutputVectorManager  : actually records for cOutVector objects
9
//
10
//==========================================================================
11

    
12
/*--------------------------------------------------------------*
13
  Copyright (C) 1992-2008 Andras Varga
14
  Copyright (C) 2006-2008 OpenSim Ltd.
15

16
  This file is distributed WITHOUT ANY WARRANTY. See the file
17
  `license' for details on this and other legal matters.
18
*--------------------------------------------------------------*/
19

    
20
#ifndef __ENVIREXT_H
21
#define __ENVIREXT_H
22

    
23
#include <iostream>
24
#include "simkerneldefs.h"
25
#include "cobject.h"
26

    
27
NAMESPACE_BEGIN
28

    
29

    
30
class cModule;
31
class cStatistic;
32

    
33
/**
34
 * Abstract base class for output vector managers for cEnvir.
35
 * cOutputVectorManagers are plugins into the Envir user
36
 * interface library (src/envir) that handle recording the output for
37
 * cOutVectors.
38
 *
39
 * The default output vector manager is cFileOutputVectorManager, defined in the
40
 * Envir library.
41
 *
42
 * To change the way output vectors are written, subclass cOutputVectorManager,
43
 * register your new class with the Register_Class() macro, then select it
44
 * by adding the following to <tt>omnetpp.ini</tt>:
45
 *
46
 * <pre>
47
 * [General]
48
 * outputvectormanager-class="MyClass"
49
 * </pre>
50
 *
51
 * @ingroup EnvirExtensions
52
 */
53
class SIM_API cOutputVectorManager : public cObject
54
{
55
  private:
56
    // copy constructor and assignment unsupported, make them inaccessible and also leave unimplemented
57
    cOutputVectorManager(const cOutputVectorManager&);
58
    cOutputVectorManager& operator=(const cOutputVectorManager&);
59

    
60
  public:
61
    /** @name Constructor, destructor */
62
    //@{
63

    
64
    /**
65
     * Constructor.
66
     */
67
    explicit cOutputVectorManager() {}
68

    
69
    /**
70
     * Destructor.
71
     */
72
    virtual ~cOutputVectorManager() {}
73
    //@}
74

    
75
    /** @name Controlling the beginning and end of collecting data. */
76
    //@{
77

    
78
    /**
79
     * Opens collecting. Called at the beginning of a simulation run.
80
     */
81
    virtual void startRun() = 0;
82

    
83
    /**
84
     * Closes collecting. Called at the end of a simulation run.
85
     */
86
    virtual void endRun() = 0;
87
    //@}
88

    
89
    /** @name Output vectors. */
90
    //@{
91

    
92
    /**
93
     * This method is called internally by the Envir library when a cOutVector object registers itself.
94
     * The return value is a handle of type void*; this handle is passed to
95
     * record() to identify the vector.
96
     */
97
    virtual void *registerVector(const char *modulename, const char *vectorname) = 0;
98

    
99
    /**
100
     * This method is called internally by the Envir library when a cOutVector object deregisters itself.
101
     */
102
    virtual void deregisterVector(void *vechandle) = 0;
103

    
104
    /**
105
     * This method is called internally by the Envir library when an attribute of the
106
     * cOutVector object is set.
107
     */
108
    virtual void setVectorAttribute(void *vechandle, const char *name, const char *value) = 0;
109

    
110
    /**
111
     * This method is called internally by the Envir library when a cOutVector object
112
     * writes a value into the output vector. The return value should be true if the
113
     * data was actually recorded, and false if it was not recorded (because of filtering, etc.)
114
     */
115
    virtual bool record(void *vechandle, simtime_t t, double value) = 0;
116

    
117
    /**
118
     * Returns the output vector file name. Returns NULL if this object is not
119
     * producing file output.
120
     */
121
    virtual const char *getFileName() const = 0;
122

    
123
    /**
124
     * Force writing out all buffered output.
125
     */
126
    virtual void flush() = 0;
127
    //@}
128
};
129

    
130

    
131
/**
132
 * Abstract base class for handling recording of output scalar data.
133
 * cOutputScalarManagers are plugins into the Envir user interface
134
 * library (src/envir) that ultimately handle calls to the
135
 * cComponent::recordScalar() family of functions.
136
 *
137
 * The default output scalar manager is cFileOutputScalarManager, defined
138
 * in the Envir library.
139
 *
140
 * To change the way scalar results are recorded, subclass cOutputScalarManager,
141
 * register your new class with the Register_Class() macro, then select it
142
 * by adding the following to <tt>omnetpp.ini</tt>:
143
 *
144
 * <pre>
145
 * [General]
146
 * outputscalarmanager-class="MyClass"
147
 * </pre>
148
 *
149
 * @ingroup EnvirExtensions
150
 */
151
class SIM_API cOutputScalarManager : public cObject
152
{
153
  private:
154
    // copy constructor and assignment unsupported, make them inaccessible and also leave unimplemented
155
    cOutputScalarManager(const cOutputScalarManager&);
156
    cOutputScalarManager& operator=(const cOutputScalarManager&);
157

    
158
  public:
159
    /** @name Constructor, destructor */
160
    //@{
161

    
162
    /**
163
     * Constructor.
164
     */
165
    explicit cOutputScalarManager() {}
166

    
167
    /**
168
     * Destructor.
169
     */
170
    virtual ~cOutputScalarManager() {}
171
    //@}
172

    
173
    /** @name Controlling the beginning and end of collecting data. */
174
    //@{
175

    
176
    /**
177
     * Opens collecting. Called at the beginning of a simulation run.
178
     */
179
    virtual void startRun() = 0;
180

    
181
    /**
182
     * Closes collecting. Called at the end of a simulation run.
183
     */
184
    virtual void endRun() = 0;
185
    //@}
186

    
187
    /** @name Scalar statistics. */
188
    //@{
189

    
190
    /**
191
     * Records a double scalar result, in a default configuration into the scalar result file.
192
     */
193
    virtual void recordScalar(cComponent *component, const char *name, double value, opp_string_map *attributes=NULL) = 0;
194

    
195
    /**
196
     * Records a histogram or statistic object into the scalar result file.
197
     * This operation may invoke the transform() method on the histogram object.
198
     */
199
    virtual void recordStatistic(cComponent *component, const char *name, cStatistic *statistic, opp_string_map *attributes=NULL) = 0;
200

    
201
    /**
202
     * Returns the output scalar file name. Returns NULL if this object is not
203
     * producing file output.
204
     */
205
    virtual const char *getFileName() const = 0;
206

    
207
    /**
208
     * Force writing out all buffered output.
209
     */
210
    virtual void flush() = 0;
211
    //@}
212
};
213

    
214

    
215
/**
216
 * Abstract base class for snapshot managers. cSnapshotManagers are plugins
217
 * into the Envir user interface library (src/envir) that provide an output
218
 * stream into which snapshots are written (see cSimulation::snapshot()).
219
 *
220
 * The default output snapshot manager is cFileSnapshotManager, defined in the
221
 * Envir library.
222
 *
223
 * To create your own snaphot manager class, subclass cSnapshotManager,
224
 * register your new class with the Register_Class() macro, then select it
225
 * by adding the following to <tt>omnetpp.ini</tt>:
226
 *
227
 * <pre>
228
 * [General]
229
 * snapshotmanager-class="MyClass"
230
 * </pre>
231
 *
232
 * @ingroup EnvirExtensions
233
 */
234
class SIM_API cSnapshotManager : public cObject
235
{
236
  private:
237
    // copy constructor and assignment unsupported, make them inaccessible and also leave unimplemented
238
    cSnapshotManager(const cSnapshotManager&);
239
    cSnapshotManager& operator=(const cSnapshotManager&);
240

    
241
  public:
242
    /** @name Constructor, destructor */
243
    //@{
244

    
245
    /**
246
     * Constructor.
247
     */
248
    explicit cSnapshotManager() {}
249

    
250
    /**
251
     * Destructor.
252
     */
253
    virtual ~cSnapshotManager() {}
254
    //@}
255

    
256
    /** @name Controlling the beginning and end of collecting data. */
257
    //@{
258

    
259
    /**
260
     * Called at the beginning of a simulation run.
261
     */
262
    virtual void startRun() = 0;
263

    
264
    /**
265
     * Called at the end of a simulation run.
266
     */
267
    virtual void endRun() = 0;
268
    //@}
269

    
270
    /** @name Snapshot management */
271
    //@{
272
    /**
273
     * Returns a stream where a snapshot can be written.
274
     */
275
    virtual std::ostream *getStreamForSnapshot() = 0;
276

    
277
    /**
278
     * Releases a stream after a snapshot was written.
279
     */
280
    virtual void releaseStreamForSnapshot(std::ostream *os) = 0;
281

    
282
    /**
283
     * Returns the snapshot file name. Returns NULL if this object is not
284
     * producing file output.
285
     */
286
    virtual const char *getFileName() const = 0;
287
    //@}
288
};
289

    
290
NAMESPACE_END
291

    
292

    
293
#endif
294

    
295