#ifndef __JAANET__JHEADWRITER__ #define __JAANET__JHEADWRITER__ #include "km3net-dataformat/offline/Head.hh" #include "JLang/JNullStream.hh" #include "JROOT/JRootDictionary.hh" #include "JROOT/JRootStreamer.hh" #include "JAAnet/JHead.hh" #include "JAAnet/JAAnetDictionary.hh" /** * \author mdejong */ namespace JAANET { using JLANG::JEquation; using JLANG::JEquationParameters; using JROOT::JRootDictionary_t; using JROOT::JRootWriter; /** * Implementation for Head output of JHead objects with ROOT dictionary. */ struct JHeadWriter : public JRootWriter { using JRootWriter::put; /** * Constructor. * * \param header header output * \param parameters equation parameters * \param dictionary dictionary */ JHeadWriter(Head& header, const JEquationParameters& parameters, const JRootDictionary_t& dictionary) : JRootWriter(JLANG::null, parameters, dictionary), header(header) {} /** * Write equation. * * \param equation equation * \return this ROOT writer */ virtual JRootWriter& put(const JEquation& equation) override { using namespace std; string key = equation.getKey(); for (int i = 1; header.find(key) != header.end(); ++i) { key = getTag(equation.getKey(), i); } header[key] = equation.getValue(); return *this; } private: Head& header; }; } #endif