# cPolymorphic Class Reference
[Simulation core classes]

`#include <cpolymorphic.h>`

Inheritance diagram for cPolymorphic:

List of all members.

## Detailed Description

Ultimate base class for cObject, and thus for nearly all OMNeT++ classes.

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 & Destructor Documentation

cPolymorphic::cPolymorphic | ( |  | ) | `[inline]`

| Constructor. It has an empty body. (The class doesn't have data members and there's nothing special to do at construction time.)

virtual cPolymorphic::~cPolymorphic | ( |  | ) | `[inline, virtual]`

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

## Member Function Documentation

virtual const char* cPolymorphic::className | ( |  | ) | const`[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.

virtual std::string cPolymorphic::detailedInfo | ( |  | ) | const`[virtual]`

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

virtual cPolymorphic* cPolymorphic::dup | ( |  | ) | const`[virtual]`

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.

virtual const char* cPolymorphic::fullName | ( |  | ) | const`[virtual]`

| Can be redefined (as done in cObject) to return an object name. This version just returns "". Reimplemented in cGate, cModule, and cObject.

virtual std::string cPolymorphic::fullPath | ( |  | ) | const`[virtual]`

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

virtual void cPolymorphic::info | ( | char * | buf | ) | `[virtual]`

| DEPRECATED. Copies first MAX_OBJECTINFO characters of `info().c_str()` into `buf'. Use info() instead.

virtual std::string cPolymorphic::info | ( |  | ) | const`[virtual]`

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.

See also:
  detailedInfo()

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.

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

- cpolymorphic.h