cnamedobject.h Source File

API: cnamedobject.h Source File
API
cnamedobject.h
1//==========================================================================
2// CNAMEDOBJECT.H - part of
3// OMNeT++/OMNEST
4// Discrete System Simulation in C++
5//
6//==========================================================================
7
8/*--------------------------------------------------------------*
9 Copyright (C) 1992-2017 Andras Varga
10 Copyright (C) 2006-2017 OpenSim Ltd.
11
12 This file is distributed WITHOUT ANY WARRANTY. See the file
13 `license' for details on this and other legal matters.
14*--------------------------------------------------------------*/
15
16#ifndef __OMNETPP_CNAMEDOBJECT_H
17#define __OMNETPP_CNAMEDOBJECT_H
18
19#include <typeinfo>
20#include <iostream>
21#include "simkerneldefs.h"
22#include "cobject.h"
23#include "cexception.h"
24
25namespace omnetpp {
26
27
34class SIM_API cNamedObject : public cObject
35{
36 private:
37 const char *name = nullptr; // object name (stringpooled if flags&FL_NAMEPOOLING!=0)
38
39 protected:
40 uint32_t flags = FL_NAMEPOOLING; // FL_NAMEPOOLING flag; other bits used by derived classes
41 enum {FL_NAMEPOOLING = 1};
42
43 private:
44 void copy(const cNamedObject& other);
45
46 protected:
47 // internal: set a bit in flags; flag is one of the FL_xxx constants
48 void setFlag(int flag, bool value) {if (value) flags|=flag; else flags&=~flag;}
49 int getFlag(int flag) {return flags & flag;}
50
51 public:
54
58
62 explicit cNamedObject(const char *name, bool namepooling=true);
63
68
72 virtual ~cNamedObject();
73
83
84 // Note: dup() is still the original cObject one, which throws an error
85 // to indicate that dup() has to be redefined in each subclass.
86
90 virtual void parsimPack(cCommBuffer *buffer) const override;
91
95 virtual void parsimUnpack(cCommBuffer *buffer) override;
97
100
105 virtual void setName(const char *s);
106
111 virtual const char *getName() const override {return name ? name : "";}
112
117 virtual void setNamePooling(bool b);
118
122 virtual bool getNamePooling() {return flags&FL_NAMEPOOLING;}
124};
125
126} // namespace omnetpp
127
128
129#endif
130
Buffer for the communications layer of parallel simulation.
Definition ccommbuffer.h:42
virtual bool getNamePooling()
Definition cnamedobject.h:122
virtual void parsimPack(cCommBuffer *buffer) const override
virtual void setNamePooling(bool b)
virtual void parsimUnpack(cCommBuffer *buffer) override
virtual const char * getName() const override
Definition cnamedobject.h:111
cNamedObject(const char *name, bool namepooling=true)
virtual void setName(const char *s)
cNamedObject & operator=(const cNamedObject &o)
cNamedObject(const cNamedObject &obj)
cNamedObject()
Definition cnamedobject.h:57
cObject()
Definition cobject.h:124