Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JEKey.hh
Go to the documentation of this file.
1#ifndef __JACOUSTICS__JEKEY__
2#define __JACOUSTICS__JEKEY__
3
4#include <ostream>
5#include <iomanip>
6
7#include "JLang/JObjectID.hh"
10
11
12/**
13 * \file
14 *
15 * Emitter hash key.
16 * \author mdejong
17 */
18namespace JACOUSTICS {}
19namespace JPP { using namespace JACOUSTICS; }
20
21namespace JACOUSTICS {
22
24 using JLANG::JObjectID;
25
26
27 /**
28 * Emitter key.
29 *
30 * The emitter key can be used to umambiguously address an event in a data set.
31 */
32 struct JEKey :
33 public JObjectID,
34 public JCounter,
35 public JMultiComparable<JEKey, JLANG::JTYPELIST<JObjectID, JCounter>::typelist>
36 {
37 /**
38 * Multiplication factor applied to the event counter for the evaluation of the hash key.\n
39 * Note that the object identifier of any emitter should not exceed this value.
40 */
41 static const int COUNTER = 100;
42
43
44 /**
45 * Default constructor.
46 */
48 {}
49
50
51 /**
52 * Constructor.
53 *
54 * \param id emitter identifier
55 * \param counter event counter
56 */
57 JEKey(const JObjectID& id,
58 const JCounter& counter) :
59 JObjectID(id),
61 {}
62
63
64 /**
65 * Get hash key.
66 *
67 * \return hash key
68 */
69 int getKey() const
70 {
71 return getCounter() * COUNTER + getID();
72 }
73
74
75 /**
76 * Write emitter key to output stream.
77 *
78 * \param out output stream
79 * \param key emitter key
80 * \return output stream
81 */
82 friend inline std::ostream& operator<<(std::ostream& out, const JEKey& key)
83 {
84 using namespace std;
85
86 return out << setw(3) << key.getID() << ' '
87 << setw(4) << key.getCounter();
88 }
89 };
90}
91
92#endif
Acoustic counter.
Auxiliary class for object identification.
Definition JObjectID.hh:25
int getID() const
Get identifier.
Definition JObjectID.hh:50
Auxiliary classes and methods for acoustic position calibration.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
int getCounter() const
Get counter.
Emitter key.
Definition JEKey.hh:36
JEKey(const JObjectID &id, const JCounter &counter)
Constructor.
Definition JEKey.hh:57
JEKey()
Default constructor.
Definition JEKey.hh:47
int getKey() const
Get hash key.
Definition JEKey.hh:69
friend std::ostream & operator<<(std::ostream &out, const JEKey &key)
Write emitter key to output stream.
Definition JEKey.hh:82
static const int COUNTER
Multiplication factor applied to the event counter for the evaluation of the hash key.
Definition JEKey.hh:41
Template definition of auxiliary base class for composite data structures composed of base classes wi...