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

#ifndef LOGQUEUE_H_
#define LOGQUEUE_H_

#include "LogEntry.h"
#include "utils/Mutex.h"
#include "utils/RingBuffer.h"

/// Typedef for a queue of log entries
typedef RingBuffer<LogEntry *> LogEntryQueue;

/// Singleton wrapper for queue
///
/// \ingroup logging
///
class LogQueue
{
public:

    /// Function for accessing singleton
    static LogQueue &Instance();

    /// Destructor
    ~LogQueue();

    /// Push onto write queue
    LogEntry* push( LogEntry *entry );

    /// Examine queue, but do not pop element
    LogEntry* peek( void );

    /// Pop out of read queue
    LogEntry* pop( void );

    /// Is read queue empty?
    bool isEmpty( void );

    // Constructor (normally protected but there are cases where you make a
    // supplemental LogQueue rather than the singleton)
    LogQueue();

protected:

    static void FlushQueues( bool andDelete = true );

private:
    /// The actual queues for LogEntry
    LogEntryQueue queue_;

    /// Clear either queue
    //void clear( QueueSelect queueSelect, bool andDelete = false );
    void clear( bool andDelete = false );

};

#endif /*LOGQUEUE_H_*/



