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
00125 char *rl_gets ();
00126
00127
00128 static std::vector<std::string> candidates;
00129
00130 static std::vector<std::string> completes;
00131 static std::vector<std::string>::iterator complete_iter;
00132
00133 static std::string component_found;
00134 static std::string component;
00135 static std::string peerpath;
00136 static std::string text;
00137
00138
00139 static char* dupstr( const char *s );
00140
00141 static void find_completes();
00142
00143 static void find_ops();
00144 static void find_peers(std::string::size_type startpos);
00145
00146 static char ** orocos_hmi_completion ( const char *text, int start, int end );
00147
00148 static char *command_generator( const char *_text, int state );
00149 #endif
00150 static RTT::TaskContext* findPeer( std::string comm );
00151
00152 protected:
00153
00154 void listText(std::stringstream& txtss,int start, int end, int ln, char s);
00155
00156 void doPrint( RTT::base::DataSourceBase::shared_ptr ds, bool recurse);
00157
00158 void enterTask();
00159 void leaveTask();
00160
00161 bool macrorecording;
00162 std::string macrotext;
00163 std::string macroname;
00164 std::stringstream sresult;
00165 void recordMacro(std::string name);
00166 void cancelMacro();
00167 void endMacro();
00168
00169 void checkPorts();
00170 Service::shared_ptr stringToService(string const& names);
00171 public:
00172
00176 enum ColorTheme { nocolors,
00177 darkbg,
00178 whitebg
00179 };
00180
00181 void setColorTheme( ColorTheme t );
00182
00188 void switchTaskContext(std::string& path);
00189
00196 void switchTaskContext( RTT::TaskContext* tc, bool store = true);
00197
00201 void switchBack();
00202
00208 void browserAction(std::string& act );
00209
00213 void printResult( RTT::base::DataSourceBase* ds, bool recurse);
00214
00218 void printHelp();
00219
00223 void printHelp(string command);
00224
00228 void printInfo(const std::string& peerpath);
00229
00233 void printSource( const std::string m );
00234
00238 void printOperation( const std::string m, Service::shared_ptr ops );
00239
00243 bool printService( const std::string name);
00244
00248 void printProgram( const std::string& pn, int line = -1, RTT::TaskContext* progpeer = 0 );
00249
00253 void printProgram( int line = -1 );
00254
00259 TaskBrowser( RTT::TaskContext* c );
00260
00261 ~TaskBrowser();
00262
00268 void loop();
00269
00276 void evaluate(std::string& comm );
00277
00281 void switchTask( RTT::TaskContext* c);
00282
00286 static std::string prompt;
00290 static std::string coloron;
00294 static std::string underline;
00298 static std::string coloroff;
00299
00303 static std::string red;
00304
00308 static std::string green;
00309
00313 static std::string blue;
00314
00318 void evalCommand(std::string& comm );
00319
00320
00321 };
00322
00323 }
00324
00325 #endif