cgv
Loading...
Searching...
No Matches
set_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
12{
13protected:
14 const void* value_ptr;
15 std::string value_type;
16 abst_reflection_traits* value_rt;
17public:
19 bool is_creative() const;
21 set_reflection_handler(const std::string& _target,
22 const std::string& _value_type,
23 const void* _value_ptr,
24 abst_reflection_traits* _value_rt = 0);
26 set_reflection_handler(const std::string& _target, const void* _value_ptr, abst_reflection_traits* _value_rt);
28 void process_member_void(const std::string& member_name, void* member_ptr,
29 abst_reflection_traits* rt, GroupKind group_kind, unsigned grp_size);
30};
31
32#ifdef REFLECT_TRAITS_WITH_DECLTYPE
34template <typename T, typename Q>
35 bool set_member(T& variable, const std::string& target, const Q& value) {
37#else
38namespace compatibility {
39 template <typename T, typename Q, typename RQ>
40 bool set_member_impl(T& variable, const std::string& target, const Q& value, const RQ&)
41 {
42 RQ rt_value;
43#endif
44 set_reflection_handler srh(target, &value, &rt_value);
45 srh.reflect_member("", variable);
46 return srh.found_target();
47 }
48#ifndef REFLECT_TRAITS_WITH_DECLTYPE
49 template <bool use_get, typename T, typename Q>
50 struct set_member_dispatch { static bool set_member(T& variable, const std::string& target, const Q& value) {
51 return set_member_impl(variable, target, value, reflection_traits<Q>()); } };
52 template <typename T, typename Q>
53 struct set_member_dispatch<true,T,Q> { static bool set_member(T& variable, const std::string& target, const Q& value) {
54 return set_member_impl(variable, target, value, get_reflection_traits(value)); } };
55}
56
57template <typename T, typename Q>
58bool set_member(T& variable, const std::string& target, const Q& value)
59{
60 return compatibility::set_member_dispatch<reflection_traits_info<Q>::use_get,T,Q>::set_member(variable, target, value);
61}
62#endif
63
64 }
65}
66
67#include <cgv/config/lib_end.h>
The cgv::reflect::find_reflection_hander steers traversal to a specific member and calls the virtual ...
GroupKind
different support group types
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.