|
OMNeT++ API 6.1
Discrete Event Simulation Library
|
|
16 #ifndef __OMNETPP_CWATCH_H
17 #define __OMNETPP_CWATCH_H
21 #include "cownedobject.h"
22 #include "cclassdescriptor.h"
50 virtual bool supportsAssignment()
const = 0;
56 virtual void assign(
const char *s) {}
74 virtual std::string
str()
const override
76 std::stringstream out;
97 virtual std::string
str()
const override
99 std::stringstream out;
103 virtual void assign(
const char *s)
override
105 std::stringstream in(s);
122 virtual std::string
str()
const override
124 return r ?
"true" :
"false";
126 virtual void assign(
const char *s)
override
128 r = *s!=
'0' && *s!=
'n' && *s!=
'N' && *s!=
'f' && *s!=
'F';
144 virtual std::string
str()
const override
146 std::stringstream out;
147 out <<
"'" << ((
unsigned char)r<32 ?
' ' : r) <<
"' (" << int(r) <<
")";
150 virtual void assign(
const char *s)
override
169 virtual const char *
getClassName()
const override {
return "unsigned char";}
171 virtual std::string
str()
const override
173 std::stringstream out;
174 out <<
"'" << (char)(r<
' ' ?
' ' : r) <<
"' (" << int(r) <<
")";
177 virtual void assign(
const char *s)
override
196 virtual const char *
getClassName()
const override {
return "std::string";}
198 virtual std::string str()
const override;
199 virtual void assign(
const char *s)
override;
208 friend class cWatchProxyDescriptor;
212 std::string typeName;
216 virtual const char *
getClassName()
const override {
return typeName.c_str();}
220 virtual void forEachChild(
cVisitor *visitor)
override;
221 cObject *getObjectPtr()
const {
return &r;}
230 friend class cWatchProxyDescriptor;
234 std::string typeName;
238 virtual const char *
getClassName()
const override {
return typeName.c_str();}
242 virtual void forEachChild(
cVisitor *visitor)
override;
243 cObject *getObjectPtr()
const {
return rp;}
247 inline cWatchBase *createWatch(
const char *varname,
short& d) {
248 return new cGenericAssignableWatch<short>(varname, d);
251 inline cWatchBase *createWatch(
const char *varname,
unsigned short& d) {
252 return new cGenericAssignableWatch<unsigned short>(varname, d);
255 inline cWatchBase *createWatch(
const char *varname,
int& d) {
256 return new cGenericAssignableWatch<int>(varname, d);
259 inline cWatchBase *createWatch(
const char *varname,
unsigned int& d) {
260 return new cGenericAssignableWatch<unsigned int>(varname, d);
263 inline cWatchBase *createWatch(
const char *varname,
long& d) {
264 return new cGenericAssignableWatch<long>(varname, d);
267 inline cWatchBase *createWatch(
const char *varname,
unsigned long& d) {
268 return new cGenericAssignableWatch<unsigned long>(varname, d);
271 inline cWatchBase *createWatch(
const char *varname,
float& d) {
272 return new cGenericAssignableWatch<float>(varname, d);
275 inline cWatchBase *createWatch(
const char *varname,
double& d) {
276 return new cGenericAssignableWatch<double>(varname, d);
279 inline cWatchBase *createWatch(
const char *varname,
bool& d) {
280 return new cWatch_bool(varname, d);
283 inline cWatchBase *createWatch(
const char *varname,
char& d) {
284 return new cWatch_char(varname, d);
287 inline cWatchBase *createWatch(
const char *varname,
unsigned char& d) {
288 return new cWatch_uchar(varname, d);
291 inline cWatchBase *createWatch(
const char *varname,
signed char& d) {
292 return new cWatch_char(varname, *(
char *)&d);
295 inline cWatchBase *createWatch(
const char *varname, std::string& v) {
296 return new cWatch_stdstring(varname, v);
301 inline cWatchBase *createWatch(
const char *varname, T& d) {
302 return new cGenericReadonlyWatch<T>(varname, d);
307 inline cWatchBase *createWatch_genericAssignable(
const char *varname, T& d) {
308 return new cGenericAssignableWatch<T>(varname, d);
312 inline cWatchBase *createWatch_cObject(
const char *varname,
const char *typeName, cObject& obj) {
313 return new cWatch_cObject(varname, typeName, obj);
323 inline cWatchBase *createWatch_cObjectPtr(
const char *varname,
const char *typeName, cObject *&refp, cObject *p) {
325 return new cWatch_cObjectPtr(varname, typeName, refp);
341 #define WATCH(variable) omnetpp::createWatch(#variable,(variable))
349 #define WATCH_RW(variable) omnetpp::createWatch_genericAssignable(#variable,(variable))
357 #define WATCH_OBJ(variable) omnetpp::createWatch_cObject(#variable, omnetpp::opp_typename(typeid(variable)), (variable))
365 #define WATCH_PTR(variable) omnetpp::createWatch_cObjectPtr(#variable, omnetpp::opp_typename(typeid(variable)), (cObject*&)(variable),(variable))
Abstract base class for class descriptors.
Definition: cclassdescriptor.h:39
Template Watch class, for any type that supports operator<<.
Definition: cwatch.h:66
virtual void assign(const char *s) override
Definition: cwatch.h:103
virtual std::string str() const override
Definition: cwatch.h:97
Watch class, specifically for char.
Definition: cwatch.h:136
cObject is a lightweight class which serves as the root of the OMNeT++ class hierarchy....
Definition: cobject.h:92
virtual const char * getClassName() const override
Definition: cwatch.h:72
virtual bool supportsAssignment() const override
Definition: cwatch.h:73
virtual bool supportsAssignment() const override
Definition: cwatch.h:218
virtual const char * getClassName() const override
Definition: cwatch.h:95
virtual const char * getClassName() const override
Definition: cwatch.h:216
Watch class, specifically for objects subclassed from cObject.
Definition: cwatch.h:206
Enables traversing the tree of (cObject-rooted) simulation objects.
Definition: cvisitor.h:56
virtual const char * getClassName() const override
Definition: cwatch.h:169
Watch class, specifically for pointers to objects subclassed from cObject.
Definition: cwatch.h:228
virtual std::string str() const override
Definition: cwatch.h:239
virtual void assign(const char *s)
Definition: cwatch.h:56
virtual cClassDescriptor * getDescriptor() const override
Definition: cwatch.h:241
virtual std::string str() const override
Definition: cwatch.h:74
virtual std::string str() const
cWatchBase(const char *name)
Definition: cwatch.h:42
virtual void assign(const char *s) override
Definition: cwatch.h:150
virtual bool supportsAssignment() const override
Definition: cwatch.h:96
virtual bool supportsAssignment() const override
Definition: cwatch.h:121
virtual std::string str() const override
Definition: cwatch.h:217
virtual void assign(const char *s) override
Definition: cwatch.h:177
Watch class, specifically for std::string.
Definition: cwatch.h:190
virtual const char * getFullName() const
Definition: cobject.h:169
virtual std::string str() const override
Definition: cwatch.h:122
Template Watch class, for any type that supports operator<<, and operator>> for assignment.
Definition: cwatch.h:89
virtual void assign(const char *s) override
Definition: cwatch.h:126
Watch class, specifically for bool.
Definition: cwatch.h:114
virtual cClassDescriptor * getDescriptor() const override
Definition: cwatch.h:219
virtual const char * getClassName() const override
Definition: cwatch.h:238
Base class for cOwnedObject-based classes that do not wish to support assignment and duplication.
Definition: cownedobject.h:242
virtual const char * getClassName() const override
Definition: cwatch.h:196
virtual bool supportsAssignment() const override
Definition: cwatch.h:143
virtual std::string str() const override
Definition: cwatch.h:171
Watch class, specifically for unsigned char.
Definition: cwatch.h:163
virtual bool supportsAssignment() const override
Definition: cwatch.h:240
virtual const char * getClassName() const
const SIM_API char * opp_typename(const std::type_info &t)
Returns the name of a C++ type, correcting the quirks of various compilers.
virtual const char * getClassName() const override
Definition: cwatch.h:142
virtual bool supportsAssignment() const override
Definition: cwatch.h:170
virtual bool supportsAssignment() const override
Definition: cwatch.h:197
virtual std::string str() const override
Definition: cwatch.h:144
virtual const char * getClassName() const override
Definition: cwatch.h:120
Helper class to make primitive types and non-cOwnedObject objects inspectable in Qtenv....
Definition: cwatch.h:34