"Fossies" - the Fresh Open Source Software Archive

Member "OpenSP-1.5.2/include/rtti.h" (21 Jul 2005, 1599 Bytes) of package /linux/misc/old/OpenSP-1.5.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "rtti.h" see the Fossies "Dox" file reference documentation.

    1 // Copyright (c) 1994 James Clark
    2 // See the file COPYING for copying permission.
    3 
    4 #ifndef rtti_INCLUDED
    5 #define rtti_INCLUDED 1
    6 
    7 #ifdef SP_HAVE_RTTI
    8 
    9 #define DYNAMIC_CAST_PTR(T, p) dynamic_cast<T *>(p)
   10 #define DYNAMIC_CAST_CONST_PTR(T, p) dynamic_cast<const T *>(p)
   11 
   12 #define RTTI_CLASS
   13 
   14 #define RTTI_DEF0(T)
   15 #define RTTI_DEF1(T, B1)
   16 #define RTTI_DEF2(T, B1, B2)
   17 #define RTTI_DEF3(T, B1, B2, B3)
   18 
   19 #else /* not SP_HAVE_RTTI */
   20 
   21 #include "TypeId.h"
   22 
   23 #define RTTI_CLASS \
   24 public: \
   25   virtual TypeId dynamicType() const; \
   26   static inline TypeId staticType() { return TypeId(RTTI_bases_); } \
   27 protected: \
   28   static const void *RTTI_bases_[]; \
   29 private:
   30 
   31 #define RTTI_DEF0(T) \
   32   const void *T::RTTI_bases_[] = { 0 }; \
   33   TypeId T::dynamicType() const { return staticType(); }
   34 
   35 #define RTTI_DEF1(T, B1) \
   36   const void *T::RTTI_bases_[] = { B1::RTTI_bases_, 0 }; \
   37   TypeId T::dynamicType() const { return staticType(); }
   38 
   39 #define RTTI_DEF2(T, B1, B2) \
   40   const void *T::RTTI_bases_[] = { B1::RTTI_bases_, B2::RTTI_bases_, 0 }; \
   41   TypeId T::dynamicType() const { return staticType(); }
   42 
   43 #define RTTI_DEF3(T, B1, B2, B3) \
   44   const void *T::RTTI_bases_[] = { \
   45     B1::RTTI_bases_, B2::RTTI_bases_, B3::RTTI_bases_, 0 }; \
   46   TypeId T::dynamicType() const { return staticType(); }
   47 
   48 #define DYNAMIC_CAST_PTR(T, p) \
   49 ((p) && (p)->dynamicType().canCast(T::staticType(), (p)->staticType()) \
   50  ? (T *)(p) \
   51  : 0)
   52 #define DYNAMIC_CAST_CONST_PTR(T, p) \
   53 ((p) && (p)->dynamicType().canCast(T::staticType(), (p)->staticType()) \
   54  ? (const T *)p \
   55  : 0)
   56 
   57 #endif /* not SP_HAVE_RTTI */
   58 
   59 #endif /* not rtti_INCLUDED */