Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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"
9 #include "JAcoustics/JCounter.hh"
10 
11 
12 /**
13  * \file
14  *
15  * Emitter hash key.
16  * \author mdejong
17  */
18 namespace JACOUSTICS {}
19 namespace JPP { using namespace JACOUSTICS; }
20 
21 namespace JACOUSTICS {
22 
23  using JLANG::JObjectID;
24 
25 
26  /**
27  * Emitter key.
28  */
29  struct JEKey :
30  public JObjectID,
31  public JCounter,
32  public JLANG::JMultiComparable<JEKey, JLANG::JTYPELIST<JObjectID, JCounter>::typelist>
33  {
34  /**
35  * Multiplication factor for emitter identifier.
36  */
37  static const int COUNTER = 100;
38 
39 
40  /**
41  * Default constructor.
42  */
44  {}
45 
46 
47  /**
48  * Constructor.
49  *
50  * \param id emitter identifier
51  * \param counter event counter
52  */
53  JEKey(const JObjectID& id,
54  const JCounter& counter) :
55  JObjectID(id),
56  JCounter (counter)
57  {}
58 
59 
60  /**
61  * Get hash key.
62  *
63  * \return hash key
64  */
65  int getKey() const
66  {
67  return getCounter() * COUNTER + getID();
68  }
69 
70 
71  /**
72  * Write emitter key to output stream.
73  *
74  * \param out output stream
75  * \param key emitter key
76  * \return output stream
77  */
78  friend inline std::ostream& operator<<(std::ostream& out, const JEKey& key)
79  {
80  using namespace std;
81 
82  return out << setw(3) << key.getID() << ' '
83  << setw(8) << key.getCounter();
84  }
85  };
86 }
87 
88 #endif
Acoustic counter.
Acoustic counter.
int getCounter() const
Get counter.
JEKey(const JObjectID &id, const JCounter &counter)
Constructor.
Definition: JEKey.hh:53
static const int COUNTER
Multiplication factor for emitter identifier.
Definition: JEKey.hh:37
int getID() const
Get identifier.
Definition: JObjectID.hh:55
friend std::ostream & operator<<(std::ostream &out, const JEKey &key)
Write emitter key to output stream.
Definition: JEKey.hh:78
int getKey() const
Get hash key.
Definition: JEKey.hh:65
Auxiliary class for object identification.
Definition: JObjectID.hh:27
Emitter key.
Definition: JEKey.hh:29
Template definition of auxiliary base class for composite data structures composed of base classes wi...
JEKey()
Default constructor.
Definition: JEKey.hh:43