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