Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
cofportstatsarray.h
1 /*
2  * cofports.h
3  *
4  * Created on: 14.03.2014
5  * Author: andreas
6  */
7 
8 #ifndef COFPORTSTATSARRAY_H_
9 #define COFPORTSTATSARRAY_H_
10 
11 #include <iostream>
12 #include <map>
13 
14 #include "rofl/common/openflow/cofportstats.h"
15 
16 namespace rofl {
17 namespace openflow {
18 
20 
21  uint8_t ofp_version;
22  std::map<uint32_t, cofport_stats_reply> array;
23 
24 public:
25 
29  cofportstatsarray(uint8_t ofp_version = OFP_VERSION_UNKNOWN);
30 
34  virtual
36 
41 
46  operator= (cofportstatsarray const& ports);
47 
51  bool
52  operator== (cofportstatsarray const& ports);
53 
58  operator+= (cofportstatsarray const& ports);
59 
60 public:
61 
65  virtual size_t
66  length() const;
67 
71  virtual void
72  pack(uint8_t *buf = (uint8_t*)0, size_t buflen = 0);
73 
77  virtual void
78  unpack(uint8_t *buf, size_t buflen);
79 
80 public:
81 
85  size_t
86  size() const { return array.size(); };
87 
91  void
92  clear() { array.clear(); };
93 
97  uint8_t
98  get_version() const { return ofp_version; };
99 
103  void
104  set_version(uint8_t ofp_version) { this->ofp_version = ofp_version; };
105 
109  std::map<uint32_t, cofport_stats_reply> const&
110  get_port_stats() const { return array; };
111 
115  std::map<uint32_t, cofport_stats_reply>&
116  set_port_stats() { return array; };
117 
118 public:
119 
124  add_port_stats(uint32_t port_id);
125 
129  void
130  drop_port_stats(uint32_t port_id);
131 
136  set_port_stats(uint32_t port_id);
137 
141  cofport_stats_reply const&
142  get_port_stats(uint32_t port_id) const;
143 
147  bool
148  has_port_stats(uint32_t port_id);
149 
150 public:
151 
152  friend std::ostream&
153  operator<< (std::ostream& os, cofportstatsarray const& portstatsarray) {
154  os << rofl::indent(0) << "<cofportstatsarray #ports:" << (int)portstatsarray.array.size() << " >" << std::endl;
155  rofl::indent i(2);
156  for (std::map<uint32_t, cofport_stats_reply>::const_iterator
157  it = portstatsarray.array.begin(); it != portstatsarray.array.end(); ++it) {
158  os << it->second;
159  }
160  return os;
161  }
162 };
163 
164 }; // end of openflow
165 }; // end of rofl
166 
167 
168 
169 #endif /* COFGROUPS_H_ */
virtual size_t length() const
Definition: cofportstatsarray.cc:88
Definition: cofportstatsarray.h:19
Definition: cofportstats.h:125
Definition: logging.h:76