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
00116
00117 const char* histfile;
00118
00121 base::DataSourceBase::shared_ptr last_expr;
00122 #if defined(HAS_READLINE) || defined(HAS_EDITLINE)
00123 #if defined(_POSIX_VERSION) && !defined(HAS_EDITLINE)
00124 static void rl_sigwinch_handler(int sig, siginfo_t *si, void *ctxt);
00125 #endif
00126
00127 static int rl_received_signal;
00128 static void rl_signal_handler(int sig, siginfo_t *si, void *ctxt);
00129
00130
00131 static int rl_getc(FILE *);
00132
00133
00134
00135 char *rl_gets ();
00136
00137
00138 static std::vector<std::string> candidates;
00139
00140 static std::vector<std::string> completes;
00141 static std::vector<std::string>::iterator complete_iter;
00142
00143 static std::string component_found;
00144 static std::string component;
00145 static std::string peerpath;
00146 static std::string text;
00147
00148
00149 static char* dupstr( const char *s );
00150
00151 static void find_completes();
00152
00153 static void find_ops();
00154 static void find_peers(std::string::size_type startpos);
00155
00156 static char ** orocos_hmi_completion ( const char *text, int start, int end );
00157
00158 static char *command_generator( const char *_text, int state );
00159 #endif
00160 static RTT::TaskContext* findPeer( std::string comm );
00161
00162 protected:
00163
00164 void listText(std::stringstream& txtss,int start, int end, int ln, char s);
00165
00166 void doPrint( RTT::base::DataSourceBase::shared_ptr ds, bool recurse);
00167
00168 void enterTask();
00169 void leaveTask();
00170
00171 bool macrorecording;
00172 std::string macrotext;
00173 std::string macroname;
00174 std::stringstream sresult;
00175 void recordMacro(std::string name);
00176 void cancelMacro();
00177 void endMacro();
00178
00179 void checkPorts();
00180 Service::shared_ptr stringToService(std::string const& names);
00181 public:
00182
00186 enum ColorTheme { nocolors,
00187 darkbg,
00188 whitebg
00189 };
00190
00191 void setColorTheme( ColorTheme t );
00192
00198 void switchTaskContext(std::string& path);
00199
00206 void switchTaskContext( RTT::TaskContext* tc, bool store = true);
00207
00211 void switchBack();
00212
00218 void browserAction(std::string& act );
00219
00223 void printResult( RTT::base::DataSourceBase* ds, bool recurse);
00224
00228 void printHelp();
00229
00233 void printHelp(std::string command);
00234
00238 void printInfo(const std::string& peerpath);
00239
00243 void printSource( const std::string m );
00244
00248 void printOperation( const std::string m, Service::shared_ptr ops );
00249
00253 bool printService( const std::string name);
00254
00258 void printProgram( const std::string& pn, int line = -1, RTT::TaskContext* progpeer = 0 );
00259
00263 void printProgram( int line = -1 );
00264
00269 TaskBrowser( RTT::TaskContext* c );
00270
00271 ~TaskBrowser();
00272
00278 void loop();
00279
00286 void evaluate(std::string& comm );
00287
00291 void switchTask( RTT::TaskContext* c);
00292
00296 static std::string prompt;
00300 static std::string coloron;
00304 static std::string underline;
00308 static std::string coloroff;
00309
00313 static std::string red;
00314
00318 static std::string green;
00319
00323 static std::string blue;
00324
00328 void evalCommand(std::string& comm );
00329
00330
00331 };
00332
00333 }
00334
00335 #endif