Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JDAQTriggerCounter.hh
Go to the documentation of this file.
1#ifndef __JDAQTRIGGERCOUNTER__
2#define __JDAQTRIGGERCOUNTER__
3
5
6
7/**
8 * \author mdejong
9 */
10
11namespace KM3NETDAQ {
12
13
14 /**
15 * Type definition of trigger counter.
16 */
17 typedef unsigned long long int JTriggerCounter_t;
18
19
20 /**
21 * Auxiliary class to count triggers.
22 */
24 private:
25 /**
26 * Constructor.
27 *
28 * \param counter counter value
29 */
31 {
32 this->trigger_counter = counter;
33 }
34
35
36 public:
37
41
42 /**
43 * Default constructor.
44 *
45 * This constructor increments the counter of the unique instance
46 * of this class and stores the result in this object.
47 */
52
53
54 /**
55 * Virtual destructor.
56 */
58 {}
59
60
61 /**
62 * Get reference to unique instance of this class object.
63 *
64 * \return reference to this class object
65 */
67 {
68 static JDAQTriggerCounter counter(0);
69
70 return counter;
71 }
72
73
74 /**
75 * Get DAQ trigger counter.
76 *
77 * \return DAQ trigger counter
78 */
80 {
81 return static_cast<const JDAQTriggerCounter&>(*this);
82 }
83
84
85 /**
86 * Reset counter of unique instance of this class object.
87 */
88 static void reset()
89 {
91 }
92
93
94 /**
95 * Get trigger counter.
96 *
97 * \return counter value
98 */
100 {
101 return trigger_counter;
102 }
103
104
105 /**
106 * Set trigger counter.
107 *
108 * \param counter counter value
109 */
110 void setCounter(const JTriggerCounter_t counter)
111 {
112 this->trigger_counter = counter;
113 }
114
115
116 /**
117 * Increment trigger counter.
118 *
119 * \return counter value
120 */
122 {
123 return trigger_counter++;
124 }
125
126
128
129
130 protected:
132 };
133
134
135 /**
136 * Equal operator for DAQ trigger counters.
137 *
138 * \param first trigger counter
139 * \param second trigger counter
140 * \result true if first trigger counter equal to second; else false
141 */
142 inline bool operator==(const JDAQTriggerCounter& first,
143 const JDAQTriggerCounter& second)
144 {
145 return (first.getCounter() == second.getCounter());
146 }
147
148
149 /**
150 * Not-equal operator for DAQ trigger counters.
151 *
152 * \param first trigger counter
153 * \param second trigger counter
154 * \result true if first trigger counter not equal to second; else false
155 */
156 inline bool operator!=(const JDAQTriggerCounter& first,
157 const JDAQTriggerCounter& second)
158 {
159 return !(first == second);
160 }
161}
162
163#endif
Interface for binary input.
Interface for binary output.
Auxiliary class to count triggers.
JTriggerCounter_t getCounter() const
Get trigger counter.
static void reset()
Reset counter of unique instance of this class object.
JDAQTriggerCounter(const JTriggerCounter_t counter)
Constructor.
JTriggerCounter_t next()
Increment trigger counter.
static JDAQTriggerCounter & getInstance()
Get reference to unique instance of this class object.
void setCounter(const JTriggerCounter_t counter)
Set trigger counter.
ClassDef(JDAQTriggerCounter, 1)
virtual ~JDAQTriggerCounter()
Virtual destructor.
friend JReader & operator>>(JReader &, JDAQTriggerCounter &)
Read DAQ trigger counter from input.
friend JWriter & operator<<(JWriter &, const JDAQTriggerCounter &)
Write JDAQTriggerCounter to output.
const JDAQTriggerCounter & getDAQTriggerCounter() const
Get DAQ trigger counter.
JDAQTriggerCounter()
Default constructor.
bool operator==(const Head &first, const Head &second)
Equal operator.
Definition JHead.hh:1801
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< JDAQTriggerCounter >()
Get size of type.
unsigned long long int JTriggerCounter_t
Type definition of trigger counter.