Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
JDAQPMTIdentifier.hh
Go to the documentation of this file.
1#ifndef __JDAQPMTIDENTIFIER__
2#define __JDAQPMTIDENTIFIER__
3
4#include <istream>
5#include <ostream>
6
9
10
11/**
12 * \author mdejong
13 */
14
15namespace KM3NETDAQ {
16
17 /**
18 * PMT identifier.
19 */
22 {
23 public:
24
28
29 /**
30 * Default constructor.
31 */
36
37
38 /**
39 * Constructor.
40 *
41 * \param id module identifier
42 * \param pmt_address PMT address
43 */
45 const int pmt_address) :
47 address (pmt_address)
48 {}
49
50
51 /**
52 * Get PMT identifier.
53 *
54 * \return PMT identifier
55 */
57 {
58 return *this;
59 }
60
61
62 /**
63 * Set PMT identifier.
64 *
65 * \param pmt PMT identifier
66 */
68 {
69 *this = pmt;
70 }
71
72
73 /**
74 * Get PMT identifier.
75 *
76 * \return PMT identifier
77 */
78 int getPMTAddress() const
79 {
80 return address;
81 }
82
83
84 /**
85 * Read PMT identifier from input.
86 *
87 * \param in input stream
88 * \param pmt PMT identifier
89 * \return input stream
90 */
91 friend inline std::istream& operator>>(std::istream& in, JDAQPMTIdentifier& pmt)
92 {
93 in >> static_cast<JDAQModuleIdentifier&>(pmt);
94 in >> pmt.address;
95
96 return in;
97 }
98
99
100 /**
101 * Write PMT identifier to output.
102 *
103 * \param out output stream
104 * \param pmt PMT identifier
105 * \return output stream
106 */
107 friend inline std::ostream& operator<<(std::ostream& out, const JDAQPMTIdentifier& pmt)
108 {
109 out << static_cast<const JDAQModuleIdentifier&>(pmt) << ' ';
110 out << pmt.address;
111
112 return out;
113 }
114
115
116 /**
117 * Compare PMT identifiers.
118 *
119 * The comparison is applied to the module identifer and to the PMT address.
120 * If the module identifier or PMT address is <tt>-1</tt>, the corresponding comparison evaluates to <tt>true</tt>.
121 *
122 * \param first PMT identifier
123 * \param second PMT identifier
124 * \result true if first PMT equal second PMT; else false
125 */
126 static inline bool compare(const JDAQPMTIdentifier& first, const JDAQPMTIdentifier& second)
127 {
128 return ((first .getModuleIdentifier() == second.getModuleIdentifier() ||
129 first .getModuleIdentifier() == -1 ||
130 second.getModuleIdentifier() == -1) &&
131 (first .getPMTAddress() == second.getPMTAddress() ||
132 first .getPMTAddress() == -1 ||
133 second.getPMTAddress() == -1));
134 }
135
136
138
139
140 protected:
142 };
143
144
145 /**
146 * Less than operator for PMT identifiers.
147 *
148 * The less than operator is applied first to the module identifer and then to the PMT address.
149 *
150 * \param first PMT identifier
151 * \param second PMT identifier
152 * \result true if first PMT lower than second PMT; else false
153 */
154 inline bool operator<(const JDAQPMTIdentifier& first, const JDAQPMTIdentifier& second)
155 {
156 if (first.getModuleIdentifier() == second.getModuleIdentifier())
157 return first.getPMTAddress() < second.getPMTAddress();
158 else
159 return first.getModuleIdentifier() < second.getModuleIdentifier();
160 }
161
162
163 /**
164 * Equal operator for PMT identifiers.
165 *
166 * The equal operator is applied to the module identifer and to the PMT address.
167 *
168 * \param first PMT identifier
169 * \param second PMT identifier
170 * \result true if first PMT equal second PMT; else false
171 */
172 inline bool operator==(const JDAQPMTIdentifier& first, const JDAQPMTIdentifier& second)
173 {
174 return (first.getModuleIdentifier() == second.getModuleIdentifier() &&
175 first.getPMTAddress() == second.getPMTAddress());
176 }
177
178
179 /**
180 * Not-equal operator for PMT identifiers.
181 *
182 * \param first PMT identifier
183 * \param second PMT identifier
184 * \result true if first PMT identifier not equal to second; else false
185 */
186 inline bool operator!=(const JDAQPMTIdentifier& first,
187 const JDAQPMTIdentifier& second)
188 {
189 return !(first == second);
190 }
191}
192
193#endif
Interface for binary input.
Interface for binary output.
const JDAQModuleIdentifier & getModuleIdentifier() const
Get Module identifier.
friend JWriter & operator<<(JWriter &, const JDAQPMTIdentifier &)
Write PMT identifier to output.
int getPMTAddress() const
Get PMT identifier.
static bool compare(const JDAQPMTIdentifier &first, const JDAQPMTIdentifier &second)
Compare PMT identifiers.
friend JReader & operator>>(JReader &, JDAQPMTIdentifier &)
Read PMT identifier from input.
void setPMTIdentifier(const JDAQPMTIdentifier &pmt)
Set PMT identifier.
const JDAQPMTIdentifier & getPMTIdentifier() const
Get PMT identifier.
friend std::istream & operator>>(std::istream &in, JDAQPMTIdentifier &pmt)
Read PMT identifier from input.
JDAQPMTIdentifier(const JDAQModuleIdentifier &id, const int pmt_address)
Constructor.
ClassDefNV(JDAQPMTIdentifier, 1)
friend std::ostream & operator<<(std::ostream &out, const JDAQPMTIdentifier &pmt)
Write PMT identifier to output.
JDAQPMTIdentifier()
Default constructor.
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< JDAQPMTIdentifier >()
Get size of type.