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

#ifndef MILTILOGWRITER_H_
#define MILTILOGWRITER_H_

#include "LogWriter.h"

#include "logger/DecimationLogWriter.h"
#include "logger/LogEngine.h"
#include "utils/FastMap.h"

class AllLogWriter;
class DataValue;
class LinearApproxLogWriter;
class MultiLogWriter;

/// Base class for a generalized set of "log data destinations," including
/// to files (text or binary), over communications links, etc.
///
/// \ingroup logging
class MultiLogWriter : public LogWriter
{
public:

    /// Constructor
    MultiLogWriter( LogWriter& outputTo, const Str& name );

    /// Destructor
    virtual ~MultiLogWriter();

    /// Write the log header, if any
    virtual unsigned int writeHeader();

    /// Write the given LogEntry - should lock the writeMutex_
    virtual unsigned int write( const LogEntry* entry, const Unit* unit = NULL );

    /// Write the log footer, if any
    virtual unsigned int writeFooter();

    void resetDirectoryEntries();

    unsigned int forceWrite( DataEntry* dataEntry );

    unsigned int writeSyslog( const SyslogEntry* syslogEntry );

    unsigned int flush();

protected:

    friend class DecimationLogManager;

    DecimationLogWriter* getCurrent()
    {
        return currentLogWriter_;
    }

    void setCurrent( DecimationLogWriter* newLogWriter );

    LogWriter& outputTo_;
    const Str varName_;
    const bool makeDirEntries_;
    bool nameWritten_;
    DataAccess* dataAccess_;
    bool dataAccessHidden_;

    DecimationLogWriter* currentLogWriter_;

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

};

#endif /*MILTILOGWRITER_H_*/
