tue_config
map.h
Go to the documentation of this file.
1 #ifndef TUE_CONFIG_MAP_H_
2 #define TUE_CONFIG_MAP_H_
3 
4 #include "node.h"
5 
6 namespace tue
7 {
8 
9 namespace config
10 {
11 
12 class Map : public Node
13 {
14 
15 public:
16 
17  Map(const Label& name) : Node(name, MAP) {}
18 
19  bool readGroup(const Label& label, NodeIdx& idx) const
20  {
22  if (it == map_.end())
23  return false;
24 
25  idx = it->second;
26  return true;
27  }
28 
29  bool value(const Label& label, Variant& value) const
30  {
32  if (it == values.end())
33  return false;
34 
35  value = it->second;
36  return true;
37  }
38 
39  // add a new group with label "label". Overwrites a group if it exsist with the same label.
40  bool addGroup(const Label& label, const NodeIdx& n, NodeIdx& idx)
41  {
42  map_[label] = n;
43  idx = n;
44  return true;
45  }
46 
47  bool setValue(const Label& label, const Variant& value)
48  {
49  values[label] = value;
50  return true;
51  }
52 
53  virtual bool empty() const
54  {
55  return (map_.empty() && values.empty());
56  }
57 
58  // --- COPY
59 
60  NodePtr deepCopy(const Data& source, NodeIdx target_idx, Data& target) const;
61 
63 
65 
66 };
67 
68 }
69 
70 } // end namespace tue
71 
72 #endif
tue::config::Map::Map
Map(const Label &name)
Definition: map.h:17
std::string
tue::config::Map::readGroup
bool readGroup(const Label &label, NodeIdx &idx) const
Definition: map.h:19
tue::config::NodeIdx
unsigned int NodeIdx
Definition: data_pointer.h:12
tue::config::Map::map_
std::map< Label, NodeIdx > map_
Definition: map.h:62
tue::config::Map
Definition: map.h:12
tue::config::Node
Definition: node.h:19
node.h
std::map
tue::config::Map::value
bool value(const Label &label, Variant &value) const
Definition: map.h:29
tue::config::Data
Definition: data.h:17
tue::config::Map::setValue
bool setValue(const Label &label, const Variant &value)
Definition: map.h:47
tue::config::MAP
@ MAP
Definition: node_type.h:12
tue::config::NodePtr
boost::shared_ptr< Node > NodePtr
Definition: types.h:21
tue::config::Map::empty
virtual bool empty() const
Definition: map.h:53
tue::config::Map::values
std::map< Label, Variant > values
Definition: map.h:64
tue::config::Node::name
const Label & name() const
Definition: node.h:54
tue::config::Map::addGroup
bool addGroup(const Label &label, const NodeIdx &n, NodeIdx &idx)
Definition: map.h:40
tue::config::Map::deepCopy
NodePtr deepCopy(const Data &source, NodeIdx target_idx, Data &target) const
Definition: map.cpp:10
tue
tue::config::Variant
Definition: variant.h:111
config
tue::config::ReaderWriter config
Definition: sdf_gtest.cpp:9