00001 #ifndef _LCORE_Object_H_ // -*- c++ -*-
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifdef __GNUG__
00036 # pragma interface
00037 #endif
00038
00039 #include <iosfwd>
00040
00041 #define _LCORE_Object_H_
00042
00043 namespace strmod {
00044 namespace lcore {
00045
00046 class ClassIdent;
00047
00048 class Object {
00049 public:
00050 static const ClassIdent identifier;
00051
00052 Object() {}
00053 virtual ~Object() {}
00054
00055 const ClassIdent &GetIdent() const { return(*i_GetIdent()); }
00056 inline virtual int AreYouA(const ClassIdent &cid) const;
00057
00058 protected:
00059 virtual void PrintOn(std::ostream &os) const;
00060 inline virtual void PrintOn(std::ostream &os);
00061 virtual int IsEqual(const Object &b) const { return(this == &b); }
00062 int DoEqual(const Object &b) const;
00063 inline virtual const ClassIdent *i_GetIdent() const;
00064
00065 private:
00066 friend int operator ==(const Object &a, const Object &b);
00067 friend std::ostream &operator <<(std::ostream &os, const Object &ob);
00068 friend std::ostream &operator <<(std::ostream &os, Object &ob);
00069
00070 };
00071
00072 #define AreYouA_Template(parent) return((identifier == cid) || \
00073 parent::AreYouA(cid)); \
00074 }
00075
00076 #define AreYouA_FuncT(parent) return((identifier == cid) || \
00077 parent::AreYouA(cid));
00078
00079 #ifndef _LCORE_ClassTypes_H_
00080 }
00081 }
00082 #include <LCore/ClassTypes.h>
00083 namespace strmod {
00084 namespace lcore {
00085 #endif
00086
00087 inline void Object::PrintOn(std::ostream &os)
00088 {
00089 ((const Object *)(this))->PrintOn(os);
00090 }
00091
00092 inline const ClassIdent *Object::i_GetIdent() const
00093 {
00094 return(&identifier);
00095 }
00096
00097 inline int Object::AreYouA(const ClassIdent &cid) const
00098 {
00099 return(cid == identifier);
00100 }
00101
00102 inline int operator ==(const Object &a, const Object &b)
00103 {
00104 return((&a == &b) || a.DoEqual(b));
00105 }
00106
00107 inline int operator !=(const Object &a, const Object &b)
00108 {
00109 return (!(a == b));
00110 }
00111
00112 inline std::ostream &operator <<(std::ostream &os, const Object &ob)
00113 {
00114 ob.PrintOn(os);
00115 return(os);
00116 }
00117
00118 inline std::ostream &operator <<(std::ostream &os, Object &ob)
00119 {
00120 ob.PrintOn(os);
00121 return(os);
00122 }
00123
00124 }
00125 }
00126
00127 #endif