Jpp  17.3.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
14 namespace KM3NETDAQ {
15 
16  /**
17  * Module identifier.
18  */
20  {
21  public:
22 
23  friend size_t getSizeof<JDAQModuleIdentifier>();
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  */
202  {}
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
JDAQModuleIdentifier(const int __id)
Constructor.
bool operator()(const JDAQModuleIdentifier &first, const JDAQModuleIdentifier &second) const
Compare modules.
bool operator==(const JDAQChronometer &first, const JDAQChronometer &second)
Equal operator for DAQ chronometers.
Interface for binary output.
int getModuleID() const
Get module identifier.
JDAQModuleIdentifier()
Default constructor.
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
Interface for binary input.
friend JWriter & operator<<(JWriter &, const JDAQModuleIdentifier &)
Write module identifier to output.
Auxiliary class to compare modules.
friend std::istream & operator>>(std::istream &in, JDAQModuleIdentifier &module)
Read DAQ ModuleIdentifier from input.
void setModuleIdentifier(const JDAQModuleIdentifier &module)
Set Module identifier.
friend std::ostream & operator<<(std::ostream &out, const JDAQModuleIdentifier &module)
Write DAQ ModuleIdentifier to output.
const JDAQModuleIdentifier & getModuleIdentifier() const
Get Module identifier.
bool operator!=(const JDAQChronometer &first, const JDAQChronometer &second)
Not-equal operator for DAQ chronometers.
size_t getSizeof< JDAQModuleIdentifier >()
Get size of type.
bool operator<(const JDAQHit &first, const JDAQHit &second)
Less than operator for DAQ hits.
Definition: JDAQHit.hh:174
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46
ClassDefNV(JDAQModuleIdentifier, 1)
friend JReader & operator>>(JReader &, JDAQModuleIdentifier &)
Read module identifier from input.