cnullenvir.h

00001 //==========================================================================
00002 //  CNULLENVIR.H - part of
00003 //
00004 //                     OMNeT++/OMNEST
00005 //            Discrete System Simulation in C++
00006 //
00007 //
00008 //  Declaration of the following classes:
00009 //    cNullEnvir : a cEnvir implementation with empty member functions
00010 //
00011 //==========================================================================
00012 
00013 /*--------------------------------------------------------------*
00014   Copyright (C) 1992-2008 Andras Varga
00015   Copyright (C) 2006-2008 OpenSim Ltd.
00016 
00017   This file is distributed WITHOUT ANY WARRANTY. See the file
00018   `license' for details on this and other legal matters.
00019 *--------------------------------------------------------------*/
00020 
00021 #ifndef __CNULLENVIR_H
00022 #define __CNULLENVIR_H
00023 
00024 #include "cenvir.h"
00025 #include "cexception.h"
00026 #include "ccomponent.h"
00027 #include "cmersennetwister.h"
00028 
00029 NAMESPACE_BEGIN
00030 
00031 
00056 class SIM_API cNullEnvir : public cEnvir
00057 {
00058   protected:
00059     int argc;
00060     char **argv;
00061     cConfiguration *cfg;
00062     cRNG *rng;
00063     unsigned long lastnum;
00064 
00065   protected:
00066     void unsupported() const {throw cRuntimeError("cNullEnvir: unsupported method called");}
00067 
00068     virtual void sputn(const char *s, int n) {}
00069     virtual void putsmsg(const char *msg) {::printf("\n<!> %s\n\n", msg);}
00070     virtual bool askyesno(const char *msg)  {unsupported(); return false;}
00071 
00072   public:
00073     // constructor, destructor
00074     cNullEnvir(int ac, char **av, cConfiguration *c) {argc=ac; argv=av; cfg=c; rng=new cMersenneTwister(); lastnum=0;}
00075     virtual ~cNullEnvir() {delete cfg; delete rng;}
00076 
00077     // eventlog callback interface
00078     virtual void objectDeleted(cObject *object) {}
00079     virtual void simulationEvent(cMessage *msg)  {}
00080     virtual void messageSent_OBSOLETE(cMessage *msg, cGate *directToGate=NULL)  {}
00081     virtual void messageScheduled(cMessage *msg)  {}
00082     virtual void messageCancelled(cMessage *msg)  {}
00083     virtual void beginSend(cMessage *msg)  {}
00084     virtual void messageSendDirect(cMessage *msg, cGate *toGate, simtime_t propagationDelay, simtime_t transmissionDelay)  {}
00085     virtual void messageSendHop(cMessage *msg, cGate *srcGate)  {}
00086     virtual void messageSendHop(cMessage *msg, cGate *srcGate, simtime_t propagationDelay, simtime_t transmissionDelay)  {}
00087     virtual void endSend(cMessage *msg)  {}
00088     virtual void messageCreated(cMessage *msg)  {}
00089     virtual void messageCloned(cMessage *msg, cMessage *clone)  {}
00090     virtual void messageDeleted(cMessage *msg)  {}
00091     virtual void moduleReparented(cModule *module, cModule *oldparent)  {}
00092     virtual void componentMethodBegin(cComponent *from, cComponent *to, const char *methodFmt, va_list va, bool silent)  {}
00093     virtual void componentMethodEnd()  {}
00094     virtual void moduleCreated(cModule *newmodule)  {}
00095     virtual void moduleDeleted(cModule *module)  {}
00096     virtual void gateCreated(cGate *newgate)  {}
00097     virtual void gateDeleted(cGate *gate)  {}
00098     virtual void connectionCreated(cGate *srcgate)  {}
00099     virtual void connectionDeleted(cGate *srcgate)  {}
00100     virtual void displayStringChanged(cComponent *component)  {}
00101     virtual void undisposedObject(cObject *obj) {}
00102 
00103     // configuration, model parameters
00104     virtual void configure(cComponent *component) {}
00105     virtual void readParameter(cPar *par)  {unsupported();}
00106     virtual bool isModuleLocal(cModule *parentmod, const char *modname, int index)  {return true;}
00107     virtual cXMLElement *getXMLDocument(const char *filename, const char *xpath=NULL)  {unsupported(); return NULL;}
00108     virtual cXMLElement *getParsedXMLString(const char *content, const char *xpath=NULL)  {unsupported(); return NULL;}
00109     virtual void forgetXMLDocument(const char *filename) {}
00110     virtual void forgetParsedXMLString(const char *content) {}
00111     virtual void flushXMLDocumentCache() {}
00112     virtual void flushXMLParsedContentCache() {}
00113     virtual unsigned getExtraStackForEnvir() const  {return 0;}
00114     virtual cConfiguration *getConfig()  {return cfg;}
00115     virtual bool isGUI() const  {return false;}
00116 
00117     // UI functions (see also protected ones)
00118     virtual void bubble(cComponent *component, const char *text)  {}
00119     virtual std::string gets(const char *prompt, const char *defaultreply=NULL)  {unsupported(); return "";}
00120     virtual cEnvir& flush()  {::fflush(stdout); return *this;}
00121 
00122     // RNGs
00123     virtual int getNumRNGs() const {return 1;}
00124     virtual cRNG *getRNG(int k)  {return rng;}
00125     virtual void getRNGMappingFor(cComponent *component)  {component->setRNGMap(0,NULL);}
00126 
00127     // output vectors
00128     virtual void *registerOutputVector(const char *modulename, const char *vectorname)  {return (void *)1;}
00129     virtual void deregisterOutputVector(void *vechandle)  {}
00130     virtual void setVectorAttribute(void *vechandle, const char *name, const char *value)  {}
00131     virtual bool recordInOutputVector(void *vechandle, simtime_t t, double value)  {return false;}
00132 
00133     // output scalars
00134     virtual void recordScalar(cComponent *component, const char *name, double value, opp_string_map *attributes=NULL)  {}
00135     virtual void recordStatistic(cComponent *component, const char *name, cStatistic *statistic, opp_string_map *attributes=NULL)  {}
00136 
00137     virtual void addResultRecorders(cComponent *component, simsignal_t signal, const char *statisticName, cProperty *statisticTemplateProperty) {}
00138 
00139     // snapshot file
00140     virtual std::ostream *getStreamForSnapshot()  {unsupported(); return NULL;}
00141     virtual void releaseStreamForSnapshot(std::ostream *os)  {unsupported();}
00142 
00143     // misc
00144     virtual int getArgCount() const  {return argc;}
00145     virtual char **getArgVector() const  {return argv;}
00146     virtual int getParsimProcId() const {return 0;}
00147     virtual int getParsimNumPartitions() const {return 1;}
00148     virtual unsigned long getUniqueNumber()  {return ++lastnum;}
00149     virtual bool idle()  {return false;}
00150     virtual void attachDebugger() {}
00151 };
00152 
00153 
00154 NAMESPACE_END
00155 
00156 #endif
00157 
00158 
Generated on Tue Dec 2 11:16:27 2014 for OMNeT++ Simulation Library by  doxygen 1.6.3