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

The cgv::reflect::find_reflection_hander steers traversal to a specific member and calls the virtual function process_member() that can be overloaded by derived classes such as cgv::reflect::get_reflection_handler. More...

#include <find_reflection_handler.h>

Inheritance diagram for cgv::reflect::find_reflection_handler:
cgv::reflect::reflection_handler cgv::reflect::get_reflection_handler cgv::reflect::set_reflection_handler

Classes

struct  group_info
 

Public Member Functions

 find_reflection_handler (const std::string &_target)
 construct from textual target description
 
 find_reflection_handler (const void *_target_ptr, bool _traverse_matched_groups)
 construct from member pointer and boolean flag that tells whether groups should be traversed in case that group pointer matches target
 
bool found_target () const
 return whether target has been found
 
bool found_valid_target () const
 return whether a valid target has been found. The semantic of being valid is defined in derived classes.
 
void * get_member_ptr () const
 in case a valid target has been found, return a pointer to the member
 
const std::string & get_member_name () const
 in case a valid target has been found, return the name of the member
 
abst_reflection_traitsget_reflection_traits () const
 in case a valid target has been found, return a point to the reflection traits describing the type of the member
 
virtual void process_member_void (const std::string &member_name, void *member_ptr, abst_reflection_traits *rt, GroupKind group_kind=GK_NO_GROUP, unsigned grp_size=-1)
 virtual method that is overloaded by derived classes to handle the target member
 
int reflect_group_begin (GroupKind group_kind, const std::string &group_name, void *group_ptr, abst_reflection_traits *rt, unsigned grp_size)
 overload to navigate grouped reflection information
 
void reflect_group_end (GroupKind group_kind)
 ensure that matched group pointers are found also in case that groups are traversed further and no group member corresponds to target pointer
 
bool reflect_member_void (const std::string &member_name, void *member_ptr, abst_reflection_traits *rt)
 check for target during member reflection
 
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)
 ignore methods
 
- 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
 

Protected Member Functions

void push_group (const std::string &_group_name, void *_group_ptr, abst_reflection_traits *_rt, GroupKind _group_kind, unsigned _group_size=-1)
 
void check_for_index_increment ()
 
- 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
 

Protected Attributes

const std::string * target
 
const void * target_ptr
 
bool traverse_matched_groups
 
std::vector< group_infotraversed_groups
 
std::vector< std::string > target_tokens
 
bool found
 
bool valid
 
std::string member_name
 
abst_reflection_traitsrt
 
void * member_ptr
 
GroupKind group_kind
 
unsigned grp_size
 
- Protected Attributes inherited from cgv::reflect::reflection_handler
std::vector< nesting_infonesting_info_stack
 stack of nesting_info used during the reflection process
 

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
 

Detailed Description

The cgv::reflect::find_reflection_hander steers traversal to a specific member and calls the virtual function process_member() that can be overloaded by derived classes such as cgv::reflect::get_reflection_handler.

The target member is specified in the constructor by a string. This can be either directly the name of the member or recursively use the dot and array operators to access members of members or elements of array members. A typical example could be complex_pnt_arr[4].x.re. Here the real part of the x coordinate of the 5th (indices start with 0) point is addressed.

Definition at line 18 of file find_reflection_handler.h.

Constructor & Destructor Documentation

◆ find_reflection_handler() [1/2]

cgv::reflect::find_reflection_handler::find_reflection_handler ( const std::string &  _target)

construct from textual target description

Definition at line 27 of file find_reflection_handler.cxx.

References cgv::utils::tokenizer::set_sep(), cgv::utils::tokenizer::set_skip(), and cgv::utils::tokenizer::set_ws().

◆ find_reflection_handler() [2/2]

cgv::reflect::find_reflection_handler::find_reflection_handler ( const void *  _target_ptr,
bool  _traverse_matched_groups 
)

construct from member pointer and boolean flag that tells whether groups should be traversed in case that group pointer matches target

Definition at line 34 of file find_reflection_handler.cxx.

◆ ~find_reflection_handler()

cgv::reflect::find_reflection_handler::~find_reflection_handler ( )

Definition at line 40 of file find_reflection_handler.cxx.

Member Function Documentation

◆ check_for_index_increment()

void cgv::reflect::find_reflection_handler::check_for_index_increment ( )
protected

Definition at line 321 of file find_reflection_handler.cxx.

◆ found_target()

