#ifndef __JACOUSTICS__JEKEY__ #define __JACOUSTICS__JEKEY__ #include #include #include "JLang/JObjectID.hh" #include "JLang/JMultiComparable.hh" #include "JAcoustics/JCounter.hh" /** * \file * * Emitter hash key. * \author mdejong */ namespace JACOUSTICS {} namespace JPP { using namespace JACOUSTICS; } namespace JACOUSTICS { using JLANG::JMultiComparable; using JLANG::JObjectID; /** * Emitter key. * * The emitter key can be used to umambiguously address an event in a data set. */ struct JEKey : public JObjectID, public JCounter, public JMultiComparable::typelist> { /** * Multiplication factor applied to the event counter for the evaluation of the hash key.\n * Note that the object identifier of any emitter should not exceed this value. */ static const int COUNTER = 100; /** * Default constructor. */ JEKey() {} /** * Constructor. * * \param id emitter identifier * \param counter event counter */ JEKey(const JObjectID& id, const JCounter& counter) : JObjectID(id), JCounter (counter) {} /** * Get hash key. * * \return hash key */ int getKey() const { return getCounter() * COUNTER + getID(); } /** * Write emitter key to output stream. * * \param out output stream * \param key emitter key * \return output stream */ friend inline std::ostream& operator<<(std::ostream& out, const JEKey& key) { using namespace std; return out << setw(3) << key.getID() << ' ' << setw(4) << key.getCounter(); } }; } #endif