00001 // ===================================================================== 00021 // ===================================================================== 00022 #ifndef __TUSERINTERFACE_HH 00023 #define __TUSERINTERFACE_HH 00024 00025 #include "Tglobals.h" 00026 #include "TCommandHistory.hh" 00027 #include "TCommandTable.hh" 00028 00029 class TCommand; 00030 00031 00051 class TUserInterface 00052 { 00053 00054 protected: 00055 TCommandTable theCommandTable; 00056 Tofstream theHistoryFileStream; 00057 Tstring theCurrentWorkingDirectory; 00058 TCommandHistory theCommandHistory; 00059 00060 public: 00061 TUserInterface( const Tstring& history ); 00062 virtual ~TUserInterface(); 00063 00064 public: 00065 Tint AddCommand( TCommand* command ); 00066 Tint RemoveCommand( Tint index ); 00067 Tvoid ClearCommands(); 00068 TCommand* FindCommand( const Tstring& fullname ); 00069 TCommand* FindCommand( const Tstring& name, const Tstring& path ); 00070 TCommand* GetCommand( Tint index ); 00071 TCommand* GetCommand( const Tstring& fullname ); 00072 TCommand* GetCommand( const Tstring& name, const Tstring& path ); 00073 Tvoid ExecuteCommand( const Tstring& command, const TstringList& arguments ); 00074 Tvoid ExecuteCommand( const Tstring& command ); 00075 Tint GetCurrentWorkingDirectoryLevel() const; 00076 Tstring ModifyPath( const Tstring& path ) const; 00077 00078 public: 00079 const TCommandTable& GetCommandTable() const; 00080 TCommandTable& GetCommandTable(); 00081 const Tstring& GetCurrentWorkingDirectory() const; 00082 Tstring& GetCurrentWorkingDirectory(); 00083 const TCommandHistory& GetCommandHistory() const; 00084 TCommandHistory& GetCommandHistory(); 00085 Tofstream& GetHistoryFileStream(); 00086 Tvoid SetCommandTable( const TCommandTable& table ); 00087 Tvoid SetCurrentWorkingDirectory( const Tstring& directory ); 00088 Tvoid SetCommandHistory( const TCommandHistory& history ); 00089 00090 public: 00091 virtual Tbool AcceptCommand() = 0; 00092 virtual const Tstring& GetInputCommand() = 0; 00093 00094 public: 00095 virtual Tvoid NotFoundCommand( const Tstring& commandname ) const; 00096 virtual Tvoid ClearScreen() const; 00097 virtual Tint GetNumberOfColumns() const; 00098 virtual Tint GetNumberOfLines() const; 00099 00100 }; 00101 00102 inline const TCommandTable& TUserInterface::GetCommandTable() const 00103 { 00104 return theCommandTable; 00105 } 00106 00107 inline TCommandTable& TUserInterface::GetCommandTable() 00108 { 00109 return theCommandTable; 00110 } 00111 00112 inline const Tstring& TUserInterface::GetCurrentWorkingDirectory() const 00113 { 00114 return theCurrentWorkingDirectory; 00115 } 00116 00117 inline Tstring& TUserInterface::GetCurrentWorkingDirectory() 00118 { 00119 return theCurrentWorkingDirectory; 00120 } 00121 00122 inline const TCommandHistory& TUserInterface::GetCommandHistory() const 00123 { 00124 return theCommandHistory; 00125 } 00126 00127 inline TCommandHistory& TUserInterface::GetCommandHistory() 00128 { 00129 return theCommandHistory; 00130 } 00131 00132 inline Tofstream& TUserInterface::GetHistoryFileStream() 00133 { 00134 return theHistoryFileStream; 00135 } 00136 00137 inline Tvoid TUserInterface::SetCommandTable( const TCommandTable& table ) 00138 { 00139 theCommandTable = table; 00140 return; 00141 } 00142 00143 inline Tvoid TUserInterface::SetCommandHistory( const TCommandHistory& history ) 00144 { 00145 theCommandHistory = history; 00146 return; 00147 } 00148 00149 #endif