Dillo
identity.hh
Go to the documentation of this file.
1 #ifndef __LOUT_OBJECTX_HH__
2 #define __LOUT_OBJECTX_HH__
3 
4 #include "object.hh"
5 #include "container.hh"
6 #include "signal.hh"
7 
8 namespace lout {
9 
13 namespace identity {
14 
99 {
100 private:
101  class Class: public object::Object
102  {
103  public:
105  int id;
106  const char *className;
107 
108  Class (Class *parent, int id, const char *className);
109 
111  };
112 
117 
118  int classId;
119 
120 protected:
121  void registerName (const char *className, int *classId);
122 
123 public:
125 
127 
134  int getClassId () { return classId; }
135 
140  const char *getClassName() { return classesById->get(classId)->className; }
141 
142  bool instanceOf (int otherClassId);
143 };
144 
145 } // namespace identity
146 
147 } // namespace lout
148 
149 #endif // __LOUT_OBJECTX_HH__
Typed version of container::untyped::Vector.
Definition: container.hh:425
int classId
Definition: identity.hh:118
A class for fast concatenation of a large number of strings.
Definition: misc.hh:565
bool instanceOf(int otherClassId)
Returns, whether this class is an instance of the class, given by otherClassId, or of a sub class of ...
Definition: identity.cc:105
Typed version of container::untyped::HashTable.
Definition: container.hh:514
void intoStringBuffer(misc::StringBuffer *sb)
Store a textual representation of the object in a misc::StringBuffer.
Definition: identity.cc:70
IdentifiableObject()
Definition: identity.cc:65
Instances of classes, which are sub classes of this class, may be identified at run-time.
Definition: identity.hh:98
int id
Definition: identity.hh:105
static Class * currentlyConstructedClass
Definition: identity.hh:116
This is the base class for many other classes, which defines very common virtual methods.
Definition: object.hh:24
static container::typed::HashTable< object::ConstString, Class > * classesByName
Definition: identity.hh:114
int getClassId()
Returns the class identifier.
Definition: identity.hh:134
T * get(int pos) const
Definition: container.hh:441
const char * className
Definition: identity.hh:106
void registerName(const char *className, int *classId)
This method must be called in the constructor for the sub class. See class comment for details...
Definition: identity.cc:83
static container::typed::Vector< Class > * classesById
Definition: identity.hh:115
const char * getClassName()
Return the name, under which the class of this object was registered.
Definition: identity.hh:140
Class(Class *parent, int id, const char *className)
Definition: identity.cc:34
Definition: container.cc:27
void intoStringBuffer(misc::StringBuffer *sb)
Store a textual representation of the object in a misc::StringBuffer.
Definition: identity.cc:42
An object::Object wrapper for constant strings (char*).
Definition: object.hh:162
Class * parent
Definition: identity.hh:104