Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JDAQModuleIdentifier.hh
Go to the documentation of this file.
1#ifndef __JDAQMODULEIDENTIFIER__
2#define __JDAQMODULEIDENTIFIER__
3
4#include <istream>
5#include <ostream>
6
8
9
10/**
11 * \author mdejong
12 */
13
14namespace KM3NETDAQ {
15
16 /**
17 * Module identifier.
18 */
20 {
21 public:
22
26
27 /**
28 * Default constructor.
29 */
31 id(-1)
32 {}
33
34
35 /**
36 * Constructor.
37 *
38 * \param __id module identifier
39 */
40 JDAQModuleIdentifier(const int __id) :
41 id(__id)
42 {}
43
44
45 /**
46 * Get Module identifier.
47 *
48 * \return Module identifier
49 */
51 {
52 return *this;
53 }
54
55
56 /**
57 * Set Module identifier.
58 *
59 * \param module Module identifier
60 */
62 {
63 *this = module;
64 }
65
66
67 /**
68 * Get module identifier.
69 *
70 * \return module identifier
71 */
72 int getModuleID() const
73 {
74 return id;
75 }
76
77
78 /**
79 * Read DAQ ModuleIdentifier from input.
80 *
81 * \param in input stream
82 * \param module module identifier
83 * \return input stream
84 */
85 friend inline std::istream& operator>>(std::istream& in, JDAQModuleIdentifier& module)
86 {
87 in >> module.id;
88
89 return in;
90 }
91
92
93 /**
94 * Write DAQ ModuleIdentifier to output.
95 *
96 * \param out output stream
97 * \param module module identifier
98 * \return output stream
99 */
100 friend inline std::ostream& operator<<(std::ostream& out, const JDAQModuleIdentifier& module)
101 {
102 out << module.id;
103
104 return out;
105 }
106
107
109
110
111 protected:
112 int id;
113 };
114
115
116 /**
117 * Equal operator.
118 *
119 * \param first first module identifier
120 * \param second second module identifier
121 * \return true if identifiers are equal; else false
122 */
123 inline bool operator==(const JDAQModuleIdentifier& first, const JDAQModuleIdentifier& second)
124 {
125 return first.getModuleID() == second.getModuleID();
126 }
127
128
129 /**
130 * Not equal operator.
131 *
132 * \param first first module identifier
133 * \param second second module identifier
134 * \return true if identifiers are different; else false
135 */
136 inline bool operator!=(const JDAQModuleIdentifier& first, const JDAQModuleIdentifier& second)
137 {
138 return first.getModuleID() != second.getModuleID();
139 }
140
141
142 /**
143 * Equal operator.
144 *
145 * \param module module identifier
146 * \param id identifier
147 * \return true if identifiers are equal; else false
148 */
149 inline bool operator==(const JDAQModuleIdentifier& module, const int id)
150 {
151 return module.getModuleID() == id;
152 }
153
154
155 /**
156 * Not equal operator.
157 *
158 * \param module module identifier
159 * \param id identifier
160 * \return true if identifiers are different; else false
161 */
162 inline bool operator!=(const JDAQModuleIdentifier& module, const int id)
163 {
164 return module.getModuleID() != id;
165 }
166
167
168 /**
169 * Less than operator.
170 *
171 * \param first first module identifier
172 * \param second second module identifier
173 * \return true if first identifier less than second eidentifier; else false
174 */
175 inline bool operator<(const JDAQModuleIdentifier& first, const JDAQModuleIdentifier& second)
176 {
177 return first.getModuleID() < second.getModuleID();
178 }
179
180
181 /**
182 * Less than operator.
183 *
184 * \param module module identifier
185 * \param id identifier
186 * \return true if module identifier less than identifier; else false
187 */
188 inline bool operator<(const JDAQModuleIdentifier& module, const int id)
189 {
190 return module.getModuleID() < id;
191 }
192
193
194 /**
195 * Auxiliary class to compare modules.
196 */
198 /*
199 * Default constructor.
200 */
203
204
205 /**
206 * Compare modules.
207 *
208 * \param first first module
209 * \param second second module
210 * \return true if first module identifier less than that of second; else false
211 */
212 bool operator()(const JDAQModuleIdentifier& first, const JDAQModuleIdentifier& second) const
213 {
214 return first.getModuleID() < second.getModuleID();
215 }
216 };
217}
218
219#endif
Interface for binary input.
Interface for binary output.
friend std::istream & operator>>(std::istream &in, JDAQModuleIdentifier &module)
Read DAQ ModuleIdentifier from input.
friend JWriter & operator<<(JWriter &, const JDAQModuleIdentifier &)
Write module identifier to output.
friend JReader & operator>>(JReader &, JDAQModuleIdentifier &)
Read module identifier from input.
int getModuleID() const
Get module identifier.
ClassDefNV(JDAQModuleIdentifier, 1)
const JDAQModuleIdentifier & getModuleIdentifier() const
Get Module identifier.
JDAQModuleIdentifier(const int __id)
Constructor.
JDAQModuleIdentifier()
Default constructor.
void setModuleIdentifier(const JDAQModuleIdentifier &module)
Set Module identifier.
friend std::ostream & operator<<(std::ostream &out, const JDAQModuleIdentifier &module)
Write DAQ ModuleIdentifier to output.
bool operator==(const Head &first, const Head &second)
Equal operator.
Definition JHead.hh:1801
bool operator<(const Head &first, const Head &second)
Less than operator.
Definition JHead.hh:1817
bool operator!=(const JTag &first, const JTag &second)
Not equal operator for JTag.
Definition JTag.hh:291
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
size_t getSizeof< JDAQModuleIdentifier >()
Get size of type.
Auxiliary class to compare modules.
bool operator()(const JDAQModuleIdentifier &first, const JDAQModuleIdentifier &second) const
Compare modules.