#ifndef __JACOUSTICS__JCOUNTER__ #define __JACOUSTICS__JCOUNTER__ #include #include #include "JIO/JSerialisable.hh" /** * \file * * Acoustic counter. * \author mdejong */ namespace JACOUSTICS {} namespace JPP { using namespace JACOUSTICS; } namespace JACOUSTICS { using JIO::JReader; using JIO::JWriter; /** * Acoustic counter. */ struct JCounter { /** * Default constructor. */ JCounter() : counter(0) {} /** * Constructor. * * \param counter counter */ JCounter(const int counter) : counter(counter) {} /** * Get counter. * * \return counter */ int getCounter() const { return counter; } /** * Read counter from input. * * \param in reader * \param object counter * \return reader */ friend inline JReader& operator>>(JReader& in, JCounter& object) { in >> object.counter; return in; } /** * Write counter to output. * * \param out writer * \param object counter * \return writer */ friend inline JWriter& operator<<(JWriter& out, const JCounter& object) { out << object.counter; return out; } ClassDefNV(JCounter, 1); protected: int counter; }; /** * Less-than operator for two counters. * * \param first first counter * \param second second counter * \return true if first counter less than second; else false */ static inline bool operator<(const JCounter& first, const JCounter& second) { return first.getCounter() < second.getCounter(); } /** * Equals operator for two counters. * * \param first first counter * \param second second counter * \return true if first counter equal to second; else false */ static inline bool operator==(const JCounter& first, const JCounter& second) { return first.getCounter() == second.getCounter(); } } #endif