OMNeT++ Simulation Library  5.6.1
coutvector.h
1 //==========================================================================
2 // COUTVECTOR.H - part of
3 // OMNeT++/OMNEST
4 // Discrete System Simulation in C++
5 //
6 //==========================================================================
7 
8 /*--------------------------------------------------------------*
9  Copyright (C) 1992-2017 Andras Varga
10  Copyright (C) 2006-2017 OpenSim Ltd.
11 
12  This file is distributed WITHOUT ANY WARRANTY. See the file
13  `license' for details on this and other legal matters.
14 *--------------------------------------------------------------*/
15 
16 #ifndef __OMNETPP_COUTVECTOR_H
17 #define __OMNETPP_COUTVECTOR_H
18 
19 #include <cstdio>
20 #include "cownedobject.h"
21 #include "simtime_t.h"
22 
23 namespace omnetpp {
24 
25 
31 typedef void (*RecordFunc)(void *, simtime_t, double);
32 
33 class cEnum;
34 
35 
44 class SIM_API cOutVector : public cNoncopyableOwnedObject
45 {
46  protected:
47  enum {
48  FL_ENABLED = 4, // flag: when false, record() method will do nothing
49  FL_RECORDWARMUP = 8, // flag: when set, object records data during warmup period as well
50  };
51 
52  void *handle; // identifies output vector for the output vector manager
53  simtime_t lastTimestamp; // last timestamp written, needed to ensure increasing timestamp order
54  long numReceived; // total number of values passed to the output vector object
55  long numStored; // number of values actually stored
56 
57  // the following members will be used directly by inspectors
58  RecordFunc recordInInspector; // to notify inspector about file writes
59  void *dataForInspector;
60 
61  public:
62  // internal: called from behind cEnvir
63  void setCallback(RecordFunc f, void *d) {recordInInspector=f; dataForInspector=d;}
64 
65  public:
66  enum Type { TYPE_INT, TYPE_DOUBLE, TYPE_ENUM };
67  enum InterpolationMode { NONE, SAMPLE_HOLD, BACKWARD_SAMPLE_HOLD, LINEAR };
68 
69  public:
75  explicit cOutVector(const char *name=nullptr);
76 
80  virtual ~cOutVector();
82 
85 
90  virtual void setName(const char *name) override;
91 
96  virtual std::string str() const override;
97 
102  virtual void parsimPack(cCommBuffer *buffer) const override;
103 
108  virtual void parsimUnpack(cCommBuffer *buffer) override;
110 
120  virtual void setEnum(const char *registeredEnumName);
121 
129  virtual void setEnum(cEnum *enumDecl);
130 
136  virtual void setUnit(const char *unit);
137 
144  virtual void setType(Type type);
145 
151  virtual void setInterpolationMode(InterpolationMode mode);
152 
159  virtual void setMin(double minValue);
160 
167  virtual void setMax(double maxValue);
169 
178  virtual bool record(double value);
179 
183  virtual bool record(SimTime value) {return record(value.dbl());}
184 
194  virtual bool recordWithTimestamp(simtime_t t, double value);
195 
199  virtual bool recordWithTimestamp(simtime_t t, SimTime value) {return recordWithTimestamp(t, value.dbl());}
200 
204  virtual void enable() {setFlag(FL_ENABLED,true);}
205 
210  virtual void disable() {setFlag(FL_ENABLED,false);}
211 
216  virtual void setEnabled(bool b) {setFlag(FL_ENABLED,b);}
217 
221  virtual bool isEnabled() const {return flags&FL_ENABLED;}
222 
230  virtual void setRecordDuringWarmupPeriod(bool b) {setFlag(FL_RECORDWARMUP,b);}
231 
236  virtual bool getRecordDuringWarmupPeriod() const {return flags&FL_RECORDWARMUP;}
237 
243  long getValuesReceived() const {return numReceived;}
244 
250  long getValuesStored() const {return numStored;}
252 };
253 
254 } // namespace omnetpp
255 
256 
257 #endif
258 
259 
virtual void setEnabled(bool b)
Definition: coutvector.h:216
Responsible for recording vector simulation results (an output vector).
Definition: coutvector.h:44
SimTime simtime_t
Represents simulation time.
Definition: simtime_t.h:36
int64_t-based, base-10 fixed-point simulation time.
Definition: simtime.h:66
virtual void disable()
Definition: coutvector.h:210
virtual bool getRecordDuringWarmupPeriod() const
Definition: coutvector.h:236
double dbl() const
Definition: simtime.h:301
virtual void enable()
Definition: coutvector.h:204
virtual void setRecordDuringWarmupPeriod(bool b)
Definition: coutvector.h:230
Buffer for the communications layer of parallel simulation.
Definition: ccommbuffer.h:41
virtual bool record(SimTime value)
Definition: coutvector.h:183
Provides string representation for enums.
Definition: cenum.h:32
Definition: cabstracthistogram.h:21
Base class for cOwnedObject-based classes that do not wish to support assignment and duplication...
Definition: cownedobject.h:248
virtual bool recordWithTimestamp(simtime_t t, SimTime value)
Definition: coutvector.h:199
virtual bool isEnabled() const
Definition: coutvector.h:221
long getValuesStored() const
Definition: coutvector.h:250
long getValuesReceived() const
Definition: coutvector.h:243
void(* RecordFunc)(void *, simtime_t, double)
Prototype for callback functions that are used to notify graphical user interfaces when values are re...
Definition: coutvector.h:31