Clarisse 5.0 SP8 SDK  5.0.5.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Macros
CoreClassInfo RTTI Macros

Macros to declare and implement CoreClassInfo RTTI API. More...

Macros

#define DECLARE_CLASS
 
#define DECLARE_POLYMORPHIC_BASE_CLASS
 
#define DECLARE_POLYMORPHIC_CLASS
 
#define IMPLEMENT_CLASS(class_name, base_class_name)
 
#define IMPLEMENT_BASE_CLASS(class_name)
 
#define IMPLEMENT_TEMPLATE_CLASS(class_name, base_class_name, template_type)
 
#define SPECIALIZE_TEMPLATE_CLASS(class_name, type_name)
 

Detailed Description

Macros to declare and implement CoreClassInfo RTTI API.

Macro Definition Documentation

#define DECLARE_CLASS
Value:
public: \
static const CoreClassInfo& class_info(); \
inline const CoreClassInfo& get_class_info() const { return class_info(); }

Declare a class that does not inherit from CoreBaseObject, and is not meant to be inherited. This will declare a static class_info method and an inline non-virtual get_class_info method.

This is used for Clarisse's RTTI system. You basically just have to use this macro (or DECLARE_POLYMORPHIC_BASE_CLASS or DECLARE_POLYMORPHIC_CLASS, depending on the class you want to support) in the class declaration.

class Foo
{
public:
// The usual...
// Declare the RTTI API. Definition is done in the .cc with #IMPLEMENT_CLASS or #IMPLEMENT_BASE_CLASS
};
Note
For legacy reasons DECLARE_CLASS is used almost everywhere, but in practice, most of the time the classes that use DECLARE_CLASS also inherit from CoreBaseObject, in which case the macro used should be DECLARE_POLYMORPHIC_CLASS. So don't trust the code base, trust the documentation instead.
#define DECLARE_POLYMORPHIC_BASE_CLASS
Value:
public: \
static const CoreClassInfo& class_info(); \
virtual inline const CoreClassInfo& get_class_info() const { return class_info(); }

Declare a class that does not inherit from CoreBaseObject and is meant to be inherited. It does the same as DECLARE_CLASS but the get_class_info method is marked as virtual. Classes that inherit from this one will need to use DECLARE_POLYMORPHIC_CLASS

#define DECLARE_POLYMORPHIC_CLASS
Value:
public: \
static const CoreClassInfo& class_info(); \
inline const CoreClassInfo& get_class_info() const override { return class_info(); }

Declare a class that inherits from CoreBaseObject either directly or indirectly. Works like DECLARE_CLASS but the get_class_info method is marked as override. See note on DECLARE_CLASS.

#define IMPLEMENT_BASE_CLASS (   class_name)
Value:
const CoreClassInfo& class_name::class_info() { \
static CoreClassInfo *class_info = CoreClassInfo::new_class( \
#class_name, \
nullptr \
); \
return *class_info; \
} \
const CoreClassInfo *__register_##class_name##_global_class_info__ = &class_name::class_info();

Implement a base class that doesn't inherit from any class.

#define IMPLEMENT_CLASS (   class_name,
  base_class_name 
)
Value:
#base_class_name " is not a base class of " #class_name); \
const CoreClassInfo& class_name::class_info() { \
static CoreClassInfo *class_info = CoreClassInfo::new_class( \
#class_name, \
&base_class_name::class_info() \
); \
return *class_info; \
} \
const CoreClassInfo *__register_##class_name##_global_class_info__ = &class_name::class_info();

Implement a class that inherits from another class.

#define IMPLEMENT_TEMPLATE_CLASS (   class_name,
  base_class_name,
  template_type 
)
Value:
template<template_type T> \
const char* class_name##_class_name() { \
return #class_name"<>"; \
} \
template<template_type T> \
const CoreClassInfo& class_name<T>::class_info() { \
static CoreClassInfo *class_info = CoreClassInfo::new_class( \
class_name##_class_name<T>(), \
&base_class_name::class_info() \
); \
return *class_info; \
}

Implement a template class that inherits from another class.

#define SPECIALIZE_TEMPLATE_CLASS (   class_name,
  type_name 
)
Value:
template<> \
inline const char* class_name##_class_name<type_name>() { \
return #class_name"<"#type_name">"; \
}

Specialize a template class for a given type.