bool cgv::reflect::find_reflection_handler::found_target ( ) const

return whether target has been found

Definition at line 47 of file find_reflection_handler.cxx.

◆ found_valid_target()

bool cgv::reflect::find_reflection_handler::found_valid_target ( ) const

return whether a valid target has been found. The semantic of being valid is defined in derived classes.

Definition at line 53 of file find_reflection_handler.cxx.

◆ get_member_name()

const std::string & cgv::reflect::find_reflection_handler::get_member_name ( ) const

in case a valid target has been found, return the name of the member

Definition at line 66 of file find_reflection_handler.cxx.

◆ get_member_ptr()

void * cgv::reflect::find_reflection_handler::get_member_ptr ( ) const

in case a valid target has been found, return a pointer to the member

Definition at line 59 of file find_reflection_handler.cxx.

◆ get_reflection_traits()

abst_reflection_traits * cgv::reflect::find_reflection_handler::get_reflection_traits ( ) const

in case a valid target has been found, return a point to the reflection traits describing the type of the member

Definition at line 72 of file find_reflection_handler.cxx.

◆ process_member_void()

void cgv::reflect::find_reflection_handler::process_member_void ( const std::string &  member_name,
void *  member_ptr,
abst_reflection_traits rt,
GroupKind  group_kind = GK_NO_GROUP,
unsigned  grp_size = -1 
)
virtual

◆ push_group()

void cgv::reflect::find_reflection_handler::push_group ( const std::string &  _group_name,
void *  _group_ptr,
abst_reflection_traits _rt,
GroupKind  _group_kind,
unsigned  _group_size = -1 
)
protected

Definition at line 117 of file find_reflection_handler.cxx.

◆ reflect_group_begin()

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

overload to navigate grouped reflection information

Reimplemented from cgv::reflect::reflection_handler.

Definition at line 128 of file find_reflection_handler.cxx.

References cgv::reflect::abst_reflection_traits::get_type_name(), cgv::utils::is_integer(), and process_member_void().

◆ reflect_group_end()

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

ensure that matched group pointers are found also in case that groups are traversed further and no group member corresponds to target pointer

Reimplemented from cgv::reflect::reflection_handler.

Definition at line 97 of file find_reflection_handler.cxx.

References process_member_void().

◆ reflect_member_void()

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

check for target during member reflection

Implements cgv::reflect::reflection_handler.

Definition at line 336 of file find_reflection_handler.cxx.

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

◆ reflect_method_void()

bool cgv::reflect::find_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

ignore methods

Implements cgv::reflect::reflection_handler.

Definition at line 361 of file find_reflection_handler.cxx.

Member Data Documentation

◆ found

bool cgv::reflect::find_reflection_handler::found
protected

Definition at line 41 of file find_reflection_handler.h.

◆ group_kind

GroupKind cgv::reflect::find_reflection_handler::group_kind
protected

Definition at line 46 of file find_reflection_handler.h.

◆ grp_size

unsigned cgv::reflect::find_reflection_handler::grp_size
protected

Definition at line 47 of file find_reflection_handler.h.

◆ member_name

std::string cgv::reflect::find_reflection_handler::member_name
protected

Definition at line 43 of file find_reflection_handler.h.

◆ member_ptr

void* cgv::reflect::find_reflection_handler::member_ptr
protected

Definition at line 45 of file find_reflection_handler.h.

◆ rt

abst_reflection_traits* cgv::reflect::find_reflection_handler::rt
protected

Definition at line 44 of file find_reflection_handler.h.

◆ target

const std::string* cgv::reflect::find_reflection_handler::target
protected

Definition at line 27 of file find_reflection_handler.h.

◆ target_ptr

const void* cgv::reflect::find_reflection_handler::target_ptr
protected

Definition at line 28 of file find_reflection_handler.h.

◆ target_tokens

std::vector<std::string> cgv::reflect::find_reflection_handler::target_tokens
protected

Definition at line 40 of file find_reflection_handler.h.

◆ traverse_matched_groups

bool cgv::reflect::find_reflection_handler::traverse_matched_groups
protected

Definition at line 36 of file find_reflection_handler.h.

◆ traversed_groups

std::vector<group_info> cgv::reflect::find_reflection_handler::traversed_groups
protected

Definition at line 37 of file find_reflection_handler.h.

◆ valid

bool cgv::reflect::find_reflection_handler::valid
protected

Definition at line 42 of file find_reflection_handler.h.


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