cgv
Loading...
Searching...
No Matches
get_reflection_handler.h
1#pragma once
2
3#include "find_reflection_handler.h"
4#include <cgv/config/cpp_version.h>
5
6#include "lib_begin.h"
7
8namespace cgv {
9 namespace reflect {
10
13{
14protected:
15 void* value_ptr;
16 std::string value_type;
17 abst_reflection_traits* value_rt;
18public:
20 get_reflection_handler(const std::string& _target,
21 const std::string& _value_type,
22 void* _value_ptr,
23 abst_reflection_traits* _value_rt = 0);
25 get_reflection_handler(const std::string& _target, void* _value_ptr, abst_reflection_traits* _value_rt);
27 void process_member_void(const std::string& member_name, void* member_ptr,
28 abst_reflection_traits* rt, GroupKind group_kind, unsigned grp_size);
29};
30
31#ifdef REFLECT_TRAITS_WITH_DECLTYPE
33
37template <typename T, typename Q>
38 bool get_member(T& variable, const std::string& target, Q& value) {
40#else
41namespace compatibility {
42 template <typename T, typename Q, typename RQ>
43 bool get_member_impl(T& variable, const std::string& target, Q& value, RQ&) {
44 RQ rt_value;
45#endif
46 get_reflection_handler grh(target, &value, &rt_value);
47 grh.reflect_member("", variable);
48 return grh.found_valid_target();
49 }
50#ifndef REFLECT_TRAITS_WITH_DECLTYPE
51 template <bool use_get, typename T, typename Q>
52 struct get_member_dispatch { static bool get_member(T& variable, const std::string& target, Q& value) {
53 return get_member_impl(variable, target, value, reflection_traits<Q>()); } };
54 template <typename T, typename Q>
55 struct get_member_dispatch<true,T,Q> { static bool get_member(T& variable, const std::string& target, Q& value) {
56 return get_member_impl(variable, target, value, get_reflection_traits(value)); } };
57}
58
60
64template <typename T, typename Q>
65bool get_member(T& variable, const std::string& target, Q& value)
66{
68}
69#endif
70 }
71}
72
73#include <cgv/config/lib_end.h>
The cgv::reflect::find_reflection_hander steers traversal to a specific member and calls the virtual ...
provides access to a member variable of an instance.
GroupKind
different support group types
bool get_member(T &variable, const std::string &target, Q &value)
uses cgv::reflect::get_reflection_handler to copy the value of a member from an instance
the cgv namespace
Definition print.h:11
abstract interface for type reflection with basic type management and optional string conversion
the reflection_traits_info defines compile time information about reflection_traits for a given type ...
Default implementation of the reflection traits providing type specific interface.