#ifndef __JACOUSTICS__JSUPEREVT__ #define __JACOUSTICS__JSUPEREVT__ #include #include #include #include #include #include "JLang/JManip.hh" #include "JIO/JSerialisable.hh" #include "JIO/JSTDIO.hh" #include "JAcoustics/JEvt.hh" /** * \file * * Acoustic event fit. * \author mdejong */ namespace JACOUSTICS {} namespace JPP { using namespace JACOUSTICS; } namespace JACOUSTICS { using JIO::JSerialisable; using JIO::JReader; using JIO::JWriter; /** * Acoustic super event fit. */ struct JSuperEvt : public virtual JSerialisable, public JEvt { /** * Default constructor. */ JSuperEvt() : JEvt() {} /** * Constructor. * * \param event event */ JSuperEvt(const JEvt& event) : JEvt(event) {} /** * Acoustics emission. */ struct tx_t { tx_t() : id (-1), counter(-1), toe (0.0) {} tx_t(const int id, const int counter, const double toe) : id (id), counter(counter), toe (toe) {} /** * Read emission from input. * * \param in reader * \param object emission * \return reader */ friend inline JReader& operator>>(JReader& in, tx_t& object) { in >> object.id; in >> object.counter; in >> object.toe; return in; } /** * Write emission to output. * * \param out writer * \param object emission * \return writer */ friend inline JWriter& operator<<(JWriter& out, const tx_t& object) { out << object.id; out << object.counter; out << object.toe; return out; } int id; int counter; double toe; }; /** * Acoustics transmission. */ struct rx_t { rx_t() : id (-1), counter(-1), string (-1), floor (-1), toa (0.0), weight (0.0) {} rx_t(const int id, const int counter, const int string, const int floor, const double toa, const double weight) : id (id), counter(counter), string (string), floor (floor), toa (toa), weight (weight) {} /** * Read transmission from input. * * \param in reader * \param object transmission * \return reader */ friend inline JReader& operator>>(JReader& in, rx_t& object) { in >> object.id; in >> object.counter; in >> object.string; in >> object.floor; in >> object.toa; in >> object.weight; return in; } /** * Write transmission to output. * * \param out writer * \param object transmission * \return writer */ friend inline JWriter& operator<<(JWriter& out, const rx_t& object) { out << object.id; out << object.counter; out << object.string; out << object.floor; out << object.toa; out << object.weight; return out; } int id; int counter; int string; int floor; double toa; double weight; }; typedef std::vector tx_type; typedef std::vector rx_type; tx_type tx; rx_type rx; /** * Write super event to output. * * \param out output stream * \param event super event * \return output stream */ friend inline std::ostream& operator<<(std::ostream& out, const JSuperEvt& event) { using namespace std; out << static_cast(event); for (JSuperEvt::tx_type::const_iterator i = event.tx.begin(); i != event.tx.end(); ++i) { out << setw(2) << i->id << ' ' << setw(6) << i->counter << ' ' << FIXED(20,6) << i->toe << endl; } for (JSuperEvt::rx_type::const_iterator i = event.rx.begin(); i != event.rx.end(); ++i) { out << setw(2) << i->id << ' ' << setw(6) << i->counter << ' ' << setw(4) << i->string << ' ' << setw(2) << i->floor << ' ' << FIXED(20,6) << i->toa << ' ' << FIXED( 5,2) << i->weight << endl; } return out; } /** * Read from input. * * \param in reader * \return reader */ virtual JReader& read(JReader& in) override { JEvt::read(in); in >> this->rx; in >> this->tx; return in; } /** * Write to output. * * \param out writer * \return writer */ virtual JWriter& write(JWriter& out) const override { JEvt::write(out); out << this->rx; out << this->tx; return out; } ClassDefOverride(JSuperEvt, 1); }; } #endif