#ifndef __JDB__JPBSSEQUENCE__ #define __JDB__JPBSSEQUENCE__ #include #include #include #include "JMath/JMath.hh" #include "JDB/JPBS_t.hh" /** * \author mdejong */ namespace JDATABASE {} namespace JPP { using namespace JDATABASE; } namespace JDATABASE { using JMATH::JMath; /** * Auxiliary data structure for a sequence of %PBS values. * * A sequence of %PBS values corresponds to the integration chain of a product,\n * starting from the lowest integration level to the highest integration level. */ struct JPBSSequence : public std::vector { /** * Default constructor. */ JPBSSequence() {} /** * Constructor. * * \param pbs %PBS */ JPBSSequence(const JPBS_t& pbs) : std::vector(1, pbs) {} /** * Constructor. * * \param input %PBS data */ JPBSSequence(const std::initializer_list& input) : std::vector(input) {} /** * Chain %PBS sequences. * * \param first first %PBS sequence * \param second second %PBS sequence * \return combined %PBS sequence */ friend inline JPBSSequence operator+(const JPBSSequence& first, const JPBSSequence& second) { using namespace std; JPBSSequence buffer(first); copy(second.begin(), second.end(), back_inserter(buffer)); return buffer; } }; /** * Auxiliary data structure for set of %PBS sequences. * * A set of %PBS sequences corresponds to all possible integration chains of a product,\n * starting from the lowest integration level to the highest integration level. */ struct JPBSSequences : public std::vector, public JMath { /** * Default constructor. */ JPBSSequences() {} /** * Constructor. * * \param input %PBS sequence */ JPBSSequences(const JPBSSequence& input) : std::vector(1, input) {} /** * Constructor. * * \param input %PBS sequence data */ JPBSSequences(const std::initializer_list& input) { using namespace std; for (std::initializer_list::const_iterator i = input.begin(); i != input.end(); ++i) { copy(i->begin(), i->end(), back_inserter(*this)); } } /** * Add %PBS sequences. * * \param input %PBS sequences * \return this %PBS sequences */ JPBSSequences& add(const JPBSSequences& input) { for (JPBSSequences::const_iterator i = input.begin(); i != input.end(); ++i) { this->push_back(*i); } return *this; } /** * Add %PBS to %PBS sequences. * * \param pbs %PBS * \param input %PBS sequences * \return %PBS sequences */ friend inline JPBSSequences operator+(const JPBS_t& pbs, const JPBSSequences& input) { JPBSSequences buffer; for (JPBSSequences::const_iterator i = input.begin(); i != input.end(); ++i) { buffer.push_back(pbs + *i); } return buffer; } }; /** * Name space to encapsulate %PBS values. */ namespace PBS { /** * %PBS sequences for detection unit. */ static const JPBSSequences DETECTION_UNIT_SEQUENCES = { { PBS::DETECTION_UNIT, PBS::DETECTOR } }; /** * %PBS sequences for optical module. */ static const JPBSSequences DOM_SEQUENCES = { PBS::DOM + PBS::DETECTION_UNIT_SEQUENCES }; /** * %PBS sequences for base module. */ static const JPBSSequences BASE_SEQUENCES = { PBS::BASE + PBS::DETECTION_UNIT_SEQUENCES, PBS::BASE_CONTAINER + PBS::DETECTION_UNIT_SEQUENCES }; /** * %PBS sequences for central-logic board. */ static const JPBSSequences CLB_SEQUENCES = { PBS::CLB + PBS::DOM_SEQUENCES, PBS::CLB + PBS::BASE_SEQUENCES }; /** * %PBS sequences for PMT. */ static const JPBSSequences PMT_SEQUENCES = { PBS::PMT + PBS::DOM_SEQUENCES }; /** * %PBS sequences for AHRS. */ static const JPBSSequences AHRS_SEQUENCES = { PBS::AHRS + PBS::CLB_SEQUENCES }; /** * %PBS sequences for acoustic sensor. */ static const JPBSSequences ACOUSTIC_SENSOR_SEQUENCES = { PBS::ACOUSTIC_SENSOR + PBS::DOM_SEQUENCES }; /** * %PBS sequences for hydrophone. */ static const JPBSSequences HYDROPHONE_SEQUENCES = { PBS::HYDROPHONE + PBS::DETECTION_UNIT_SEQUENCES }; } /** * Auxiliary class to get %PBS sequences as a function of %PBS. */ struct JGetPBSSequences : public std::map { /** * Default constructor. */ JGetPBSSequences() { (*this)[PBS::DETECTION_UNIT] = PBS::DETECTION_UNIT_SEQUENCES; (*this)[PBS::DOM] = PBS::DOM_SEQUENCES; (*this)[PBS::BASE] = PBS::BASE_SEQUENCES; (*this)[PBS::CLB] = PBS::CLB_SEQUENCES; (*this)[PBS::PMT] = PBS::PMT_SEQUENCES; (*this)[PBS::AHRS] = PBS::AHRS_SEQUENCES; (*this)[PBS::ACOUSTIC_SENSOR] = PBS::ACOUSTIC_SENSOR_SEQUENCES; (*this)[PBS::HYDROPHONE] = PBS::HYDROPHONE_SEQUENCES; } /** * Get %PBS sequences for the given %PBS. * * \param pbs %PBS * \return %PBS sequences */ JPBSSequences operator()(const JPBS_t& pbs) const { const_iterator p = this->find(pbs); if (p != this->end()) { return p->second; } else { JPBSSequence buffer; for (JPBS_t i = pbs; !i.empty(); i.pop_back()) { buffer.push_back(i); } return buffer; } } }; /** * Function object to get %PBS sequences as a function of %PBS. */ static JGetPBSSequences getPBSSequences; } #endif