// =====================================================================
/*!
//
//  \file TUserInterface.hh
//  \brief This file contains the TUserInterface class.
//  \author Go IWAI <goiwai@users.sourceforge.jp>
//
//  $Id: TUserInterface.hh,v 1.6 2004/03/07 10:30:31 goiwai Exp $
//  $Name: CLDAQ-1-14-06 $
//  $Log: TUserInterface.hh,v $
//  Revision 1.6  2004/03/07 10:30:31  goiwai
//  ROOTに組みこむためのおまじないマクロを埋めこみました。
//  全てにおいて完全に動作するわけではありません。
//
//  Revision 1.5  2004/01/19 21:09:40  goiwai
//  プリプロセッサの接頭辞をCLDAQ__に変更しました.
//
//  Revision 1.4  2003/11/03 08:35:12  goiwai
//  Doxygen用のタグとコメントをうちこんでいく試みを開始しました.
//
//  Revision 1.3  2003/10/06 17:02:40  goiwai
//  *** empty log message ***
//
//  Revision 1.2  2003/07/30 16:18:52  goiwai
//  ファイルにコミットログをつけることにしました.
//
*/
// =====================================================================
#ifndef CLDAQ__TUSERINTERFACE_HH
#define CLDAQ__TUSERINTERFACE_HH

#include "Tglobals.h"
#include "TCommandHistory.hh"
#include "TCommandTable.hh"

class TCommand;


/*!
// \example
//
// If example code exists.
//
*/

/*!
// \class TUserInterface
// \brief This is the TUserInterface class.
// \author Go IWAI <goiwai@users.sourceforge.jp>
//
// The TUserInterface class detail description.
// Write it down ASAP!
//
// \todo None?
// \bug None?
// \ingroup InterfacesCategory
*/
class TUserInterface
{

  protected:
    TCommandTable theCommandTable;
    Tofstream theHistoryFileStream;
    Tstring theCurrentWorkingDirectory;
    TCommandHistory theCommandHistory;

  public:
    TUserInterface( const Tstring& history );
    virtual ~TUserInterface();

  public:
    Tint AddCommand( TCommand* command );
    Tint RemoveCommand( Tint index );
    Tvoid ClearCommands();
    TCommand* FindCommand( const Tstring& fullname );
    TCommand* FindCommand( const Tstring& name, const Tstring& path );
    TCommand* GetCommand( Tint index );
    TCommand* GetCommand( const Tstring& fullname );
    TCommand* GetCommand( const Tstring& name, const Tstring& path );
    Tvoid ExecuteCommand( const Tstring& command, const TstringList& arguments );
    Tvoid ExecuteCommand( const Tstring& command );
    Tint GetCurrentWorkingDirectoryLevel() const;
    Tstring ModifyPath( const Tstring& path ) const;

  public:
    const TCommandTable& GetCommandTable() const;
    TCommandTable& GetCommandTable();
    const Tstring& GetCurrentWorkingDirectory() const;
    Tstring& GetCurrentWorkingDirectory();
    const TCommandHistory& GetCommandHistory() const;
    TCommandHistory& GetCommandHistory();
    Tofstream& GetHistoryFileStream();
    Tvoid SetCommandTable( const TCommandTable& table );
    Tvoid SetCurrentWorkingDirectory( const Tstring& directory );
    Tvoid SetCommandHistory( const TCommandHistory& history );

  public:
    virtual Tbool AcceptCommand() = 0;
    virtual const Tstring& GetInputCommand() = 0;

  public:
    virtual Tvoid NotFoundCommand( const Tstring& commandname ) const;
    virtual Tvoid ClearScreen() const;
    virtual Tint GetNumberOfColumns() const;
    virtual Tint GetNumberOfLines() const;

#ifdef __CLDAQ_ROOT_DLL
    ClassDef(TUserInterface,0)
#endif

};

inline const TCommandTable& TUserInterface::GetCommandTable() const
{
  return theCommandTable;
}

inline TCommandTable& TUserInterface::GetCommandTable()
{
  return theCommandTable;
}

inline const Tstring& TUserInterface::GetCurrentWorkingDirectory() const
{
  return theCurrentWorkingDirectory;
}

inline Tstring& TUserInterface::GetCurrentWorkingDirectory()
{
  return theCurrentWorkingDirectory;
}

inline const TCommandHistory& TUserInterface::GetCommandHistory() const
{
  return theCommandHistory;
}

inline TCommandHistory& TUserInterface::GetCommandHistory()
{
  return theCommandHistory;
}

inline Tofstream& TUserInterface::GetHistoryFileStream()
{
  return theHistoryFileStream;
}

inline Tvoid TUserInterface::SetCommandTable( const TCommandTable& table )
{
  theCommandTable = table;
  return;
}

inline Tvoid TUserInterface::SetCommandHistory( const TCommandHistory& history )
{
  theCommandHistory = history;
  return;
}

#endif
