cgv
Loading...
Searching...
No Matches
cgv::reflect::debug_reflection_handler Class Reference

the debug reflection handler generates a string in the member output that contains a complete description of the reflected instance More...

#include <debug_reflection_handler.h>

Inheritance diagram for cgv::reflect::debug_reflection_handler:
cgv::reflect::reflection_handler

Public Member Functions

int reflect_group_begin (GroupKind group_kind, const std::string &group_name, void *group_ptr, abst_reflection_traits *rt, unsigned grp_size)
 abstract interface to start reflection of a group of members.
 
void reflect_group_end (GroupKind group_kind)
 abstract interface to start reflection of a group of members
 
bool reflect_member_void (const std::string &member_name, void *member_ptr, abst_reflection_traits *rt)
 abstract interface to reflect a member variable, where the member type is specified as a string.
 
bool reflect_method_void (const std::string &method_name, method_interface *mi_ptr, abst_reflection_traits *return_traits, const std::vector< abst_reflection_traits * > &param_value_traits)
 empty implementation
 
- Public Member Functions inherited from cgv::reflect::reflection_handler
virtual bool is_creative () const
 give information on whether reflection_handler creates object (defaults to false)
 
template<typename T >
bool reflect_member (const std::string &member_name, T &member_ref, bool hard_cast=false)
 call this to reflect a member by member name and reference to the member.
 
template<typename M >
bool reflect_method (const std::string &method_name, M m)
 call this to reflect a method by method name and reference to the member.
 
template<typename B >
bool reflect_base (B &base_ref)
 reflect a base class with its members
 
template<typename T , unsigned n>
bool reflect_member (const std::string &member_name, T(&member_ref)[n])
 reflect a member of constant size array type
 
template<typename T >
bool reflect_member (const std::string &member_name, std::vector< T > &member_ref)
 reflect a member of vector type
 
template<typename T >
bool reflect_member (const std::string &member_name, T *&member_ref)
 reflect a member of pointer type.
 
template<typename T , typename S >
bool reflect_array (const std::string &member_name, T *&member_ref, S &size)
 reflect a dynamic array member of vector type
 
virtual ~reflection_handler ()
 declare virtual destructor
 

Public Attributes

std::string output
 contains the description in form of a string
 

Protected Member Functions

std::string extend_name (const std::string &name) const
 
- Protected Member Functions inherited from cgv::reflect::reflection_handler
GroupTraversal process_structural_group_begin (GroupKind gk, const std::string &member_name, GroupTraversal gt)
 type independent part of the reflect_group method that starts the group traversal
 
bool group_end (GroupKind gk)
 updates the nesting info at the end of group and always returns true
 
template<typename T , typename RT , typename D >
bool self_reflect_member (const std::string &member_name, T &member_ref, const RT &, const D &, bool hard_cast)
 implementation of reflection with internal or external self_reflect function
 
int reflect_array_begin (GroupKind group_kind, const std::string &group_name, void *group_ptr, abst_reflection_traits *rt, unsigned grp_size)
 type independent functionality of array reflection
 

Additional Inherited Members

- Public Types inherited from cgv::reflect::reflection_handler
enum  GroupTraversal { GT_TERMINATE = -3 , GT_SKIP = -2 , GT_COMPLETE = -1 }
 @ basic types with helper functions More...
 
enum  GroupKind {
  GK_NO_GROUP , GK_BASE_CLASS , GK_STRUCTURE , GK_VECTOR ,
  GK_ARRAY , GK_POINTER
}
 different support group types More...
 
- Static Public Member Functions inherited from cgv::reflect::reflection_handler
static std::string group_traversal_name (GroupTraversal gt)
 return the group traversals as a string
 
static const char * group_kind_name (GroupKind gk)
 return the group kind as a string
 
static bool is_array_kind (GroupKind gk)
 check whether a group kind is of array or vector kind
 
- Protected Attributes inherited from cgv::reflect::reflection_handler
std::vector< nesting_infonesting_info_stack
 stack of nesting_info used during the reflection process
 

Detailed Description

the debug reflection handler generates a string in the member output that contains a complete description of the reflected instance

Definition at line 12 of file debug_reflection_handler.h.

Member Function Documentation

◆ extend_name()

std::string cgv::reflect::debug_reflection_handler::extend_name ( const std::string &  name) const
protected

Definition at line 9 of file debug_reflection_handler.cxx.

◆ reflect_group_begin()

int cgv::reflect::debug_reflection_handler::reflect_group_begin ( GroupKind  group_kind,
const std::string &  group_name,
void *  group_ptr,
abst_reflection_traits rt,
unsigned  grp_size 
)
virtual

abstract interface to start reflection of a group of members.

The return value gives information about further traversal of the group:

  • GT_TERMINATE ... terminate traversal completely
  • GT_SKIP ... skip traversal of group
  • GT_COMPLETE ... traverse group completely
  • index i >= 0 ... traverse only the i-th member of the group. Depending on the group kind, the remaining parameters are given as follows:
  • GK_BASE_CLASS ... group_name and grp_size are undefined, group_ptr is pointer to instance of base class, rt reflects base class
  • GK_STRUCTURE ... group_name is instance name, group_ptr is pointer to instance, rt reflects type of structure, grp_size is undefined,
  • GK_VECTOR ... group_name is vector name, group_ptr is pointer to vector data structure, rt reflects element type, grp_size is size of vector
  • GK_ARRAY ... group_name is array name, group_ptr is pointer to first array element, rt reflects element type, grp_size is size of array.
  • GK_POINTER ... group_name is pointer name, group_ptr is pointer to first array element, rt reflects type to which pointer poits, grp_size is undefined.

Reimplemented from cgv::reflect::reflection_handler.

Definition at line 33 of file debug_reflection_handler.cxx.

References cgv::reflect::abst_reflection_traits::get_to_string(), cgv::reflect::abst_reflection_traits::get_type_name(), cgv::reflect::reflection_handler::group_kind_name(), cgv::reflect::abst_reflection_traits::has_string_conversions(), output, and cgv::utils::to_string().

◆ reflect_group_end()

void cgv::reflect::debug_reflection_handler::reflect_group_end ( GroupKind  group_kind)
virtual

abstract interface to start reflection of a group of members

Reimplemented from cgv::reflect::reflection_handler.

Definition at line 67 of file debug_reflection_handler.cxx.

◆ reflect_member_void()

bool cgv::reflect::debug_reflection_handler::reflect_member_void ( const std::string &  member_name,
void *  member_ptr,
abst_reflection_traits rt 
)
virtual

◆ reflect_method_void()

bool cgv::reflect::debug_reflection_handler::reflect_method_void ( const std::string &  method_name,
method_interface mi_ptr,
abst_reflection_traits return_traits,
const std::vector< abst_reflection_traits * > &  param_value_traits 
)
virtual

empty implementation

Implements cgv::reflect::reflection_handler.

Definition at line 95 of file debug_reflection_handler.cxx.

References cgv::reflect::abst_reflection_traits::get_type_name(), and output.

Member Data Documentation

◆ output

std::string cgv::reflect::debug_reflection_handler::output

contains the description in form of a string

Definition at line 20 of file debug_reflection_handler.h.

Referenced by reflect_group_begin(), reflect_member_void(), and reflect_method_void().


The documentation for this class was generated from the following files: