Go to the documentation of this file.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/Service.hpp>
00064 #include <deque>
00065 #include <string>
00066 #include <sstream>
00067 #include <vector>
00068 #if defined(HAS_READLINE) && !defined(HAS_EDITLINE) && defined(_POSIX_VERSION)
00069 #include <signal.h>
00070 #endif
00071
00072 #include <ocl/OCL.hpp>
00073
00074 namespace OCL
00075 {
00086 class OCL_API TaskBrowser
00087 : public RTT::TaskContext
00088 {
00089
00090 static RTT::TaskContext* taskcontext;
00091
00092 static RTT::TaskContext* peer;
00093
00094 static RTT::TaskContext* tb;
00095
00096 static RTT::TaskContext* context;
00097 static RTT::Service::shared_ptr taskobject;
00098 RTT::internal::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 bool usehex;
00108
00109 std::deque<RTT::TaskContext*> taskHistory;
00110
00111
00112 typedef std::map<std::pair<RTT::TaskContext*,std::string>,int> PTrace;
00113 PTrace ptraces;
00114 PTrace straces;
00115
00118 base::DataSourceBase::shared_ptr last_expr;
00119 #if defined(HAS_READLINE) || defined(HAS_EDITLINE)
00120 #if defined(_POSIX_VERSION) && !defined(HAS_EDITLINE)
00121 static void rl_sigwinch_handler(int sig, siginfo_t *si, void *ctxt);
00122 #endif
00123
00124 static int rl_received_signal;
00125 static void rl_signal_handler(int sig, siginfo_t *si, void *ctxt);
00126
00127
00128 static int rl_getc(FILE *);
00129
00130
00131
00132 char *rl_gets ();
00133
00134
00135 static std::vector<std::string> candidates;
00136
00137 static std::vector<std::string> completes;
00138 static std::vector<std::string>::iterator complete_iter;
00139
00140 static std::string component_found;
00141 static std::string component;
00142 static std::string peerpath;
00143 static std::string text;
00144
00145
00146 static char* dupstr( const char *s );
00147
00148 static void find_completes();
00149
00150 static void find_ops();
00151 static void find_peers(std::string::size_type startpos);
00152
00153 static char ** orocos_hmi_completion ( const char *text, int start, int end );
00154
00155 static char *command_generator( const char *_text, int state );
00156 #endif
00157 static RTT::TaskContext* findPeer( std::string comm );
00158
00159 protected:
00160
00161 void listText(std::stringstream& txtss,int start, int end, int ln, char s);
00162
00163 void doPrint( RTT::base::DataSourceBase::shared_ptr ds, bool recurse);
00164
00165 void enterTask();
00166 void leaveTask();
00167
00168 bool macrorecording;
00169 std::string macrotext;
00170 std::string macroname;
00171 std::stringstream sresult;
00172 void recordMacro(std::string name);
00173 void cancelMacro();
00174 void endMacro();
00175
00176 void checkPorts();
00177 Service::shared_ptr stringToService(std::string const& names);
00178 public:
00179
00183 enum ColorTheme { nocolors,
00184 darkbg,
00185 whitebg
00186 };
00187
00188 void setColorTheme( ColorTheme t );
00189
00195 void switchTaskContext(std::string& path);
00196
00203 void switchTaskContext( RTT::TaskContext* tc, bool store = true);
00204
00208 void switchBack();
00209
00215 void browserAction(std::string& act );
00216
00220 void printResult( RTT::base::DataSourceBase* ds, bool recurse);
00221
00225 void printHelp();
00226
00230 void printHelp(std::string command);
00231
00235 void printInfo(const std::string& peerpath);
00236
00240 void printSource( const std::string m );
00241
00245 void printOperation( const std::string m, Service::shared_ptr ops );
00246
00250 bool printService( const std::string name);
00251
00255 void printProgram( const std::string& pn, int line = -1, RTT::TaskContext* progpeer = 0 );
00256
00260 void printProgram( int line = -1 );
00261
00266 TaskBrowser( RTT::TaskContext* c );
00267
00268 ~TaskBrowser();
00269
00275 void loop();
00276
00283 void evaluate(std::string& comm );
00284
00288 void switchTask( RTT::TaskContext* c);
00289
00293 static std::string prompt;
00297 static std::string coloron;
00301 static std::string underline;
00305 static std::string coloroff;
00306
00310 static std::string red;
00311
00315 static std::string green;
00316
00320 static std::string blue;
00321
00325 void evalCommand(std::string& comm );
00326
00327
00328 };
00329
00330 }
00331
00332 #endif