#ifndef __JDB__JLOCATION_T_ #define __JDB__JLOCATION_T_ #include #include "JLang/JComparable.hh" #include "JLang/JManip.hh" /** * \author mdejong */ namespace JDATABASE {} namespace JPP { using namespace JDATABASE; } namespace JDATABASE { using JLANG::JComparable; /** * Auxiliary data structure for location of product in detector. */ struct JLocation_t : public JComparable { /** * Default constructor.\n * The default corresponds to an invalid location. */ JLocation_t() : string (-1), floor (-1), position(-1) {} /** * Constructor. * * \param string string * \param floor floor * \param position position */ JLocation_t(const int string, const int floor, const int position) : string (string), floor (floor), position(position) {} /** * Check validity of location. * * \return true if valid; else false */ bool is_valid() const { return *this != JLocation_t(); } /** * Less-than method. * * \param location location * \return true if this location less than given location; else false */ bool less(const JLocation_t& location) const { if (this->string == location.string) { if (this->floor == location.floor) return this->position < location.position; else return this->floor < location.floor; } else { return this->string < location.string; } } /** * Write location to output stream. * * \param out output stream * \param object location * \return output stream */ friend inline std::ostream& operator<<(std::ostream& out, const JLocation_t& object) { using namespace std; using namespace JPP; return out << FILL(4,'0') << object.string << '.' << FILL(2,'0') << object.floor << '.' << FILL(2,'0') << object.position << FILL(); } int string; //!< position in detector int floor; //!< position in string int position; //!< position in floor }; } #endif