Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
cdpid.h
1 /*
2  * cdpid.h
3  *
4  * Created on: 05.08.2014
5  * Author: andreas
6  */
7 
8 #ifndef CDPID_HPP_
9 #define CDPID_HPP_
10 
11 #include <inttypes.h>
12 #include <iostream>
13 #include <string>
14 #include <sstream>
15 
16 #include "logging.h"
17 
18 namespace rofl {
19 
20 class cdpid {
21 public:
22 
26  cdpid() :
27  dpid(0) {};
28 
32  explicit cdpid(uint64_t dpid) :
33  dpid(dpid) {
34  std::stringstream sstr; sstr << dpid;
35  s_dpid = sstr.str();
36  };
37 
41  cdpid(const cdpid& dpid) { *this = dpid; };
42 
46  cdpid&
47  operator= (const cdpid& dpid) {
48  if (this == &dpid)
49  return *this;
50  this->dpid = dpid.dpid;
51  this->s_dpid = dpid.s_dpid;
52  return *this;
53  };
54 
58  bool
59  operator< (const cdpid& dpid) const {
60  return (this->dpid < dpid.dpid);
61  };
62 
66  bool
67  operator== (const cdpid& dpid) const {
68  return (this->dpid == dpid.dpid);
69  };
70 
74  bool
75  operator!= (const cdpid& dpid) const {
76  return (this->dpid != dpid.dpid);
77  };
78 
79 public:
80 
84  uint64_t
85  get_uint64_t() const { return dpid; };
86 
90  const std::string&
91  str() const { return s_dpid; };
92 
93 public:
94 
95  friend std::ostream&
96  operator<< (std::ostream& os, const cdpid& dpid) {
97  os << rofl::indent(0) << "<cdpid "
98  << (unsigned long long)dpid.get_uint64_t() << " >" << std::endl;
99  return os;
100  };
101 
102 private:
103 
104  uint64_t dpid;
105  std::string s_dpid;
106 };
107 
108 };
109 
110 #endif /* CDPID_HPP_ */
Definition: cdpid.h:20
Definition: logging.h:76