// =====================================================================
//  $Id: TEventManager.hh,v 1.2 2003/06/30 03:44:07 goiwai Exp $
//  $Name: CLDAQ-1-06-02 $
// =====================================================================
#ifndef __TEVENTMANAGER_HH
#define __TEVENTMANAGER_HH

#include "Tglobals.h"
#include "TEvent.hh"
//#include "TSystemTimer.hh"

class TRun;
class TEventAction;

class TEventManager
{

  private:
    static TEventManager* theEventManager;

  public:
    enum { tDefaultStackSize = 100 };

  private:
    Tstatus_t theStatus;
    Tint theStackSize;
    Tint theNumberOfEvents;
    TEventAction* theEventAction;
    TEvent theEvent;
    //TSystemTimer theEventTimer;

  public:
    TEventManager( Tint stacksize = tDefaultStackSize );
    virtual ~TEventManager();

  public:
    Tint GetStackSize() const;
    Tint GetNumberOfEvents() const;
    const TEvent& GetEvent() const;
    TEvent& GetEvent();
    TEventAction* GetEventAction() const;
    Tvoid SetStackSize( Tint stacksize );
    Tvoid SetNumberOfEvents( Tint nevents );
    Tvoid SetEvent( const TEvent& event );
    Tvoid SetEventAction( TEventAction* action );
    Tstatus_t GetStatus() const;
    Tvoid SetStatus( Tstatus_t status );
    //const TSystemTimer& GetEventTimer() const;
    //TSystemTimer& GetEventTimer();
    //Tvoid SetEventTimer( const TSystemTimer& timer );

  public:
    virtual const TRun& RecordEvent();
    virtual const TEvent& TakeEvent();
    virtual Tvoid ShowStatus() const;
    virtual Tvoid Clear();

  public:
    static TEventManager* GetEventManager();

};

inline TEventManager* TEventManager::GetEventManager()
{
  return( theEventManager );
}

inline Tint TEventManager::GetStackSize() const
{
  return( theStackSize );
}

inline Tint TEventManager::GetNumberOfEvents() const
{
  return( theNumberOfEvents );
}

inline const TEvent& TEventManager::GetEvent() const
{
  return( theEvent );
}

inline TEvent& TEventManager::GetEvent()
{
  return( theEvent );
}

inline TEventAction* TEventManager::GetEventAction() const
{
  return( theEventAction );
}

inline Tvoid TEventManager::SetNumberOfEvents( Tint nevents )
{
  theNumberOfEvents = nevents;
  return;
}

inline Tvoid TEventManager::SetEvent( const TEvent& event )
{
  theEvent = event;
  return;
}

inline Tstatus_t TEventManager::GetStatus() const
{
  return( theStatus );
}

inline Tvoid TEventManager::SetStatus( Tstatus_t status )
{
  theStatus = status;
  return;
}

// inline const TSystemTimer& TEventManager::GetEventTimer() const
// {
//   return( theEventTimer );
// }

// inline TSystemTimer& TEventManager::GetEventTimer()
// {
//   return( theEventTimer );
// }

// inline Tvoid TEventManager::SetEventTimer( const TSystemTimer& timer )
// {
//   theEventTimer = timer;
//   return;
// }

#endif
