cgv
Loading...
Searching...
No Matches
base_generator.cxx
1#include "base_generator.h"
2
3namespace cgv {
4 namespace base {
5
8{
9 return "base_generator";
10}
11
13void base_generator::add_void(const std::string& name, abst_property_access* apa)
14{
15 iter_type i = property_map.find(name);
16 if (i != property_map.end()) {
17 if (apa != i->second) {
18 delete i->second;
19 i->second = apa;
20 }
21 }
22 else
23 property_map[name] = apa;
24}
25
27{
28 for (auto& p : property_map) {
29 delete p.second;
30 p.second = 0;
31 }
32}
33
34
36void base_generator::del(const std::string& name)
37{
38 iter_type i = property_map.find(name);
39 if (i != property_map.end()) {
40 delete i->second;
41 property_map.erase(i);
42 }
43}
44
46bool base_generator::changed(const std::string& property) const
47{
48 const_iter_type i = property_map.find(property);
49 if (i == property_map.end())
50 return false;
51 return i->second->has_changed;
52}
53
56{
57 std::string res;
58 for (iter_type i = property_map.begin(); i != property_map.end(); ++i) {
59 if (!res.empty())
60 res += ';';
61 res += i->first+':'+i->second->get_type_name();
62 }
63 return res;
64}
65
67bool base_generator::set_void(const std::string& property, const std::string& value_type, const void* value_ptr)
68{
69 iter_type i = property_map.find(property);
70 if (i != property_map.end())
71 return i->second->set(value_type, value_ptr);
72 return false;
73}
74
76bool base_generator::get_void(const std::string& property, const std::string& value_type, void* value_ptr)
77{
78 iter_type i = property_map.find(property);
79 if (i != property_map.end())
80 return i->second->get(value_type, value_ptr);
81 return false;
82}
83
84 }
85}
virtual bool end()
perform the leave part of the action on the current object
Definition action.cxx:48
std::string get_property_declarations()
returns a semicolon separated list of property declarations
~base_generator()
during destruction free all memory allocated on heap
map_type property_map
store the properties as map from property name to type and pointer to instance
std::string get_type_name() const
overload to return the type name of this object. By default the type interface is queried over get_ty...
void add_void(const std::string &name, abst_property_access *apa)
add a new property
bool set_void(const std::string &property, const std::string &value_type, const void *value_ptr)
abstract interface for the setter of a dynamic property.
bool changed(const std::string &property) const
return whether property has changed
bool get_void(const std::string &property, const std::string &value_type, void *value_ptr)
abstract interface for the getter of a dynamic property.
void del(const std::string &property)
remove a property
complete implementation of method actions that only call one method when entering a node
Definition action.h:113
bool begin()
uses call_method of base class method_action to call the method refered to by the stored method point...
Definition action.h:122
the cgv namespace
Definition print.h:11