Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
cofmeterconfigarray.h
1 /*
2  * cofmeterconfigarray.h
3  *
4  * Created on: 27.05.2014
5  * Author: andreas
6  */
7 
8 #ifndef COFMETERCONFIGARRAY_H_
9 #define COFMETERCONFIGARRAY_H_
10 
11 #include <iostream>
12 #include <map>
13 
14 #include "rofl/common/openflow/cofmeterconfig.h"
15 
16 namespace rofl {
17 namespace openflow {
18 
20 {
21 public:
22 
27  uint8_t ofp_version = OFP_VERSION_UNKNOWN);
28 
32  virtual
34 
39  const cofmeterconfigarray& mconfig);
40 
45  operator= (
46  const cofmeterconfigarray& mconfig);
47 
51  bool
52  operator== (
53  const cofmeterconfigarray& mconfig);
54 
59  operator+= (
60  const cofmeterconfigarray& mconfig);
61 
62 public:
63 
67  virtual size_t
68  length() const;
69 
73  virtual void
74  pack(uint8_t *buf = (uint8_t*)0, size_t buflen = 0);
75 
79  virtual void
80  unpack(uint8_t *buf, size_t buflen);
81 
82 public:
83 
87  size_t
88  size() const { return array.size(); };
89 
93  void
94  clear() { array.clear(); };
95 
99  uint8_t
100  get_version() const { return ofp_version; };
101 
105  void
106  set_version(uint8_t ofp_version) {
107  this->ofp_version = ofp_version;
108  for (std::map<unsigned int, cofmeter_config_reply>::iterator
109  it = array.begin(); it != array.end(); ++it) {
110  it->second.set_version(ofp_version);
111  }
112  };
113 
117  const std::map<unsigned int, cofmeter_config_reply>&
118  get_mconfig() const { return array; };
119 
123  std::map<unsigned int, cofmeter_config_reply>&
124  set_mconfig() { return array; };
125 
126 public:
127 
132  add_meter_config(
133  unsigned int index = 0);
134 
138  void
139  drop_meter_config(
140  unsigned int index = 0);
141 
146  set_meter_config(
147  unsigned int index = 0);
148 
152  const cofmeter_config_reply&
153  get_meter_config(
154  unsigned int index = 0) const;
155 
159  bool
160  has_meter_config(
161  unsigned int index = 0) const;
162 
163 public:
164 
165  friend std::ostream&
166  operator<< (std::ostream& os, cofmeterconfigarray const& mconfig) {
167  os << rofl::indent(0) << "<cofmeterconfigarray #meter-config:" << (int)mconfig.array.size() << " >" << std::endl;
168  rofl::indent i(2);
169  for (std::map<unsigned int, cofmeter_config_reply>::const_iterator
170  it = mconfig.array.begin(); it != mconfig.array.end(); ++it) {
171  os << it->second;
172  }
173  return os;
174  }
175 
176 private:
177 
178  uint8_t ofp_version;
179  std::map<unsigned int, cofmeter_config_reply> array;
180 };
181 
182 }; // end of openflow
183 }; // end of rofl
184 
185 
186 
187 #endif /* COFMETERCONFIGARRAY_H_ */
virtual size_t length() const
Definition: cofmeterconfigarray.cc:96
Definition: cofmeterconfigarray.h:19
Definition: cofmeterconfig.h:136
Definition: logging.h:76