00001 // ===================================================================== 00002 // $Id: TUserInterface.hh,v 1.1.1.1 2003/06/27 02:56:42 goiwai Exp $ 00003 // $Name: CLDAQ-1-06-00 $ 00004 // ===================================================================== 00005 #ifndef __TUSERINTERFACE_HH 00006 #define __TUSERINTERFACE_HH 00007 00008 #include "Tglobals.h" 00009 #include "TCommandHistory.hh" 00010 #include "TCommandTable.hh" 00011 00012 class TCommand; 00013 00014 class TUserInterface 00015 { 00016 00017 protected: 00018 TCommandTable theCommandTable; 00019 Tofstream theHistoryFileStream; 00020 Tstring theCurrentWorkingDirectory; 00021 TCommandHistory theCommandHistory; 00022 00023 public: 00024 TUserInterface( const Tstring& history ); 00025 virtual ~TUserInterface(); 00026 00027 public: 00028 Tint AddCommand( TCommand* command ); 00029 Tint RemoveCommand( Tint index ); 00030 Tvoid ClearCommands(); 00031 TCommand* FindCommand( const Tstring& fullname ); 00032 TCommand* FindCommand( const Tstring& name, const Tstring& path ); 00033 TCommand* GetCommand( Tint index ); 00034 TCommand* GetCommand( const Tstring& fullname ); 00035 TCommand* GetCommand( const Tstring& name, const Tstring& path ); 00036 Tvoid ExecuteCommand( const Tstring& command, const TstringList& arguments ); 00037 Tvoid ExecuteCommand( const Tstring& command ); 00038 Tint GetCurrentWorkingDirectoryLevel() const; 00039 Tstring ModifyPath( const Tstring& path ) const; 00040 00041 public: 00042 const TCommandTable& GetCommandTable() const; 00043 TCommandTable& GetCommandTable(); 00044 const Tstring& GetCurrentWorkingDirectory() const; 00045 Tstring& GetCurrentWorkingDirectory(); 00046 const TCommandHistory& GetCommandHistory() const; 00047 TCommandHistory& GetCommandHistory(); 00048 Tofstream& GetHistoryFileStream(); 00049 Tvoid SetCommandTable( const TCommandTable& table ); 00050 Tvoid SetCurrentWorkingDirectory( const Tstring& directory ); 00051 Tvoid SetCommandHistory( const TCommandHistory& history ); 00052 00053 public: 00054 virtual Tbool AcceptCommand() = 0; 00055 virtual const Tstring& GetInputCommand() = 0; 00056 00057 public: 00058 virtual Tvoid NotFoundCommand( const Tstring& commandname ) const; 00059 virtual Tvoid ClearScreen() const; 00060 virtual Tint GetNumberOfColumns() const; 00061 virtual Tint GetNumberOfLines() const; 00062 00063 }; 00064 00065 inline const TCommandTable& TUserInterface::GetCommandTable() const 00066 { 00067 return( theCommandTable ); 00068 } 00069 00070 inline TCommandTable& TUserInterface::GetCommandTable() 00071 { 00072 return( theCommandTable ); 00073 } 00074 00075 inline const Tstring& TUserInterface::GetCurrentWorkingDirectory() const 00076 { 00077 return( theCurrentWorkingDirectory ); 00078 } 00079 00080 inline Tstring& TUserInterface::GetCurrentWorkingDirectory() 00081 { 00082 return( theCurrentWorkingDirectory ); 00083 } 00084 00085 inline const TCommandHistory& TUserInterface::GetCommandHistory() const 00086 { 00087 return( theCommandHistory ); 00088 } 00089 00090 inline TCommandHistory& TUserInterface::GetCommandHistory() 00091 { 00092 return( theCommandHistory ); 00093 } 00094 00095 inline Tofstream& TUserInterface::GetHistoryFileStream() 00096 { 00097 return( theHistoryFileStream ); 00098 } 00099 00100 inline Tvoid TUserInterface::SetCommandTable( const TCommandTable& table ) 00101 { 00102 theCommandTable = table; 00103 return; 00104 } 00105 00106 inline Tvoid TUserInterface::SetCommandHistory( const TCommandHistory& history ) 00107 { 00108 theCommandHistory = history; 00109 return; 00110 } 00111 00112 #endif