00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef VRS_TYPEINFO_H
00019 #define VRS_TYPEINFO_H
00020
00021 #include <vrs/config.h>
00022 #include <vrs/id.h>
00023 #include <vrs/serializationmacros.h>
00024 #include <typeinfo>
00025
00026 namespace VRS {
00027
00028 class SharedObj;
00029 class SerializationManager;
00030
00031 class VRS_CORE_API ClassInfo {
00032 public:
00033 ClassInfo(const std::type_info& typeInfo, const ClassInfo* parent);
00034
00035 const std::type_info* typeInfo() const { return typeInfo_; }
00036 const ID& name() const { return name_; }
00037 const ClassInfo* parent() const { return parent_; }
00038
00039 bool isA(const ID& base) const;
00040
00041 private:
00042 const std::type_info* typeInfo_;
00043 const ID name_;
00044 const ClassInfo* const parent_;
00045 };
00046
00047 }
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 #define VRS_TYPEINFO(THIS_CLASS, BASE_CLASS) \
00058 typedef THIS_CLASS VRS_ThisClass; \
00059 typedef BASE_CLASS VRS_BaseClass; \
00060 virtual bool isEqual(const ::VRS::SharedObj* other) const { \
00061 if(!other) { return false; } \
00062 if(this == other) { return true; } \
00063 if(ClassInfoVRS() != other->classInfoVRS()) { return false; } \
00064 return (*this == static_cast<const THIS_CLASS&>(*other)); \
00065 } \
00066 static const ::VRS::ClassInfo* ClassInfoVRS() { \
00067 static const ::VRS::ClassInfo cInfo( \
00068 typeid(THIS_CLASS), \
00069 BASE_CLASS::ClassInfoVRS() \
00070 ); \
00071 return &cInfo; \
00072 } \
00073 virtual const ::VRS::ClassInfo* classInfoVRS() const { \
00074 return ClassInfoVRS(); \
00075 } \
00076 static const ::VRS::ID& ClassNameVRS() { \
00077 return ClassInfoVRS()->name(); \
00078 } \
00079 VRS_VISITABLE;
00080
00081
00082
00083
00084
00085
00086
00087 #define VRS_TEMPLATE_ARGS_1(T1, CLASS) CLASS< T1 >
00088 #define VRS_TEMPLATE_ARGS_2(T1, T2, CLASS) CLASS< T1, T2 >
00089 #define VRS_TEMPLATE_ARGS_3(T1, T2, T3, CLASS) CLASS< T1, T2, T3 >
00090 #define VRS_TEMPLATE_ARGS_4(T1, T2, T3, T4, CLASS) CLASS< T1, T2, T3, T4 >
00091 #define VRS_TEMPLATE_ARGS_5(T1, T2, T3, T4, T5, CLASS) CLASS< T1, T2, T3, T4, T5 >
00092
00093 #endif // VRS_TYPEINFO_H