Instances of classes, which are sub classes of this class, may be identified at run-time. More…
|void||intoStringBuffer (misc::StringBuffer *sb)|
|Store a textual representation of the object in a misc::StringBuffer. More…|
|Returns the class identifier. More…|
|const char *||getClassName ()|
|Return the name, under which the class of this object was registered. More…|
|bool||instanceOf (int otherClassId)|
|Returns, whether this class is an instance of the class, given by otherClassId, or of a sub class of this class. More…|
|Public Member Functions inherited from lout::object::Object|
|The destructor is defined as virtual (but not abstract), so that destruction of Object‘s works properly. More…|
|virtual bool||equals (Object *other)|
|Returns, whether two objects are equal. More…|
|virtual int||hashValue ()|
|Return a hash value for the object. More…|
|virtual Object *||clone ()|
|Return an exact copy of the object. More…|
|const char *||toString ()|
|Use object::Object::intoStringBuffer to return a textual representation of the object. More…|
|virtual size_t||sizeOf ()|
|Return the number of bytes, this object totally uses. More…|
|void||registerName (const char *className, int *classId)|
|This method must be called in the constructor for the sub class. See class comment for details. More…|
|static container::typed::HashTable< object::ConstString, Class > *||classesByName|
|static container::typed::Vector< Class > *||classesById|
|static Class *||currentlyConstructedClass|
Instances of classes, which are sub classes of this class, may be identified at run-time.
Testing the class
It is also possible to get the class identifier of an identity::IdentifiableObject, e.g.
Defining Sub Classes
Each direct or indirect sub class of IdentifiableObject must
- add a static int CLASS_ID with -1 as initial value, and
- call registerName (name, &CLASS_ID) in the constructor, where name should be unique, e.g. the fully qualified class name.
After this, class::CLASS_ID refers to a number, which denotes the class. (If this is still -1, since the class has not yet been instantiated, any test will fail, which is correct.)
Notes on implementation
If there are some classes like this:
and first, an instance of A, and then an instance of C is created, there will be the following calls of functions and constructors:
- IdentifiableObject ();
- registerName (“A”, &A::CLASS_ID);
- IdentifiableObject ();
- registerName (“B”, &B::CLASS_ID);
- registerName (“C”, &C::CLASS_ID);
N.b. Multiple inheritance is not supported, the construction of the tree would become confused.
Constructor & Destructor Documentation
Member Function Documentation
Return the name, under which the class of this object was registered.
This method must be called in the constructor for the sub class. See class comment for details.
Referenced by dw::AlignedTableCell::AlignedTableCell(), dw::AlignedTextblock::AlignedTextblock(), dw::ListItem::ListItem(), dw::RegardingBorder::RegardingBorder(), dw::Ruler::Ruler(), and dw::SimpleTableCell::SimpleTableCell().
Member Data Documentation
Referenced by getClassId().
The documentation for this class was generated from the following files:
Generated on Mon Apr 6 2015 02:15:19 for Dillo by 184.108.40.206