OMNeT++ Simulation Library
5.6.1
|
#include <cdefaultlist.h>
Internal class, used as a base class for modules and channels. It is not intended for subclassing outside the simulation kernel.
cDefaultList acts as a "soft owner" (see object ownership discussion in cOwnedObject documentation).
Public Member Functions | |
Constructors, destructor, assignment. | |
cDefaultList (const char *name=nullptr) | |
virtual | ~cDefaultList () |
Redefined cObject methods. | |
virtual bool | isSoftOwner () const override |
virtual std::string | str () const override |
virtual void | forEachChild (cVisitor *v) override |
virtual void | parsimPack (cCommBuffer *buffer) const override |
virtual void | parsimUnpack (cCommBuffer *buffer) override |
Container functions. | |
bool | getPerformFinalGC () const |
virtual void | setPerformFinalGC (bool b) |
int | defaultListSize () const |
cOwnedObject * | defaultListGet (int k) |
bool | defaultListContains (cOwnedObject *obj) const |
Public Member Functions inherited from cNoncopyableOwnedObject | |
cNoncopyableOwnedObject (const char *name=nullptr, bool namepooling=true) | |
virtual cNoncopyableOwnedObject * | dup () const override |
Public Member Functions inherited from cOwnedObject | |
cOwnedObject () | |
cOwnedObject (const char *name, bool namepooling=true) | |
cOwnedObject (const cOwnedObject &obj) | |
virtual | ~cOwnedObject () |
cOwnedObject & | operator= (const cOwnedObject &o) |
virtual cObject * | getOwner () const override |
virtual bool | isOwnedObject () const override |
Public Member Functions inherited from cNamedObject | |
cNamedObject () | |
cNamedObject (const char *name, bool namepooling=true) | |
cNamedObject (const cNamedObject &obj) | |
virtual | ~cNamedObject () |
cNamedObject & | operator= (const cNamedObject &o) |
virtual void | setName (const char *s) |
virtual const char * | getName () const override |
virtual void | setNamePooling (bool b) |
virtual bool | getNamePooling () |
Public Member Functions inherited from cObject | |
cObject () | |
cObject (const cObject &other) | |
virtual | ~cObject () |
virtual const char * | getClassName () const |
bool | isName (const char *s) const |
virtual const char * | getFullName () const |
virtual std::string | getFullPath () const |
const cObject * | getThisPtr () const |
virtual _OPPDEPRECATED std::string | info () const |
virtual _OPPDEPRECATED std::string | detailedInfo () const |
cObject * | findObject (const char *name, bool deep=true) |
void | copyNotSupported () const |
Protected Member Functions | |
Redefined cObject member functions | |
virtual void | take (cOwnedObject *obj) override |
virtual void | drop (cOwnedObject *obj) override |
Protected Member Functions inherited from cObject | |
void | dropAndDelete (cOwnedObject *obj) |
Additional Inherited Members | |
Static Public Member Functions inherited from cOwnedObject | |
static long | getTotalObjectCount () |
static long | getLiveObjectCount () |
static void | resetObjectCounters () |
static cDefaultList * | getDefaultOwner () |
|
explicit |
Constructor.
|
virtual |
Destructor. The contained objects will be deleted.
|
overrideprotectedvirtual |
Redefined.
Reimplemented from cObject.
|
overrideprotectedvirtual |
Redefined.
Reimplemented from cObject.
|
inlineoverridevirtual |
Returns true.
Reimplemented from cOwnedObject.
|
overridevirtual |
Produces a one-line description of the object's contents. See cObject for more details.
Reimplemented from cObject.
Reimplemented in cModule, cSimpleModule, cChannel, and cDatarateChannel.
|
overridevirtual |
Calls v->visit(this) for each contained object. See cObject for more details.
Reimplemented from cObject.
Reimplemented in cModule, cComponent, and cSimpleModule.
|
overridevirtual |
Packing and unpacking cannot be supported with this class. This method raises an error.
Reimplemented from cNoncopyableOwnedObject.
Reimplemented in cChannel.
|
overridevirtual |
Packing and unpacking cannot be supported with this class. This method raises an error.
Reimplemented from cNoncopyableOwnedObject.
Reimplemented in cChannel.
|
inline |
Whether the destructor will delete garbage objects (owned objects that have not been deallocated by destructors of derived classes); see setPerformFinalGC() for details. The default setting is false.
|
inlinevirtual |
Enables deleting of garbage objects in the destructor. Garbage objects are objects that are on this default list at destruct time (see defaultListSize() and defaultListGet()); they are practically objects owned by this module or channel that have not been deallocated by destructors of derived classes.
This feature is turned off by default, because it cannot be implemented to work correctly in all cases. The garbage collection routine invokes the delete
operator on all objects on the default list. This, however, causes problems (crash) in some cases: when the object has been allocated as an element in an array (e.g. new cQueue[10]
), when the object is part of another object (e.g. struct X {cQueue q;};
), or any other case when the object's pointer is not deleteable. Note that the presence of such data structures in a module does not automatically rule out the use of the final GC mechanism. Final GC can still be turned on if care is taken that the module's destructor deallocates those arrays and structs/objects, so that the contained objects disappear before the GC process could see them. Conclusion: only turn on final GC if you know what you are doing.
|
inline |
Returns the number of elements stored.
cOwnedObject* defaultListGet | ( | int | k | ) |
Get the element at the given position. k must be between 0 and defaultListSize()-1 (inclusive). If the index is out of bounds, nullptr is returned.
bool defaultListContains | ( | cOwnedObject * | obj | ) | const |
Returns true if the set contains the given object, false otherwise.