00001 #ifndef NO_GPL
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #else
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 #endif
00056
00057 #ifndef ORO_TASKBROWSER_HPP
00058 #define ORO_TASKBROWSER_HPP
00059
00060
00061 #include <rtt/RTT.hpp>
00062 #include <rtt/TaskContext.hpp>
00063 #include "rtt/OperationInterface.hpp"
00064 #include "rtt/DispatchInterface.hpp"
00065 #include <deque>
00066 #include <string>
00067 #include <sstream>
00068 #include <vector>
00069
00070 #include <ocl/OCL.hpp>
00071
00072 namespace OCL
00073 {
00084 class OCL_API TaskBrowser
00085 : public RTT::TaskContext
00086 {
00087
00088 static RTT::TaskContext* taskcontext;
00089
00090 static RTT::TaskContext* peer;
00091
00092 static RTT::TaskContext* tb;
00093
00094 static RTT::TaskContext* context;
00095 static RTT::OperationInterface* taskobject;
00096 RTT::ConditionInterface* condition;
00097 RTT::DispatchInterface* command;
00098 RTT::DataSource<bool>::shared_ptr accepted;
00099
00100 int debug;
00101
00102 char *line_read;
00103 int lastc;
00104
00105 std::string storedname;
00106 int storedline;
00107
00108 std::deque<TaskContext*> taskHistory;
00109
00110
00111 typedef std::map<std::pair<TaskContext*,std::string>,int> PTrace;
00112 PTrace ptraces;
00113 PTrace straces;
00114
00115 #if defined(HAS_READLINE) || defined(HAS_EDITLINE)
00116
00117
00118 char *rl_gets ();
00119
00120
00121 static std::vector<std::string> candidates;
00122
00123 static std::vector<std::string> completes;
00124 static std::vector<std::string>::iterator complete_iter;
00125
00126 static std::string component;
00127 static std::string peerpath;
00128 static std::string text;
00129
00130
00131 static char* dupstr( const char *s );
00132
00133 static void find_completes();
00134
00135 static void find_ops();
00136 static void find_peers(std::string::size_type startpos);
00137
00138 static char ** orocos_hmi_completion ( const char *text, int start, int end );
00139
00140 static char *command_generator( const char *_text, int state );
00141 #endif
00142 static RTT::TaskContext* findPeer( std::string comm );
00143
00144 protected:
00145
00146 void listText(std::stringstream& txtss,int start, int end, int ln, char s);
00147
00148 void doPrint( RTT::DataSourceBase* ds, bool recurse);
00149
00150 void enterTask();
00151 void leaveTask();
00152
00153 bool macrorecording;
00154 std::string macrotext;
00155 std::string macroname;
00156 std::stringstream sresult;
00157 void recordMacro(std::string name);
00158 void cancelMacro();
00159 void endMacro();
00160
00161 void checkPorts();
00162 public:
00163
00167 enum ColorTheme { nocolors,
00168 darkbg,
00169 whitebg
00170 };
00171
00172 void setColorTheme( ColorTheme t );
00173
00179 void switchTaskContext(std::string& path);
00180
00187 void switchTaskContext( RTT::TaskContext* tc, bool store = true);
00188
00192 void switchBack();
00193
00199 void browserAction(std::string& act );
00200
00204 void printResult( RTT::DataSourceBase* ds, bool recurse);
00205
00209 void printHelp();
00210
00214 void printInfo(const std::string& peerpath);
00215
00219 void printCommand( const std::string c, OperationInterface* ops );
00220
00224 void printSource( const std::string m );
00225
00229 void printMethod( const std::string m, OperationInterface* ops );
00230
00234 void printEvent( const std::string m, RTT::EventService* ops );
00235
00239 void printProgram( const std::string& pn, int line = -1, TaskContext* progpeer = 0 );
00240
00244 void printProgram( int line = -1 );
00245
00250 TaskBrowser( RTT::TaskContext* c );
00251
00252 ~TaskBrowser();
00253
00259 void loop();
00260
00267 void evaluate(std::string& comm );
00268
00272 void switchTask( RTT::TaskContext* c);
00273
00277 static std::string prompt;
00281 static std::string coloron;
00285 static std::string underline;
00289 static std::string coloroff;
00290
00294 static std::string red;
00295
00299 static std::string green;
00300
00304 static std::string blue;
00305
00309 void evalCommand(std::string& comm );
00310
00311
00312 };
00313
00314 }
00315
00316 #endif