cgv
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 
8 namespace cgv {
9  namespace reflect {
10 
13 {
14 protected:
15  void* value_ptr;
16  std::string value_type;
17  abst_reflection_traits* value_rt;
18 public:
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
32 
37 template <typename T, typename Q>
38  bool get_member(T& variable, const std::string& target, Q& value) {
40 #else
41 namespace 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 
64 template <typename T, typename Q>
65 bool get_member(T& variable, const std::string& target, Q& value)
66 {
67  return compatibility::get_member_dispatch<reflection_traits_info<Q>::use_get,T,Q>::get_member(variable, target, value);
68 }
69 #endif
70  }
71 }
72 
73 #include <cgv/config/lib_end.h>
cgv::reflect::find_reflection_handler
Definition: find_reflection_handler.h:19
cgv::reflect::abst_reflection_traits
abstract interface for type reflection with basic type management and optional string conversion
Definition: reflection_traits.h:24
cgv::reflect::reflection_traits_info
the reflection_traits_info defines compile time information about reflection_traits for a given type ...
Definition: reflection_traits_info.h:54
cgv::reflect::reflection_handler::GroupKind
GroupKind
different support group types
Definition: reflection_handler.h:85
cgv::reflect::get_reflection_handler
Definition: get_reflection_handler.h:13
cgv::math::reflect
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
cgv::reflect::get_member
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
Definition: get_reflection_handler.h:65
cgv
the cgv namespace
Definition: vr_calib.cxx:9