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>
10 #include "lib_begin.h"
17 class CGV_API reflection_handler;
32 virtual unsigned size()
const = 0;
50 static const bool has_external =
false;
53 virtual bool has_external_implementation()
const;
60 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);
73 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;
92 template <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); }
115 template <
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); }
137 template <
bool has_str,
typename T,
typename B>
143 template <
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) {
159 template <
typename T, ReflectionTraitsKind KIND = RTK_STRING,
bool has_str = true>
170 extern CGV_API reflection_traits<bool,RTK_STD_TYPE> get_reflection_traits(
const bool&);
178 #include <cgv/config/lib_end.h>
virtual abst_reflection_traits * clone()=0
clone function
virtual void delete_instance(void *) const =0
delete an instance with the delete operator
virtual void delete_instances(void *) const =0
delete instances with the delete [] operator
TypeId
ids for the different types and type constructs
Definition: type_id.h:12
cgv::type::info::TypeId get_type_id() const
return the type id
Definition: reflection_traits.h:107
unsigned size() const
return the size of the type
Definition: reflection_traits.h:97
void delete_instances(void *instance_array) const
delete instances with the delete [] operator
Definition: reflection_traits.h:105
abstract interface for type reflection with basic type management and optional string conversion
Definition: reflection_traits.h:24
void * new_instance() const
construct an instance on the heap with the new operator
Definition: reflection_traits.h:121
void delete_instance(void *instance_ptr) const
delete an instance with the delete operator
Definition: reflection_traits.h:101
abst_reflection_traits * clone()
clone function
Definition: reflection_traits.h:164
implementation of the reflection traits providing type specific interface for variable base class
Definition: reflection_traits.h:95
bool is_enum_type() const
return whether type is an enum type - this is independent of whether enum interface is implemented
Definition: reflection_traits.h:133
virtual cgv::type::info::TypeId get_type_id() const =0
return the type id
cgv::type::info::TypeId get_type_id() const
return the type id
Definition: reflection_traits.h:129
void * new_instances(unsigned n) const
construct n instances on the heap with the new operator
Definition: reflection_traits.h:125
static const char * get_name()
return special name for standard types or type name from RTTI cleaned from keywords for all other typ...
Definition: type_name.h:56
const char * get_type_name() const
return the type name
Definition: reflection_traits.h:131
bool from_string(std::string &v, const std::string &s)
specialization to extract string value from string
Definition: convert_string.cxx:13
void * new_instances(unsigned n) const
construct n instances on the heap with the new operator
Definition: reflection_traits.h:103
ReflectionTraitsKind
different types of reflection traits
Definition: reflection_traits.h:20
const char * get_type_name() const
return the type name
Definition: reflection_traits.h:109
void delete_instances(void *instance_array) const
delete instances with the delete [] operator
Definition: reflection_traits.h:127
void * new_instance() const
construct an instance on the heap with the new operator
Definition: reflection_traits.h:99
virtual void * new_instances(unsigned n) const =0
construct n instances on the heap with the new operator
Definition: reflection_handler.h:63
void delete_instance(void *instance_ptr) const
delete an instance with the delete operator
Definition: reflection_traits.h:123
Default implementation of the reflection traits providing type specific interface.
Definition: reflection_traits.h:161
template with a static member function get_id() of type TypeId returning the TypeId of the template a...
Definition: type_id.h:86
template condition returning, whether the given type is an enum type
Definition: is_enum.h:14
vec< T > reflect(const vec< T > &v, const vec< T > &n)
calculates the reflected direction of v; n is the normal of the reflecting surface
Definition: vec.h:822
virtual void * new_instance() const =0
construct an instance on the heap with the new operator
this template allows to distinguish between traits with and without string conversions
Definition: reflection_traits.h:139
unsigned size() const
return the size of the type
Definition: reflection_traits.h:119
bool is_enum_type() const
return whether type is an enum type - this is independent of whether enum interface is implemented
Definition: reflection_traits.h:111
std::string to_string(const std::string &v, unsigned int w, unsigned int p)
specialization of conversion from string to strings
Definition: convert_string.cxx:7
the cgv namespace
Definition: vr_calib.cxx:9
virtual const char * get_type_name() const =0
return the type name