Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
cindex.h
1 /*
2  * cindex.h
3  *
4  * Created on: 17.07.2014
5  * Author: andreas
6  */
7 
8 #ifndef CINDEX_H_
9 #define CINDEX_H_
10 
11 #include <iostream>
12 
13 #include "rofl/common/logging.h"
14 
15 namespace rofl {
16 
17 class cindex {
18 public:
19 
23  cindex() : index(0) {};
24 
28  explicit
29  cindex(unsigned int index) : index(index) {};
30 
34  ~cindex() {};
35 
39  cindex(const cindex& idx) { *this = idx; };
40 
44  cindex&
45  operator= (const cindex& idx) {
46  if (this == &idx)
47  return *this;
48  index = idx.index;
49  return *this;
50  };
51 
55  bool
56  operator< (const cindex& idx) const {
57  return (index < idx.index);
58  };
59 
63  bool
64  operator== (const cindex& idx) const {
65  return (index == idx.index);
66  };
67 
71  bool
72  operator!= (const cindex& idx) const {
73  return (index != idx.index);
74  };
75 
79  cindex&
80  operator++ () { // prefix
81  ++index;
82  return *this;
83  };
84 
88  cindex
89  operator++ (int unused) { // postfix
90  cindex result = *this;
91  ++index;
92  return result;
93  };
94 
95 public:
96 
100  void
101  set_index(unsigned int index) { this->index = index; };
102 
106  unsigned int
107  get_index() const { return index; };
108 
109 public:
110 
111  friend std::ostream&
112  operator<< (std::ostream& os, const cindex& index) {
113  os << rofl::indent(0) << "<cindex idx:" << index.get_index() << " >";
114  return os;
115  };
116 
117 private:
118 
119  unsigned int index;
120 };
121 
122 }; // end of namespace rofl
123 
124 #endif /* CINDEX_H_ */
Definition: cindex.h:17
Definition: logging.h:76