Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members  

cwatch.h

00001 //==========================================================================
00002 //   CWATCH.H  - header for
00003 //                             OMNeT++
00004 //            Discrete System Simulation in C++
00005 //
00006 //
00007 //  Declaration of the following classes:
00008 //    cWatch    : shell for a char/int/long/double/char*/cObject* variable
00009 //
00010 //==========================================================================
00011 
00012 /*--------------------------------------------------------------*
00013   Copyright (C) 1992-2001 Andras Varga
00014   Technical University of Budapest, Dept. of Telecommunications,
00015   Stoczek u.2, H-1111 Budapest, Hungary.
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 __CWATCH_H
00022 #define __CWATCH_H
00023 
00024 #include "cobject.h"
00025 
00026 //=== classes declared here
00027 class  cWatch;
00028 
00034 
00061 #define WATCH(var)   new cWatch( #var, var );
00062 
00069 #define LWATCH(var)  cWatch var##__varshell( #var, var );
00070 
00071 
00072 //==========================================================================
00073 
00083 class SIM_API cWatch : public cObject
00084 {
00085   private:
00086     void *ptr;
00087     char type;
00088 
00089   public:
00092 
00096     cWatch(const cWatch& vs);
00097 
00101     cWatch(const char *name, char& c)  : cObject(name) {ptr=&c; type='c';}
00102 
00106     cWatch(const char *name, signed char& c)  : cObject(name) {ptr=&c; type='c';}
00107 
00111     cWatch(const char *name, unsigned char& c)  : cObject(name) {ptr=&c; type='c';}
00112 
00116     cWatch(const char *name, int& i)  : cObject(name) {ptr=&i; type='i';}
00117 
00121     cWatch(const char *name, unsigned int& i)  : cObject(name) {ptr=&i; type='i';}
00122 
00126     cWatch(const char *name, long& l)  : cObject(name) {ptr=&l; type='l';}
00127 
00131     cWatch(const char *name, unsigned long& l)  : cObject(name) {ptr=&l; type='l';}
00132 
00136     cWatch(const char *name, double& d): cObject(name) {ptr=&d; type='d';}
00137 
00141     cWatch(const char *name, char* &s) : cObject(name) {ptr=&s; type='s';}
00142 
00146     cWatch(const char *name, signed char* &s) : cObject(name) {ptr=&s; type='s';}
00147 
00151     cWatch(const char *name, unsigned char* &s) : cObject(name) {ptr=&s; type='s';}
00152 
00156     cWatch(const char *name, const cObject* &o) : cObject(name) {ptr=&o; type='o';}
00157 
00161     cWatch& operator=(const cWatch& vs)     {ptr=vs.ptr;type=vs.type;return *this;}
00163 
00166 
00170     virtual const char *className() const {return "cWatch";}
00171 
00176     virtual cObject *dup() const   {return new cWatch(*this);}
00177 
00182     virtual void info(char *buf);
00183 
00188     virtual const char *inspectorFactoryName() const {return "cWatchIFC";}
00189 
00194     virtual void writeContents(ostream& os);
00196 
00199 
00204     virtual void printTo(char *s);  //FIXME: why public?
00205 
00211     char typeChar() const {return type;}
00212 
00216     void *pointer() const {return ptr;}
00218 };
00219 
00220 #endif
00221 

Generated at Sat May 4 15:45:48 2002 for OMNeT++ by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001