/** \file
 *
 *  Contains the BinaryLogWriter class definition.
 *
 *  Copyright (c) 2007,2008,2009 MBARI
 *  MBARI Proprietary Information.  All Rights Reserved
 *
 */

#ifndef BINARYLOGWRITER_H_
#define BINARYLOGWRITER_H_

#include "LogWriter.h"

#include "io/OutStream.h"

/**
 *  Defines a LogWriter specific to writing binary values to a stream
 *  See FileLogWriter for output to the filesystem.
 *
 *  \ingroup logging
 */
class BinaryLogWriter : public LogWriter
{
public:
    /** Default Constructor
     * Assumes that the stream will be assigned later via setOutStream()
     *
     * \param withDirectory If true, include DirectoryEntry entries.
     */
    BinaryLogWriter( bool withDirectory = false, bool debug = false );

    /** Constructor, takes an OutStream.
     *
     * \param stream An OutStream for output.
     * \param withDirectory If true, include DirectoryEntry entries.
     */
    BinaryLogWriter( OutStream &stream, bool withDirectory = false );

    /// Destructor.
    virtual ~BinaryLogWriter();

    /// Start the binary log
    virtual unsigned int writeHeader();

    /// Write an entry to the log
    ///
    /// \param entry The LogEntry to write/serialize
    /// \param unit optional unit to express the value in
    /// \return Returns number of bytes written
    virtual unsigned int write( const LogEntry *entry, const Unit* unit = NULL );

    /// Calling this resets the time base to "zero"
    virtual void resetTimeBase()
    {
        timeBase_ = Timestamp::NOT_SET_TIME;
    }

protected:

    /// Start of the cycle time
    Timestamp timeBase_;

    bool withDirectory_, debug_;

};

#endif /*BINARYLOGWRITER_H_*/
