coutvector.h

00001 //==========================================================================
00002 //  COUTVECTOR.H - part of
00003 //                     OMNeT++/OMNEST
00004 //            Discrete System Simulation in C++
00005 //
00006 //
00007 //  Declaration of the following classes:
00008 //    cOutVector : represents an output vector
00009 //
00010 //==========================================================================
00011 
00012 /*--------------------------------------------------------------*
00013   Copyright (C) 1992-2008 Andras Varga
00014   Copyright (C) 2006-2008 OpenSim Ltd.
00015 
00016   This file is distributed WITHOUT ANY WARRANTY. See the file
00017   `license' for details on this and other legal matters.
00018 *--------------------------------------------------------------*/
00019 
00020 #ifndef __COUTVECTOR_H
00021 #define __COUTVECTOR_H
00022 
00023 #include <stdio.h>
00024 #include "cownedobject.h"
00025 #include "simtime_t.h"
00026 
00027 NAMESPACE_BEGIN
00028 
00029 
00035 typedef void (*RecordFunc)(void *, simtime_t, double, double);
00036 
00037 class cEnum;
00038 
00039 
00047 class SIM_API cOutVector : public cNoncopyableOwnedObject
00048 {
00049   protected:
00050     enum {
00051       FL_ENABLED = 4,      // flag: when false, record() method will do nothing
00052       FL_RECORDWARMUP = 8, // flag: when set, object records data during warmup period as well
00053     };
00054 
00055     void *handle;        // identifies output vector for the output vector manager
00056     simtime_t last_t;    // last timestamp written, needed to ensure increasing timestamp order
00057     long num_received;   // total number of values passed to the output vector object
00058     long num_stored;     // number of values actually stored
00059 
00060     // the following members will be used directly by inspectors
00061     RecordFunc record_in_inspector; // to notify inspector about file writes
00062     void *data_for_inspector;
00063 
00064   public:
00065     // internal: called from behind cEnvir
00066     void setCallback(RecordFunc f, void *d) {record_in_inspector=f; data_for_inspector=d;}
00067 
00068   public:
00069     enum Type { TYPE_INT, TYPE_DOUBLE, TYPE_ENUM };
00070     enum InterpolationMode { NONE, SAMPLE_HOLD, BACKWARD_SAMPLE_HOLD, LINEAR };
00071 
00072   public:
00078     explicit cOutVector(const char *name=NULL);
00079 
00083     virtual ~cOutVector();
00085 
00088 
00093     virtual void setName(const char *name);
00094 
00099     virtual std::string info() const;
00100 
00105     virtual void parsimPack(cCommBuffer *buffer);
00106 
00111     virtual void parsimUnpack(cCommBuffer *buffer);
00113 
00123     virtual void setEnum(const char *registeredEnumName);
00124 
00132     virtual void setEnum(cEnum *enumDecl);
00133 
00139     virtual void setUnit(const char *unit);
00140 
00147     virtual void setType(Type type);
00148 
00154     virtual void setInterpolationMode(InterpolationMode mode);
00155 
00162     virtual void setMin(double minValue);
00163 
00170     virtual void setMax(double maxValue);
00172 
00181     virtual bool record(double value);
00182 
00186     virtual bool record(SimTime value)  {return record(value.dbl());}
00187 
00197     virtual bool recordWithTimestamp(simtime_t t, double value);
00198 
00202     virtual bool recordWithTimestamp(simtime_t t, SimTime value) {return recordWithTimestamp(t, value.dbl());}
00203 
00207     virtual void enable()  {setFlag(FL_ENABLED,true);}
00208 
00213     virtual void disable()  {setFlag(FL_ENABLED,false);}
00214 
00219     virtual void setEnabled(bool b)  {setFlag(FL_ENABLED,b);}
00220 
00224     virtual bool isEnabled() const  {return flags&FL_ENABLED;}
00225 
00233     virtual void setRecordDuringWarmupPeriod(bool b)  {setFlag(FL_RECORDWARMUP,b);}
00234 
00239     virtual bool getRecordDuringWarmupPeriod() const  {return flags&FL_RECORDWARMUP;}
00240 
00246     long getValuesReceived() const  {return num_received;}
00247 
00253     long getValuesStored() const  {return num_stored;}
00255 };
00256 
00257 NAMESPACE_END
00258 
00259 
00260 #endif
00261 
00262 
Generated on Tue Dec 2 11:16:27 2014 for OMNeT++ Simulation Library by  doxygen 1.6.3