Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
cofbucketcounters.h
1 /*
2  * cofbucketcounters.h
3  *
4  * Created on: 16.03.2014
5  * Author: andi
6  */
7 
8 #ifndef COFBUCKETCOUNTERS_H_
9 #define COFBUCKETCOUNTERS_H_
10 
11 #include <inttypes.h>
12 
13 #include <iostream>
14 #include <map>
15 
16 #include "rofl/common/openflow/cofbucketcounter.h"
17 #include "rofl/common/logging.h"
18 
19 namespace rofl {
20 namespace openflow {
21 
23 {
24  uint8_t ofp_version;
25  std::map<uint32_t, cofbucket_counter> bucketcounters;
26 
27 public:
28 
32  cofbucket_counters(uint8_t ofp_version = rofl::openflow::OFP_VERSION_UNKNOWN);
33 
37  virtual
39 
44  cofbucket_counters const& bcs);
45 
50  operator= (
51  cofbucket_counters const& bcs);
52 
56  bool
57  operator== (
58  cofbucket_counters const& bcs);
59 
60 public:
61 
65  void
66  clear() { return bucketcounters.clear(); };
67 
71  uint8_t
72  get_version() const { return ofp_version; };
73 
77  void
78  set_version(uint8_t ofp_version) { this->ofp_version = ofp_version; };
79 
80 public:
81 
85  virtual size_t
86  length() const;
87 
91  virtual void
92  pack(uint8_t* buf, size_t buflen);
93 
97  virtual void
98  unpack(uint8_t* buf, size_t buflen);
99 
100 public:
101 
106  add_bucket_counter(uint32_t bucket_counter_id);
107 
111  void
112  drop_bucket_counter(uint32_t bucket_counter_id);
113 
118  set_bucket_counter(uint32_t bucket_counter_id);
119 
123  cofbucket_counter const&
124  get_bucket_counter(uint32_t bucket_counter_id) const;
125 
129  bool
130  has_bucket_counter(uint32_t bucket_counter_id);
131 
132 public:
133 
137  friend std::ostream&
138  operator<< (std::ostream& os, cofbucket_counters const& bcs) {
139  os << rofl::indent(0) << "<cofbucket_counters #bucket-counters:" << bcs.bucketcounters.size() << " >" << std::endl;
140  rofl::indent i(2);
141  for (std::map<uint32_t, cofbucket_counter>::const_iterator
142  it = bcs.bucketcounters.begin(); it != bcs.bucketcounters.end(); ++it) {
143  os << it->second;
144  }
145  return os;
146  };
147 };
148 
149 }; // end of namespace openflow
150 }; // end of namespace rofl
151 
152 
153 
154 #endif /* COFBUCKETCOUNTERS_H_ */
Definition: cofbucketcounters.h:22
Definition: logging.h:76
Definition: cofbucketcounter.h:27