OMNeT++ Simulation Library  5.6.1
cobject.h
1 //==========================================================================
2 // COBJECT.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_COBJECT_H
17 #define __OMNETPP_COBJECT_H
18 
19 #include <string>
20 #include "simkerneldefs.h"
21 #include "simutil.h"
22 #include "cvisitor.h"
23 
24 // Note: we include regmacros.h here in order to prevent the compiler from
25 // misunderstanding Register_Class() in other source files as a function declaration
26 #include "regmacros.h"
27 
28 namespace omnetpp {
29 
30 class cCommBuffer;
31 class cClassDescriptor;
32 class cOwnedObject;
33 
34 
58 class SIM_API cObject
59 {
60  friend class cOwnedObject;
61  friend class cDefaultList;
62 
63  public:
64  // internal: returns a descriptor object for this object
65  virtual cClassDescriptor *getDescriptor() const;
66 
67 #ifdef SIMFRONTEND_SUPPORT
68  // internal: used by the UI to optimize refreshes
69  virtual bool hasChangedSince(int64_t refreshSerial);
70  static int64_t getChangeCounter() {return changeCounter;}
71 #endif
72 
73  protected:
74 #ifdef SIMFRONTEND_SUPPORT
75  // internal
76  static int64_t changeCounter;
77 #endif
78 
79  // internal
80  virtual void ownedObjectDeleted(cOwnedObject *obj);
81 
82  // internal
83  virtual void yieldOwnership(cOwnedObject *obj, cObject *to);
84 
85  public:
90  cObject() {}
91 
98  cObject(const cObject& other) {}
99 
105  virtual ~cObject();
106 
112  virtual const char *getClassName() const;
113 
120  virtual const char *getName() const {return "";}
121 
125  bool isName(const char *s) const {return !opp_strcmp(getName(),s);}
126 
135  virtual const char *getFullName() const {return getName();}
136 
144  virtual std::string getFullPath() const;
145 
149  const cObject *getThisPtr() const {return this;} //Note: nonvirtual
150 
155  virtual std::string str() const;
156 
160  _OPPDEPRECATED virtual std::string info() const {return str();}
161 
165  _OPPDEPRECATED virtual std::string detailedInfo() const {return "";}
166 
172  virtual cObject *dup() const;
174 
175  protected:
183 
191  virtual void take(cOwnedObject *obj);
192 
200  virtual void drop(cOwnedObject *obj);
201 
215  void dropAndDelete(cOwnedObject *obj);
217 
218  public:
230  virtual void parsimPack(cCommBuffer *buffer) const;
231 
236  virtual void parsimUnpack(cCommBuffer *buffer);
238 
245  virtual cObject *getOwner() const {return nullptr;}
246 
254  virtual bool isOwnedObject() const {return false;}
255 
264  virtual void forEachChild(cVisitor *v);
265 
278  cObject *findObject(const char *name, bool deep=true);
280 
289  void copyNotSupported() const;
291 };
292 
293 
312 {
313  protected:
314  noncopyable() {}
315  ~noncopyable() {}
316  private:
317  // private, and in addition deleted
318  noncopyable(const noncopyable& x) = delete;
319  const noncopyable& operator=(const noncopyable&) = delete;
320 };
321 
322 } // namespace omnetpp
323 
324 
325 #endif
326 
Internal class, used as a base class for modules and channels. It is not intended for subclassing out...
Definition: cdefaultlist.h:33
Root of the OMNeT++ class hierarchy. cObject is a lightweight class without any data members...
Definition: cobject.h:58
virtual const char * getName() const
Definition: cobject.h:120
virtual _OPPDEPRECATED std::string detailedInfo() const
Definition: cobject.h:165
virtual _OPPDEPRECATED std::string info() const
Definition: cobject.h:160
const cObject * getThisPtr() const
Definition: cobject.h:149
virtual const char * getFullName() const
Definition: cobject.h:135
virtual cObject * getOwner() const
Definition: cobject.h:245
bool isName(const char *s) const
Definition: cobject.h:125
cObject()
Definition: cobject.h:90
cObject(const cObject &other)
Definition: cobject.h:98
Buffer for the communications layer of parallel simulation.
Definition: ccommbuffer.h:41
A cObject that keeps track of its owner. It serves as base class for many classes in the OMNeT++ libr...
Definition: cownedobject.h:104
Enables traversing the tree of (cObject-rooted) simulation objects.
Definition: cvisitor.h:56
Utility class, to make it impossible to call the operator= and copy constructor of any class derived ...
Definition: cobject.h:311
virtual bool isOwnedObject() const
Definition: cobject.h:254
Definition: cabstracthistogram.h:21
Abstract base class for structure description classes, used mainly with message subclassing.
Definition: cclassdescriptor.h:44
int opp_strcmp(const char *, const char *)
Same as the standard strcmp() function, except that nullptr is treated exactly as an empty string (""...
Definition: simutil.h:307