Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
cofmeterbandstatsarray.h
1 /*
2  * cofmeterbandstatsarray.h
3  *
4  * Created on: 25.05.2014
5  * Author: andreas
6  */
7 
8 #ifndef COFMETERBANDSTATSARRAY_H_
9 #define COFMETERBANDSTATSARRAY_H_
10 
11 #include <inttypes.h>
12 #include <iostream>
13 #include <map>
14 
15 #include "rofl/common/openflow/openflow_rofl_exceptions.h"
16 #include "rofl/common/openflow/openflow.h"
17 #include "rofl/common/openflow/cofmeterbandstats.h"
18 #include "rofl/common/logging.h"
19 
20 namespace rofl {
21 namespace openflow {
22 
24 public:
25 
30  uint8_t of_version = rofl::openflow::OFP_VERSION_UNKNOWN);
31 
36 
41  const cofmeter_band_stats_array& array);
42 
47  operator= (
48  const cofmeter_band_stats_array& array);
49 
53  const bool
54  operator== (
55  const cofmeter_band_stats_array& array) const;
56 
57 public:
58 
62  void
63  clear();
64 
68  void
69  set_version(uint8_t of_version) {
70  this->of_version = of_version;
71  for (std::map<unsigned int, cofmeter_band_stats>::iterator
72  it = array.begin(); it != array.end(); ++it) {
73  it->second.set_version(of_version);
74  }
75  };
76 
80  uint8_t
81  get_version() const { return of_version; };
82 
86  std::map<unsigned int, cofmeter_band_stats>&
87  set_mbs_array() { return array; };
88 
92  const std::map<unsigned int, cofmeter_band_stats>&
93  get_mbs_array() const { return array; };
94 
99  add_mbstats(unsigned int index = 0);
100 
105  set_mbstats(unsigned int index = 0);
106 
110  void
111  drop_mbstats(unsigned int index = 0);
112 
116  const cofmeter_band_stats&
117  get_mbstats(unsigned int index = 0) const;
118 
122  const bool
123  has_mbstats(unsigned int index = 0) const;
124 
125 public:
126 
130  size_t
131  length() const;
132 
136  void
137  pack(uint8_t* buf, size_t buflen);
138 
142  void
143  unpack(uint8_t* buf, size_t buflen);
144 
145 public:
146 
147  friend std::ostream&
148  operator<< (std::ostream& os, const cofmeter_band_stats_array& array) {
149  os << rofl::indent(0) << "<cofmeter_band_stats_array #stats: "
150  << array.get_mbs_array().size() << " >" << std::endl;
151  rofl::indent i(2);
152  for (std::map<unsigned int, cofmeter_band_stats>::const_iterator
153  it = array.get_mbs_array().begin(); it != array.get_mbs_array().end(); ++it) {
154  os << it->second;
155  }
156  return os;
157  };
158 
159 private:
160 
161  uint8_t of_version;
162  std::map<unsigned int, cofmeter_band_stats> array;
163 
164 };
165 
166 }; // end of namespace openflow
167 }; // end of namespace rofl
168 
169 #endif /* COFMETERBANDSTATSARRAY_H_ */
Definition: cofmeterbandstatsarray.h:23
Definition: cofmeterbandstats.h:24
Definition: logging.h:76