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>
33 virtual unsigned size()
const = 0;
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);
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); }
111 bool is_enum_type()
const {
return cgv::type::cond::is_enum<T>::value; }
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); }
133 bool is_enum_type()
const {
return cgv::type::cond::is_enum<T>::value; }
137template <
bool has_str,
typename T,
typename B>
143template <
typename T,
typename B>
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.
in this namespace reflection of types is implemented
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
this header is dependency free
abstract interface for type reflection with basic type management and optional string conversion
virtual std::string get_enum_name(unsigned i) const
return the name of the i-th enum item
static const bool has_external
compile information about external implementation
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 bool is_enum_type() const
return whether type is an enum type - this is independent of whether enum interface is implemented
virtual abst_reflection_traits * clone()=0
clone function
virtual bool has_string_conversions() const
whether type can be converted to string, defaults to false
virtual void delete_instance(void *) const =0
delete an instance with the delete operator
virtual int get_enum_value(unsigned i) const
return the value of the i-th enum item
virtual cgv::type::info::TypeId get_type_id() const =0
return the type id
virtual bool has_external_implementation() const
whether type can be converted to string, defaults to false
virtual const char * get_type_name() const =0
return the type name
static const bool has_string
compile information about string conversions
virtual void * new_instance() const =0
construct an instance on the heap with the new operator
virtual void get_to_string(const void *instance_ptr, std::string &str_val)
convert given instance into a string value
virtual void * new_instances(unsigned n) const =0
construct n instances on the heap with the new operator
virtual bool has_enum_interface() const
return whether the traits class implements the enum interface
static const bool has_enum
compile information about enum interface
virtual bool external_implementation(reflection_handler &rh, void *member_ptr)
call the external implementation
virtual bool set_from_string(void *instance_ptr, const std::string &str_val)
convert a given string value to the reflected type and store in the instance pointer
virtual unsigned get_nr_enum_items() const
return the number of enum items
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
static const bool has_string
compile information about string conversions
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
static const char * get_name()
return special name for standard types or type name from RTTI cleaned from keywords for all other typ...