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

#ifndef BINARYLOGREADER_H_
#define BINARYLOGREADER_H_

#include "LogReader.h"

#include "io/InStream.h"
#include "logger/Logger.h"
#include "utils/Timestamp.h"

class LogEngine;

/**
 *  Defines a LogReader specific to writing binary values to a stream
 *  See FileLogReader for input from the filesystem.
 *
 *  \ingroup logging
 */
class BinaryLogReader : public LogReader
{
public:
    /// Default Constructor.
    BinaryLogReader( Logger& sysLogger,
                     const Timestamp& startTime = Timestamp::NOT_SET_TIME,
                     const Timestamp& endTime = Timestamp::NOT_SET_TIME,
                     const Str& whileRunningName = Str::EMPTY_STR,
                     LogEngine* writeEngine = NULL, LogEngine* syslogEngine = NULL, bool debug = false );

    /// Destructor.
    virtual ~BinaryLogReader();

    /// Read the log
    virtual unsigned int read();

    Timespan getTimeAdjust()
    {
        return timeAdjust_;
    }

    void setTimeAdjust( const Timespan& timeAdjust )
    {
        timeAdjust_ = timeAdjust;
    }

    Timestamp getFirstTime()
    {
        return firstTime_;
    }

    Timestamp getLastTime()
    {
        return lastTime_;
    }

private:

    // Note that the copy constructor below is private and not given a body.
    // Any attempt to call it will return a compiler error.
    BinaryLogReader( const BinaryLogReader& old ); // disallow copy constructor

    /// Start of the cycle time
    Timestamp timeBase_;

    /// GPS Adjustment of time
    Timespan timeAdjust_;

    Logger& sysLogger_;
    const Timestamp& startTime_;
    const Timestamp& endTime_;
    const Str& whileRunningName_;
    LogEngine* writeEngine_;
    LogEngine* syslogEngine_;
    Timestamp firstTime_;
    Timestamp lastTime_;
    unsigned short whileRunningCode_;
    bool running_;
    bool debug_;
};

#endif /*BINARYLOGREADER_H_*/
