#include <cpolymorphic.h>
Inheritance diagram for cPolymorphic:
cPolymorphic is a lightweight common base class: it only contains virtual member functions but NO DATA MEMBERS at all.
It is recommended to use cPolymorphic as a base class for any class that has at least one virtual member function. This makes the class more interoperable with OMNeT++, and causes no extra overhead at all. sizeof(cPolymorphic) should yield 4 on a 32-bit architecture (4-byte vptr), and using cPolymorphic as a base class doesn't add anything to the size because a class with a virtual function already has a vptr.
cPolymorphic allows the object to be displayed in graphical user interface (Tkenv) via the className(), info() and detailedInfo() methods which you may choose to redefine in your own subclasses.
Using cPolymorphic also strengthens type safety. cPolymorphic *
pointers should replace void *
in most places where you need pointers to "any data structure". Using cPolymorphic will allow safe downcasts using dynamic_cast
and also OMNeT++'s check_and_cast
.
Public Member Functions | |
cPolymorphic () | |
virtual | ~cPolymorphic () |
virtual const char * | className () const |
Empty virtual functions which can be redefined in subclasses | |
virtual const char * | fullName () const |
virtual std::string | fullPath () const |
virtual std::string | info () const |
virtual void | info (char *buf) |
virtual std::string | detailedInfo () const |
virtual cPolymorphic * | dup () const |
|
Constructor. It has an empty body. (The class doesn't have data members and there's nothing special to do at construction time.) |
|
Destructor. It has an empty body (the class doesn't have data members.) It is declared here only to make the class polymorphic and make its destructor virtual. |
|
Returns a pointer to the class name string. This method is implemented using typeid (C++ RTTI), and it does not need to be overridden in subclasses. Reimplemented in cGenericReadonlyWatch< T >, cGenericAssignableWatch< T >, cWatch_bool, cWatch_char, cWatch_uchar, cWatch_stdstring, cWatch_cPolymorphic, and cWatch_cPolymorphicPtr. |
|
Can be redefined to produce a detailed, multi-line, arbitrarily long description of the object. The string appears in the graphical user interface (Tkenv) together with other object data (e.g. class name) wherever it is feasible to display a multi-line string. |
|
Should be redefined in subclasses to create an exact copy of this object. The default implementation just throws an error, to indicate that the method was not redefined. Reimplemented in cBag, cArray, cChannel, cBasicChannel, cDefaultList, cTDExpandingWindows, cADByStddev, cEnum, cFSM, cGate, cLongHistogram, cDoubleHistogram, cKSplit, cLinkedList, cMessage, cCompoundModule, cMessageHeap, cObject, cOutVector, cPacket, cPar, cModulePar, cPSquare, cQueue, cSimpleModule, cSimulation, cStdDev, cWeightedStdDev, cTopology, cModuleInterface, cModuleType, cLinkType, cFunctionType, cClassRegister, cVarHistogram, and cWatchBase. |
|
Can be redefined (as done in cObject) to return an object name. This version just returns "". |
|
Can be redefined (as done in cObject) to return an object full path, which contains the object name (more precisely, fullName()) together with the object's location in the object hierarchy. This version just returns fullName() (which is by default ""). Reimplemented in cGate, cModule, cObject, cModulePar, and cSimulation. |
|
DEPRECATED.
Copies first MAX_OBJECTINFO characters of |
|
Can be redefined to produce a one-line description of object into `buf'. The string appears in the graphical user interface (Tkenv) e.g. when the object is displayed in a listbox. The returned string should possibly be at most 80-100 characters long, and must not contain newline.
Reimplemented in cBag, cArray, cChannel, cBasicChannel, cDefaultList, cEnum, cFSM, cGate, cLinkedList, cMessage, cCompoundModule, cMessageHeap, cOutVector, cPacket, cPar, cQueue, cSimpleModule, cStdDev, cTopology, cGenericReadonlyWatch< T >, cGenericAssignableWatch< T >, cWatch_bool, cWatch_char, cWatch_uchar, cWatch_stdstring, cWatch_cPolymorphic, and cWatch_cPolymorphicPtr. |