00001
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
00029 #ifndef ORO_TASKBROWSER_HPP
00030 #define ORO_TASKBROWSER_HPP
00031
00032
00033 #include <rtt/RTT.hpp>
00034 #include <rtt/TaskContext.hpp>
00035 #include "rtt/OperationInterface.hpp"
00036 #include "rtt/DispatchInterface.hpp"
00037 #include <deque>
00038 #include <string>
00039 #include <sstream>
00040 #include <vector>
00041
00042
00043 #include <ocl/OCL.hpp>
00044
00045 namespace OCL
00046 {
00057 class TaskBrowser
00058 : public RTT::TaskContext
00059 {
00060
00061 static RTT::TaskContext* taskcontext;
00062
00063 static RTT::TaskContext* peer;
00064
00065 static RTT::TaskContext* tb;
00066
00067 static RTT::TaskContext* context;
00068 static RTT::OperationInterface* taskobject;
00069 RTT::ConditionInterface* condition;
00070 RTT::DispatchInterface* command;
00071 RTT::DataSource<bool>::shared_ptr accepted;
00072
00073 int debug;
00074
00075 char *line_read;
00076 int lastc;
00077
00078 std::string storedname;
00079 int storedline;
00080
00081 std::deque<TaskContext*> taskHistory;
00082
00083
00084 typedef std::map<std::pair<TaskContext*,std::string>,int> PTrace;
00085 PTrace ptraces;
00086 PTrace straces;
00087
00088
00089
00090 char *rl_gets ();
00091
00092
00093 static std::vector<std::string> candidates;
00094
00095 static std::vector<std::string> completes;
00096 static std::vector<std::string>::iterator complete_iter;
00097
00098 static std::string component;
00099 static std::string object;
00100 static std::string peerpath;
00101 static std::string method;
00102 static std::string datasource;
00103 static std::string text;
00104
00105
00106 static char* dupstr( const char *s );
00107
00108 static RTT::TaskContext* findPeer( std::string comm );
00109
00110 static void find_completes();
00111
00112 static void find_ops();
00113 static void find_peers(std::string::size_type startpos);
00114
00115 static char ** orocos_hmi_completion ( const char *text, int start, int end );
00116
00117 static char *command_generator( const char *_text, int state );
00118
00119 protected:
00120
00121 void listText(std::stringstream& txtss,int start, int end, int ln, char s);
00122
00123 void doPrint( RTT::DataSourceBase* ds, bool recurse);
00124
00125 void enterTask();
00126 void leaveTask();
00127
00128 bool macrorecording;
00129 std::string macrotext;
00130 std::string macroname;
00131 void recordMacro(std::string name);
00132 void cancelMacro();
00133 void endMacro();
00134
00135 void checkPorts();
00136 public:
00137
00141 enum ColorTheme { nocolors,
00142 darkbg,
00143 whitebg
00144 };
00145
00146 void setColorTheme( ColorTheme t );
00147
00153 void switchTaskContext(std::string& path);
00154
00161 void switchTaskContext( RTT::TaskContext* tc, bool store = true);
00162
00166 void switchBack();
00167
00173 void browserAction(std::string& act );
00174
00178 void printResult( RTT::DataSourceBase* ds, bool recurse);
00179
00183 void printHelp();
00184
00188 void printInfo(const std::string& peerpath);
00189
00193 void printCommand( const std::string c, OperationInterface* ops );
00194
00198 void printSource( const std::string m );
00199
00203 void printMethod( const std::string m, OperationInterface* ops );
00204
00208 void printEvent( const std::string m, RTT::EventService* ops );
00209
00213 void printProgram( const std::string& pn, int line = -1, TaskContext* progpeer = 0 );
00214
00218 void printProgram( int line = -1 );
00219
00224 TaskBrowser( RTT::TaskContext* c );
00225
00226 ~TaskBrowser();
00227
00233 void loop();
00234
00241 void evaluate(std::string& comm );
00242
00246 void switchTask( RTT::TaskContext* c);
00247
00251 static std::string prompt;
00255 static std::string coloron;
00259 static std::string underline;
00263 static std::string coloroff;
00264
00268 static std::string red;
00269
00273 static std::string green;
00274
00278 static std::string blue;
00279
00283 void evalCommand(std::string& comm );
00284
00285
00286 };
00287
00288 }
00289
00290 #endif