OMNeT++ Simulation Library  5.6.1
cDefaultList Class Reference

#include <cdefaultlist.h>

Description

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).

Inheritance diagram for cDefaultList:
cNoncopyableOwnedObject cOwnedObject noncopyable cNamedObject cObject cComponent cChannel cModule cDatarateChannel cDelayChannel cIdealChannel cSimpleModule

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
 
cOwnedObjectdefaultListGet (int k)
 
bool defaultListContains (cOwnedObject *obj) const
 
- Public Member Functions inherited from cNoncopyableOwnedObject
 cNoncopyableOwnedObject (const char *name=nullptr, bool namepooling=true)
 
virtual cNoncopyableOwnedObjectdup () const override
 
- Public Member Functions inherited from cOwnedObject
 cOwnedObject ()
 
 cOwnedObject (const char *name, bool namepooling=true)
 
 cOwnedObject (const cOwnedObject &obj)
 
virtual ~cOwnedObject ()
 
cOwnedObjectoperator= (const cOwnedObject &o)
 
virtual cObjectgetOwner () 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 ()
 
cNamedObjectoperator= (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 cObjectgetThisPtr () const
 
virtual _OPPDEPRECATED std::string info () const
 
virtual _OPPDEPRECATED std::string detailedInfo () const
 
cObjectfindObject (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 cDefaultListgetDefaultOwner ()
 

Constructor & Destructor Documentation

◆ cDefaultList()

cDefaultList ( const char *  name = nullptr)
explicit

Constructor.

◆ ~cDefaultList()

virtual ~cDefaultList ( )
virtual

Destructor. The contained objects will be deleted.

Member Function Documentation

◆ take()

virtual void take ( cOwnedObject obj)
overrideprotectedvirtual

Redefined.

Reimplemented from cObject.

◆ drop()

virtual void drop ( cOwnedObject obj)
overrideprotectedvirtual

Redefined.

Reimplemented from cObject.

◆ isSoftOwner()

virtual bool isSoftOwner ( ) const
inlineoverridevirtual

Returns true.

Reimplemented from cOwnedObject.

◆ str()

virtual std::string str ( ) const
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.

◆ forEachChild()

virtual void forEachChild ( cVisitor v)
overridevirtual

Calls v->visit(this) for each contained object. See cObject for more details.

Reimplemented from cObject.

Reimplemented in cModule, cComponent, and cSimpleModule.

◆ parsimPack()

virtual void parsimPack ( cCommBuffer buffer) const
overridevirtual

Packing and unpacking cannot be supported with this class. This method raises an error.

Reimplemented from cNoncopyableOwnedObject.

Reimplemented in cChannel.

◆ parsimUnpack()

virtual void parsimUnpack ( cCommBuffer buffer)
overridevirtual

Packing and unpacking cannot be supported with this class. This method raises an error.

Reimplemented from cNoncopyableOwnedObject.

Reimplemented in cChannel.

◆ getPerformFinalGC()

bool getPerformFinalGC ( ) const
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.

◆ setPerformFinalGC()

virtual void setPerformFinalGC ( bool  b)
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.

◆ defaultListSize()

int defaultListSize ( ) const
inline

Returns the number of elements stored.

◆ defaultListGet()

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.

◆ defaultListContains()

bool defaultListContains ( cOwnedObject obj) const

Returns true if the set contains the given object, false otherwise.


The documentation for this class was generated from the following file: