00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifdef __cplusplus
00024
00025 # ifndef OGS_SUPPORT_CLASS_H
00026 # define OGS_SUPPORT_CLASS_H
00027
00028 # include <string>
00029 # include <typeinfo>
00030
00031 # include <ogs/support/Namespace.h>
00032 # include <ogs/support/Object.h>
00033
00034 OGS_BEGIN_SUPPORT_NAMESPACE
00035
00041 class Class {
00042 public:
00043 template <class C>
00044 static Class getClass ();
00045
00046 bool operator== (const Class& cls) const;
00047 bool operator!= (const Class& cls) const;
00048 std::string getName () const;
00049
00050 private:
00051 const std::type_info& typeInfo;
00052
00053 Class ();
00054 Class (const std::type_info& typeInfo);
00055
00056 friend Class Object::getClass () const;
00057 };
00058
00065 template <class C>
00066 inline Class Class::getClass () {
00067 Class c (typeid (C));
00068 return (c);
00069 }
00070
00077 inline bool
00078 Class::operator== (const Class& cls) const {
00079 return (typeInfo == cls.typeInfo);
00080 }
00081
00089 inline bool
00090 Class::operator!= (const Class& cls) const {
00091 return (typeInfo != cls.typeInfo);
00092 }
00093
00099 inline std::string Class::getName () const {
00100 return (std::string (typeInfo.name ()));
00101 }
00102
00108 inline Class
00109 Object::getClass () const {
00110 return (Class (typeid (*this)));
00111 }
00112
00113 OGS_END_SUPPORT_NAMESPACE
00114
00115 # endif
00116
00117 #endif
00118