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-2003 Andras Varga
00014 
00015   This file is distributed WITHOUT ANY WARRANTY. See the file
00016   `license' for details on this and other legal matters.
00017 *--------------------------------------------------------------*/
00018 
00019 #ifndef __CWATCH_H
00020 #define __CWATCH_H
00021 
00022 #include "cobject.h"
00023 
00024 //=== classes declared here
00025 class  cWatch;
00026 
00032 
00059 #define WATCH(var)   new cWatch( #var, var );
00060 
00067 #define LWATCH(var)  cWatch var##__varshell( #var, var );
00068 
00069 
00070 //==========================================================================
00071 
00081 class SIM_API cWatch : public cObject
00082 {
00083   private:
00084     void *ptr;
00085     char type;
00086 
00087   public:
00090 
00094     cWatch(const cWatch& vs);
00095 
00099     cWatch(const char *name, char& c)  : cObject(name) {ptr=&c; type='c';}
00100 
00104     cWatch(const char *name, signed char& c)  : cObject(name) {ptr=&c; type='c';}
00105 
00109     cWatch(const char *name, unsigned char& c)  : cObject(name) {ptr=&c; type='c';}
00110 
00114     cWatch(const char *name, bool& b)  : cObject(name) {ptr=&b; type='b';}
00115 
00119     cWatch(const char *name, int& i)  : cObject(name) {ptr=&i; type='i';}
00120 
00124     cWatch(const char *name, unsigned int& i)  : cObject(name) {ptr=&i; type='i';}
00125 
00129     cWatch(const char *name, long& l)  : cObject(name) {ptr=&l; type='l';}
00130 
00134     cWatch(const char *name, unsigned long& l)  : cObject(name) {ptr=&l; type='l';}
00135 
00139     cWatch(const char *name, double& d): cObject(name) {ptr=&d; type='d';}
00140 
00144     cWatch(const char *name, const char* &s) : cObject(name) {ptr=&s; type='s';}
00145 
00149     cWatch(const char *name, const signed char* &s) : cObject(name) {ptr=&s; type='s';}
00150 
00154     cWatch(const char *name, const unsigned char* &s) : cObject(name) {ptr=&s; type='s';}
00155 
00159     cWatch(const char *name, const cObject* &o) : cObject(name) {ptr=&o; type='o';}
00160 
00164     cWatch& operator=(const cWatch& vs)     {ptr=vs.ptr;type=vs.type;return *this;}
00166 
00169 
00174     virtual cObject *dup() const   {return new cWatch(*this);}
00175 
00180     virtual void info(char *buf);
00181 
00186     virtual void writeContents(ostream& os);
00188 
00191 
00196     virtual void printTo(char *s);  //FIXME: why public?
00197 
00203     char typeChar() const {return type;}
00204 
00208     void *pointer() const {return ptr;}
00210 };
00211 
00212 #endif
00213 

Generated at Mon Jun 16 23:37:31 2003 for OMNeT++ by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001