#ifndef __JDETECTOR__JPMTPHYSICALADDRESS__ #define __JDETECTOR__JPMTPHYSICALADDRESS__ #include #include #include "JLang/JComparable.hh" #include "JIO/JSerialisable.hh" /** * \author mdejong */ namespace JDETECTOR {} namespace JPP { using namespace JDETECTOR; } namespace JDETECTOR { using JLANG::JComparable; /** * Data structure for PMT physical address. */ class JPMTPhysicalAddress : public JComparable { public: /** * Default constructor. */ JPMTPhysicalAddress() { this->ring = '\0'; this->position = -1; } /** * Constructor. * * \param ring ring * \param position position */ JPMTPhysicalAddress(const char ring, const int position) { this->ring = ring; this->position = position; } /** * Less than method. * * \param address PMT physical address * \result true if this address before given address; else false */ inline bool less(const JPMTPhysicalAddress& address) const { if (this->ring == address.ring) return this->position < address.position; else return this->ring < address.ring; } /** * Read PMT physical address from input. * * \param in input stream * \param object PMT physical address * \return input stream */ friend inline std::istream& operator>>(std::istream& in, JPMTPhysicalAddress& object) { in >> object.ring; in >> object.position; return in; } /** * Write PMT physical address to output. * * \param out output stream * \param object PMT physical address * \return output stream */ friend inline std::ostream& operator<<(std::ostream& out, const JPMTPhysicalAddress& object) { out << object.ring; out << object.position; return out; } /** * Read PMT physical address from input. * * \param in reader * \param object PMT physical address * \return reader */ friend inline JReader& operator>>(JReader& in, JPMTPhysicalAddress& object) { in >> object.ring; in >> object.position; return in; } /** * Write PMT physical address to output. * * \param out writer * \param object PMT physical address * \return writer */ friend inline JWriter& operator<<(JWriter& out, const JPMTPhysicalAddress& object) { out << object.ring; out << object.position; return out; } /** * Convert PMT physical address to string. * * \return string */ std::string toString() const { std::ostringstream os; os << *this; return os.str(); } char ring; //!< ring number ['A','F'] int position; //!< position within ring [1,6] }; } #endif