/
cctlid.h
101 lines (83 loc) · 1.56 KB
/
cctlid.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
* cctlid.h
*
* Created on: 19.04.2014
* Author: andreas
*/
#ifndef CCTLID_H_
#define CCTLID_H_
#include <inttypes.h>
#include <ios>
#include <iostream>
#include <string>
namespace rofl {
/**
* @ingroup common_devel_workflow
* @brief rofl-common's internal remote controller handle.
*/
class cctlid {
uint64_t id;
std::string s_id;
public:
/**
*
*/
explicit cctlid(uint64_t ctlid = 0) : id(ctlid) {
std::stringstream sstr;
sstr << id;
s_id = sstr.str();
};
/**
*
*/
~cctlid(){};
/**
*
*/
cctlid(cctlid const &ctlid) { *this = ctlid; };
/**
*
*/
cctlid &operator=(cctlid const &ctlid) {
if (this == &ctlid)
return *this;
id = ctlid.id;
s_id = ctlid.s_id;
return *this;
};
/**
*
*/
bool operator==(cctlid const &ctlid) const { return (id == ctlid.id); };
/**
*
*/
bool operator!=(cctlid const &ctlid) const { return (id != ctlid.id); };
/**
*
*/
bool operator<(cctlid const &ctlid) const { return (id < ctlid.id); };
public:
/**
*
*/
const uint64_t &get_ctlid() const { return id; };
/**
*
*/
const std::string &get_ctlid_s() const { return s_id; };
public:
friend std::ostream &operator<<(std::ostream &os, const cctlid &ctlid) {
os << "<cctlid:" << std::hex << (unsigned long long)ctlid.id << std::dec
<< "(" << ctlid.s_id << ")"
<< " >" << std::endl;
return os;
};
std::string str() const {
std::stringstream ss;
ss << id;
return ss.str();
};
};
}; // namespace rofl
#endif /* CCTLID_H_ */