4 #include <cgv/type/variant.h>
16 struct CGV_API abst_property_access
19 abst_property_access();
21 virtual bool set(
const std::string& value_type,
const void* value_ptr) = 0;
22 virtual bool get(
const std::string& value_type,
void* value_ptr) = 0;
26 struct standard_type_property_access :
public abst_property_access
29 standard_type_property_access(T* _ptr) : ptr(_ptr) {}
31 bool set(
const std::string& value_type,
const void* value_ptr) { get_variant(*ptr,value_type,value_ptr); has_changed =
true;
return true; }
32 bool get(
const std::string& value_type,
void* value_ptr) { set_variant(*ptr,value_type,value_ptr);
return true; }
36 struct emulated_property_access :
public abst_property_access
39 emulated_property_access(T* _ptr) : ptr(_ptr) {}
41 bool set(
const std::string& value_type,
const void* value_ptr) {
43 *ptr = *((
const T*) value_ptr);
47 else if (value_type ==
"string") {
52 bool get(
const std::string& value_type,
void* value_ptr) {
54 *((T*) value_ptr) = *ptr;
57 else if (value_type ==
"string") {
65 struct property_access :
public emulated_property_access<T>
67 property_access(T* _ptr) : emulated_property_access<T>(_ptr) {}
70 template <>
struct property_access<
int8_type> :
public standard_type_property_access<int8_type> { property_access<int8_type>(
int8_type* _ptr) : standard_type_property_access<
int8_type>(_ptr) {}; };
71 template <>
struct property_access<
int16_type> :
public standard_type_property_access<int16_type> { property_access<int16_type>(
int16_type* _ptr) : standard_type_property_access<
int16_type>(_ptr) {}; };
72 template <>
struct property_access<
int32_type> :
public standard_type_property_access<int32_type> { property_access<int32_type>(
int32_type* _ptr) : standard_type_property_access<
int32_type>(_ptr) {}; };
73 template <>
struct property_access<
int64_type> :
public standard_type_property_access<int64_type> { property_access<int64_type>(
int64_type* _ptr) : standard_type_property_access<
int64_type>(_ptr) {}; };
74 template <>
struct property_access<
uint8_type> :
public standard_type_property_access<uint8_type> { property_access<uint8_type>(
uint8_type* _ptr) : standard_type_property_access<
uint8_type>(_ptr) {}; };
75 template <>
struct property_access<
uint16_type> :
public standard_type_property_access<uint16_type> { property_access<uint16_type>(
uint16_type* _ptr) : standard_type_property_access<
uint16_type>(_ptr) {}; };
76 template <>
struct property_access<
uint32_type> :
public standard_type_property_access<uint32_type> { property_access<uint32_type>(
uint32_type* _ptr) : standard_type_property_access<
uint32_type>(_ptr) {}; };
77 template <>
struct property_access<
uint64_type> :
public standard_type_property_access<uint64_type> { property_access<uint64_type>(
uint64_type* _ptr) : standard_type_property_access<
uint64_type>(_ptr) {}; };
78 template <>
struct property_access<float> :
public standard_type_property_access<float> { property_access<float>(
float* _ptr) : standard_type_property_access<float>(_ptr) {}; };
79 template <>
struct property_access<double> :
public standard_type_property_access<double> { property_access<double>(
double* _ptr) : standard_type_property_access<double>(_ptr) {}; };
80 template <>
struct property_access<bool> :
public standard_type_property_access<bool> { property_access<bool>(
bool* _ptr) : standard_type_property_access<bool>(_ptr) {}; };
81 template <>
struct property_access<std::string> :
public standard_type_property_access<std::string> { property_access<std::string>(std::string* _ptr) : standard_type_property_access<std::string>(_ptr) {}; };
89 typedef std::map<std::string,abst_property_access*> map_type;
90 typedef map_type::iterator iter_type;
91 typedef map_type::const_iterator const_iter_type;
96 std::string get_type_name()
const;
98 void add_void(
const std::string& name, abst_property_access* apa);
100 template <
typename T>
101 void add(
const std::string& property, T& value) { add_void(property,
new property_access<T>(&value)); }
103 void del(
const std::string& property);
105 bool changed(
const std::string& property)
const;
107 std::string get_property_declarations();
109 bool set_void(
const std::string& property,
const std::string& value_type,
const void* value_ptr);
111 bool get_void(
const std::string& property,
const std::string& value_type,
void* value_ptr);
128 template <
typename T>
129 bool has_property(
const std::string& options,
const std::string& property, T& value,
bool report_error =
true) {
131 bg.
add(property, value);
140 #include <cgv/config/lib_end.h>