blob: 467fb702fe2b6bca2c0decc22c8645c080474aa4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information.
#ifndef INCLUDED_GRAS_DETAIL_PROPERTY_HPP
#define INCLUDED_GRAS_DETAIL_PROPERTY_HPP
#include <PMC/PMC.hpp>
namespace gras
{
struct PropertyRegistry
{
PropertyRegistry(void){}
~PropertyRegistry(void){}
virtual void set(const PMCC &) = 0;
virtual PMCC get(void) = 0;
};
template <typename ClassType, typename ValueType>
struct PropertyRegistryImpl : PropertyRegistry
{
PropertyRegistryImpl(
ClassType *my_class,
ValueType(ClassType::*getter)(void),
void(ClassType::*setter)(const ValueType &)
):
_my_class(my_class),
_getter(getter),
_setter(setter)
{}
~PropertyRegistryImpl(void){}
void set(const PMCC &value)
{
return _setter(_my_class, value.as<ValueType>());
}
PMCC get(void)
{
return PMC_M(_getter(_my_class));
}
ClassType *_my_class;
ValueType(ClassType::*_getter)(void);
void(ClassType::*_setter)(const ValueType &);
};
struct PropertyInterface
{
virtual void property_interface_register(
const std::string &key,
boost::shared_ptr<PropertyRegistry> pr
) = 0;
virtual void property_interface_set(const std::string &key, const PMCC &value) = 0;
virtual PMCC property_interface_get(const std::string &key) = 0;
};
} //namespace gras
#endif /*INCLUDED_GRAS_DETAIL_PROPERTY_HPP*/
|