#ifndef __JSUPPORT__JDAQFILEWRITER__ #define __JSUPPORT__JDAQFILEWRITER__ #include #include "JIO/JWriterObjectOutput.hh" #include "JIO/JStreamIO.hh" #include "JDAQ/JDAQPreambleIO.hh" #include "JLang/JAccessibleBinaryStream.hh" #include "JLang/JObjectOutput.hh" #include "JLang/JTypeList.hh" #include "JLang/JNullType.hh" #include "JLang/JObjectOutput.hh" #include "JLang/JConversion.hh" /** * \author mdejong */ namespace JSUPPORT {} namespace JPP { using namespace JSUPPORT; } namespace JSUPPORT { using JIO::JWriter; using JIO::JWriterObjectOutput; using JIO::JStreamWriter; using KM3NETDAQ::JDAQPreamble; using JLANG::JAccessibleBinaryOutputStream; using JLANG::JObjectOutput; using JLANG::JAccessibleObjectOutput; using JLANG::JNullOutput; using JLANG::JTypeList; using JLANG::JNullType; /** * Auxiliary class for DAQ object writing to binary stream. */ template::is_derived> class JDAQWriterObjectOutput; /** * Implementation of object output for DAQ compatible data types. * * This class implements the JLANG::JObjectOutput interface. */ template class JDAQWriterObjectOutput : public JWriterObjectOutput { protected: /** * Constructor. * * \param writer JWriter output */ JDAQWriterObjectOutput(JWriter& writer) : JWriterObjectOutput(writer) {} }; /** * Implementation of object output for DAQ incompatible data types. * * This class implements the JLANG::JObjectOutput interface by doing nothing. */ template class JDAQWriterObjectOutput : public JNullOutput { protected: /** * Constructor. * * \param writer JWriter output */ JDAQWriterObjectOutput(JWriter& writer) {} }; /** * Implementation of object output to binary file for single data type. * * This class implements the JLANG::JObjectOutput interface. */ template class JDAQWriter : public JDAQWriterObjectOutput { protected: /** * Constructor. * * \param writer JWriter output */ JDAQWriter(JWriter& writer) : JDAQWriterObjectOutput(writer) {} }; /** * Implementation of object output to binary file for multiple data types. * * This class recursively implements the JLANG::JObjectOutput interface * for all data types by deriving from: * - JDAQWriter; and * - JDAQWriter. */ template class JDAQWriter< JTypeList > : public virtual JObjectOutput< JTypeList >, public JDAQWriter, public JDAQWriter { protected: /** * Constructor. * * \param writer JWriter output */ JDAQWriter(JWriter& writer) : JDAQWriter(writer), JDAQWriter(writer) {} }; /** * Terminator class of recursive JDAQWriter class. */ template class JDAQWriter< JTypeList > : public JDAQWriter { protected: /** * Constructor. * * \param writer JWriter output */ JDAQWriter(JWriter& writer) : JDAQWriter(writer) {} }; /** * Object(s) writing to binary file (i.e.\ .dat). * * This class implements the JLANG::JAccessibleObjectOutput interface. */ template class JDAQFileWriter : public JAccessibleBinaryOutputStream, public JStreamWriter, public JDAQWriter, public JAccessibleObjectOutput { public: /** * Default constructor. */ JDAQFileWriter() : JAccessibleBinaryOutputStream(), JStreamWriter(static_cast(*this)), JDAQWriter(static_cast (*this)) {} }; } #endif