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

#ifndef DIRECTORYMANAGINGLOGWRITER_H_
#define DIRECTORYMANAGINGLOGWRITER_H_

#include "logger/TableLogWriter.h"

#include "utils/FlexArray.h"

class DataEntry;

/**
 *  Defines a LogWriter that can insert directory entries into a stream of data that
 *  is written to it, and handed off to the LogWriter provided in the outputTo constructor argument.
 *
 *  \ingroup logging
 */
class DirectoryManagingLogWriter : public LogWriter
{
public:
    DirectoryManagingLogWriter( LogWriter& outputTo );

    virtual ~DirectoryManagingLogWriter();

    void resetDirectoryEntries();

    unsigned int writeHeader();

    unsigned int writeFooter();

    unsigned int write( const LogEntry* entry, const Unit* unit );

    unsigned int writeData( const DataEntry* dataEntry, const Unit* unit );

    unsigned int writeSyslog( const SyslogEntry* syslogEntry );

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

    /// Stores an LogWriter.
    LogWriter& outputTo_;

    FlexArray< int* > nameWrites_;
    FlexArray< int* > elementWrites_;

};

#endif /*DIRECTORYMANAGINGLOGWRITER_H_*/
