4#include <cgv/type/info/type_name.h>
5#include <cgv/type/info/type_id.h>
6#include <cgv/type/cond/is_enum.h>
7#include <cgv/type/cond/is_abstract.h>
17class CGV_API reflection_handler;
33 virtual unsigned size()
const = 0;
51 static const bool has_external =
false;
53 virtual bool has_external_implementation()
const;
61 static const bool has_string =
false;
63 virtual bool has_string_conversions()
const;
65 virtual bool set_from_string(
void* instance_ptr,
const std::string& str_val);
67 virtual void get_to_string(
const void* instance_ptr, std::string& str_val);
74 static const bool has_enum =
false;
76 virtual bool is_enum_type()
const;
78 virtual bool has_enum_interface()
const;
80 virtual unsigned get_nr_enum_items()
const;
82 virtual std::string get_enum_name(
unsigned i)
const;
84 virtual int get_enum_value(
unsigned i)
const;
93template <typename T, typename B, bool base_is_abst = cgv::type::cond::is_abstract<B>::value>
97 unsigned size()
const {
return sizeof(T); }
101 void delete_instance(
void* instance_ptr)
const {
delete static_cast<T*
>(instance_ptr); }
105 void delete_instances(
void* instance_array)
const {
delete []
static_cast<T*
>(instance_array); }
115template <
typename T,
typename B>
119 unsigned size()
const {
return sizeof(T); }
123 void delete_instance(
void* instance_ptr)
const {
delete static_cast<T*
>(instance_ptr); }
127 void delete_instances(
void* instance_array)
const {
delete []
static_cast<T*
>(instance_array); }
137template <
bool has_str,
typename T,
typename B>
143template <
typename T,
typename B>
147 static const bool has_string =
true;
149 bool has_string_conversions()
const {
return true; }
150 bool set_from_string(
void* member_ptr,
const std::string& str_val) {
153 void get_to_string(
const void* member_ptr, std::string& str_val) {
159template <
typename T, ReflectionTraitsKind KIND = RTK_STRING,
bool has_str = true>
170extern CGV_API reflection_traits<bool,RTK_STD_TYPE> get_reflection_traits(
const bool&);
178#include <cgv/config/lib_end.h>
the self reflection handler is passed to the virtual self_reflect() method of cgv::base::base.
Helper functions to convert numeric types into strings using std streams.
ReflectionTraitsKind
different types of reflection traits
TypeId
ids for the different types and type constructs
std::string to_string(const std::string &v, unsigned int w, unsigned int p, bool)
specialization of conversion from string to strings
bool from_string(std::string &v, const std::string &s)
specialization to extract string value from string
abstract interface for type reflection with basic type management and optional string conversion
virtual void delete_instances(void *) const =0
delete instances with the delete [] operator
virtual unsigned size() const =0
return the size of the type
virtual abst_reflection_traits * clone()=0
clone function
virtual void delete_instance(void *) const =0
delete an instance with the delete operator
virtual cgv::type::info::TypeId get_type_id() const =0
return the type id
virtual const char * get_type_name() const =0
return the type name
virtual void * new_instance() const =0
construct an instance on the heap with the new operator
virtual void * new_instances(unsigned n) const =0
construct n instances on the heap with the new operator
cgv::type::info::TypeId get_type_id() const
return the type id
void * new_instance() const
construct an instance on the heap with the new operator
bool is_enum_type() const
return whether type is an enum type - this is independent of whether enum interface is implemented
void delete_instance(void *instance_ptr) const
delete an instance with the delete operator
unsigned size() const
return the size of the type
void delete_instances(void *instance_array) const
delete instances with the delete [] operator
const char * get_type_name() const
return the type name
void * new_instances(unsigned n) const
construct n instances on the heap with the new operator
implementation of the reflection traits providing type specific interface for variable base class
void * new_instances(unsigned n) const
construct n instances on the heap with the new operator
void delete_instances(void *instance_array) const
delete instances with the delete [] operator
bool is_enum_type() const
return whether type is an enum type - this is independent of whether enum interface is implemented
unsigned size() const
return the size of the type
cgv::type::info::TypeId get_type_id() const
return the type id
const char * get_type_name() const
return the type name
void * new_instance() const
construct an instance on the heap with the new operator
void delete_instance(void *instance_ptr) const
delete an instance with the delete operator
this template allows to distinguish between traits with and without string conversions
Default implementation of the reflection traits providing type specific interface.
abst_reflection_traits * clone()
clone function
template condition returning, whether the given type is an enum type
template with a static member function get_id() of type TypeId returning the TypeId of the template a...
static const char * get_name()
return special name for standard types or type name from RTTI cleaned from keywords for all other typ...