Main Page | Modules | Class Hierarchy | Class List | File List | Class Members | Related Pages

cwatch.h

00001 //==========================================================================
00002 //  CWATCH.H - part of
00003 //                     OMNeT++/OMNEST
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-2005 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 // TBD update watches to use templates
00082 class SIM_API cWatch : public cObject
00083 {
00084   private:
00085     void *ptr;
00086     char type;
00087 
00088   public:
00091 
00095     cWatch(const cWatch& vs);
00096 
00100     cWatch(const char *name, char& c)  : cObject(name) {ptr=&c; type='c';}
00101 
00105     cWatch(const char *name, signed char& c)  : cObject(name) {ptr=&c; type='c';}
00106 
00110     cWatch(const char *name, unsigned char& c)  : cObject(name) {ptr=&c; type='c';}
00111 
00115     cWatch(const char *name, bool& b)  : cObject(name) {ptr=&b; type='b';}
00116 
00120     cWatch(const char *name, int& i)  : cObject(name) {ptr=&i; type='i';}
00121 
00125     cWatch(const char *name, unsigned int& i)  : cObject(name) {ptr=&i; type='i';}
00126 
00130     cWatch(const char *name, long& l)  : cObject(name) {ptr=&l; type='l';}
00131 
00135     cWatch(const char *name, unsigned long& l)  : cObject(name) {ptr=&l; type='l';}
00136 
00140     cWatch(const char *name, double& d): cObject(name) {ptr=&d; type='d';}
00141 
00145     cWatch(const char *name, const char* &s) : cObject(name) {ptr=&s; type='s';}
00146 
00150     cWatch(const char *name, const signed char* &s) : cObject(name) {ptr=&s; type='s';}
00151 
00155     cWatch(const char *name, const unsigned char* &s) : cObject(name) {ptr=&s; type='s';}
00156 
00160     cWatch(const char *name, const cObject* &o) : cObject(name) {ptr=&o; type='o';}
00161 
00165     cWatch& operator=(const cWatch& vs)     {ptr=vs.ptr;type=vs.type;return *this;}
00167 
00170 
00175     virtual cObject *dup() const   {return new cWatch(*this);}
00176 
00181     virtual std::string info() const;
00182 
00187     virtual void writeContents(std::ostream& os);
00189 
00192 
00197     virtual void printTo(char *s) const;
00198 
00204     char typeChar() const {return type;}
00205 
00209     void *pointer() const {return ptr;}
00211 };
00212 
00213 #endif
00214 

Generated on Fri Apr 1 12:25:33 2005 for OMNeT++/OMNEST Simulation Library by  doxygen 1.3.9.1