#ifndef __JTRIGGER__JFRAME_T__ #define __JTRIGGER__JFRAME_T__ #include #include "JTrigger/JHitToolkit.hh" /** * \author mdejong */ namespace JTRIGGER {} namespace JPP { using namespace JTRIGGER; } namespace JTRIGGER { /** * Data frame with end marker. * * The end marker is a special element that is used in JTOOLS::JMergeSort to speed up the sorting of data.\n * It is placed within the capacity of the container whilst its size is maintained.\n * Here, it is defined by an element of which the time is larger than any possible nominal value.\n * The end marker should manually be put using method putEndMarker() after modifications of the contents of the container. */ template > class JFrame_t : public std::vector, public JHitToolkit { public: /** * Default constructor. * * Empty container with end marker. */ JFrame_t() { this->putEndMarker(); } /** * Copy constructor. * * \param frame frame */ JFrame_t(const JFrame_t& frame) : std::vector(frame.begin(), frame.end()) { this->putEndMarker(); } /** * Move constructor. * * \param frame frame */ JFrame_t(JFrame_t&& frame) { this->swap(frame); this->putEndMarker(); } /** * Assignment operator. * * \param frame frame * \return this frame */ JFrame_t& operator=(const JFrame_t& frame) { this->assign(frame.begin(), frame.end()); this->putEndMarker(); return *this; } /** * Move assignment operator. * * \param frame frame * \return this frame */ JFrame_t& operator=(JFrame_t&& frame) { this->swap(frame); this->putEndMarker(); return *this; } /** * Check presence of end marker. * * \return true if end marker present; else false */ bool hasEndMarker() const { return (this->capacity() > this->size() && this->getT(*(this->end())) == this->getT(this->getEndMarker())); } /** * Append end marker to data. */ void putEndMarker() { if (this->capacity() <= this->size()) { this->reserve(this->size() + 1); } *(this->end()) = this->getEndMarker(); } /** * Reset. * * Clear container and put end marker. */ void reset() { this->clear(); this->putEndMarker(); } }; } #endif