#ifndef __JIO__JBINARYFILEWRITER__ #define __JIO__JBINARYFILEWRITER__ #include #include "JLang/JAccessibleBinaryStream.hh" #include "JLang/JObjectOutput.hh" #include "JLang/JTypeList.hh" #include "JLang/JNullType.hh" #include "JIO/JStreamIO.hh" #include "JIO/JWriterObjectOutput.hh" /** * \author mdejong */ namespace JIO {} namespace JPP { using namespace JIO; } namespace JIO { using JLANG::JAccessibleObjectOutput; using JLANG::JAccessibleBinaryOutputStream; using JLANG::JObjectOutput; using JLANG::JNullOutput; using JLANG::JTypeList; using JLANG::JNullType; /** * Auxiliary class for object writing to binary stream. */ template::is_derived> class JBinaryWriterObjectOutput; /** * Implementation of object output for binary stream compatible data types. * * This class implements the JLANG::JObjectOutput interface. */ template class JBinaryWriterObjectOutput : public JWriterObjectOutput { protected: /** * Constructor. * * \param writer JWriter output */ JBinaryWriterObjectOutput(JWriter& writer) : JWriterObjectOutput(writer) {} }; /** * Implementation of object output for binary stream incompatible data types. * * This class implements the JLANG::JObjectOutput interface by doing nothing. */ template class JBinaryWriterObjectOutput : public JNullOutput { protected: /** * Constructor. * * \param writer JWriter output */ JBinaryWriterObjectOutput(JWriter& writer) {} }; /** * Implementation of object output to binary file for single data type. * * This class implements the JLANG::JObjectOutput interface. */ template class JBinaryWriter : public JBinaryWriterObjectOutput { protected: /** * Constructor. * * \param writer JWriter output */ JBinaryWriter(JWriter& writer) : JBinaryWriterObjectOutput(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: * - JBinaryWriter; and * - JBinaryWriter. */ template class JBinaryWriter< JTypeList > : public virtual JObjectOutput< JTypeList >, public JBinaryWriter, public JBinaryWriter { protected: /** * Constructor. * * \param writer JWriter output */ JBinaryWriter(JWriter& writer) : JBinaryWriter(writer), JBinaryWriter(writer) {} }; /** * Terminator class of recursive JBinaryWriter class. */ template class JBinaryWriter< JTypeList > : public JBinaryWriter { protected: /** * Constructor. * * \param writer JWriter output */ JBinaryWriter(JWriter& writer) : JBinaryWriter(writer) {} }; /** * Object(s) writing to binary file (i.e.\ .jpp). * * This class implements the JLANG::JAccessibleObjectOutput interface. */ template class JBinaryFileWriter : public JAccessibleObjectOutput, public JAccessibleBinaryOutputStream, protected JStreamWriter, public JBinaryWriter { public: /** * Default constructor. */ JBinaryFileWriter() : JAccessibleBinaryOutputStream(), JStreamWriter (static_cast(*this)), JBinaryWriter(static_cast (*this)) {} }; } #endif