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