Guest User

Untitled

a guest
Mar 4th, 2012
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. #include <boost/type_traits/is_base_of.hpp>
  2.  
  3. // Must be parent for all classes
  4. class Object
  5. {
  6. };
  7.  
  8. #define DECLARE_TYPE_BASE(T)                                                \
  9. public:                                                                     \
  10.     typedef T ThisType;
  11.  
  12. #define DECLARE_TYPE_INHERITANCE(T, BASE)                                   \
  13.     BOOST_STATIC_ASSERT((boost::is_base_of<Object, BASE>::value) == true);  \
  14.     DECLARE_TYPE_BASE(T)                                                    \
  15. public:                                                                     \
  16.     typedef BASE InheritedType;
  17.  
  18. #define DECLARE_TYPE(T, BASE)                                               \
  19.     DECLARE_TYPE_INHERITANCE(T, BASE)
  20.  
  21. class Bar : public Object
  22. {
  23. };
  24.  
  25. class Foo : public Bar
  26. {
  27.     DECLARE_TYPE(Foo, Bar)
  28. public:
  29.     Foo() {}
  30.     virtual ~Foo() {}
  31. };
Advertisement
Add Comment
Please, Sign In to add comment