TaskBrowser.hpp
Go to the documentation of this file.
1 #ifndef NO_GPL
2 /***************************************************************************
3  tag: Peter Soetens Thu Jul 3 15:31:33 CEST 2008 TaskBrowser.hpp
4 
5  TaskBrowser.hpp - description
6  -------------------
7  begin : Thu July 03 2008
8  copyright : (C) 2008 Peter Soetens
9  email : peter.soetens@fmtc.be
10 
11  ***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  * This program is distributed in the hope that it will be useful, *
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
21  * General Public License for more details. *
22  * *
23  * You should have received a copy of the GNU General Public *
24  * License along with this program; if not, write to the Free Software *
25  * Foundation, Inc., 59 Temple Place, *
26  * Suite 330, Boston, MA 02111-1307 USA *
27  ***************************************************************************/
28 #else
29 /***************************************************************************
30  tag: Peter Soetens Tue Dec 21 22:43:08 CET 2004 TaskBrowser.hpp
31 
32  TaskBrowser.hpp - description
33  -------------------
34  begin : Tue December 21 2004
35  copyright : (C) 2004 Peter Soetens
36  email : peter.soetens@mech.kuleuven.ac.be
37 
38  ***************************************************************************
39  * This library is free software; you can redistribute it and/or *
40  * modify it under the terms of the GNU Lesser General Public *
41  * License as published by the Free Software Foundation; either *
42  * version 2.1 of the License, or (at your option) any later version. *
43  * *
44  * This library is distributed in the hope that it will be useful, *
45  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
46  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
47  * Lesser General Public License for more details. *
48  * *
49  * You should have received a copy of the GNU Lesser General Public *
50  * License along with this library; if not, write to the Free Software *
51  * Foundation, Inc., 59 Temple Place, *
52  * Suite 330, Boston, MA 02111-1307 USA *
53  * *
54  ***************************************************************************/
55 #endif
56 
57 #ifndef ORO_TASKBROWSER_HPP
58 #define ORO_TASKBROWSER_HPP
59 
60 
61 #include <rtt/RTT.hpp>
62 #include <rtt/TaskContext.hpp>
63 #include <rtt/Service.hpp>
64 #include <deque>
65 #include <string>
66 #include <sstream>
67 #include <vector>
68 #if defined(HAS_READLINE) && !defined(HAS_EDITLINE) && defined(_POSIX_VERSION)
69 #include <signal.h>
70 #endif
71 
72 #include <ocl/OCL.hpp>
73 
74 namespace OCL
75 {
86  class OCL_API TaskBrowser
87  : public RTT::TaskContext
88  {
89  // the 'current' task context
91  // the TC we are using for completion.
93  // the TaskBrowser
95  // the current Context: is tb or taskcontext
99 
100  int debug;
101  /* A static variable for holding the line. */
102  char *line_read;
103  int lastc; // last command's number
104 
105  std::string storedname;
107  bool usehex;
108 
109  std::deque<RTT::TaskContext*> taskHistory;
110 
111  // store TC + program/state name + line number
112  typedef std::map<std::pair<RTT::TaskContext*,std::string>,int> PTrace;
113  PTrace ptraces;
114  PTrace straces;
115 
116  //file to store history
117  const char* histfile;
118 
122 #if defined(HAS_READLINE) || defined(HAS_EDITLINE)
123 #if defined(_POSIX_VERSION) && !defined(HAS_EDITLINE)
124  static void rl_sigwinch_handler(int sig, siginfo_t *si, void *ctxt);
125  static int rl_received_signal;
126  static void rl_signal_handler(int sig, siginfo_t *si, void *ctxt);
127 
128  /* Custom implementation of rl_getc() to handle signals correctly. */
129  static int rl_getc(FILE *);
130 #endif
131 
132  /* Read a string, and return a pointer to it.
133  Returns NULL on EOF. */
134  char *rl_gets ();
135 
136  // use this vector to generate candidate strings
137  static std::vector<std::string> candidates;
138  // Add successful matches of candidate strings to completes.
139  static std::vector<std::string> completes;
140  static std::vector<std::string>::iterator complete_iter;
141 
142  static std::string component_found;
143  static std::string component;
144  static std::string peerpath;
145  static std::string text;
146 
147  // helper function
148  static char* dupstr( const char *s );
149 
150  static void find_completes();
151 
152  static void find_ops();
153  static void find_peers(std::string::size_type startpos);
154 
155  static char ** orocos_hmi_completion ( const char *text, int start, int end );
156 
157  static char *command_generator( const char *_text, int state );
158 #endif
159  static RTT::TaskContext* findPeer( std::string comm );
160 
161  protected:
162 
163  void listText(std::stringstream& txtss,int start, int end, int ln, char s);
164 
165  void doPrint( RTT::base::DataSourceBase::shared_ptr ds, bool recurse);
166 
167  void enterTask();
168  void leaveTask();
169 
171  std::string macrotext;
172  std::string macroname;
173  std::stringstream sresult;
174  void recordMacro(std::string name);
175  void cancelMacro();
176  void endMacro();
177 
178  void checkPorts();
179  Service::shared_ptr stringToService(std::string const& names);
180  public:
181 
187  whitebg
188  };
189 
190  void setColorTheme( ColorTheme t );
191 
197  void switchTaskContext(std::string& path);
198 
205  void switchTaskContext( RTT::TaskContext* tc, bool store = true);
206 
210  void switchBack();
211 
217  void browserAction(std::string& act );
218 
222  void printResult( RTT::base::DataSourceBase* ds, bool recurse);
223 
227  void printHelp();
228 
232  void printHelp(std::string command);
233 
237  void printInfo(const std::string& peerpath);
238 
242  void printSource( const std::string m );
243 
247  void printOperation( const std::string m, Service::shared_ptr ops );
248 
252  bool printService( const std::string name);
253 
257  bool printGlobals();
258 
262  void printProgram( const std::string& pn, int line = -1, RTT::TaskContext* progpeer = 0 );
263 
267  void printProgram( int line = -1 );
268 
274 
275  ~TaskBrowser();
276 
282  void loop();
283 
290  void evaluate(std::string& comm );
291 
295  void switchTask( RTT::TaskContext* c);
296 
300  static std::string prompt;
304  static std::string coloron;
308  static std::string underline;
312  static std::string coloroff;
313 
317  static std::string red;
318 
322  static std::string green;
323 
327  static std::string blue;
328 
332  void evalCommand(std::string& comm );
333 
334 
335  };
336 
337 }
338 
339 #endif
static RTT::TaskContext * taskcontext
Definition: TaskBrowser.hpp:90
std::deque< RTT::TaskContext * > taskHistory
This component allows a text client to browse the peers of a peer RTT::TaskContext and execute comman...
Definition: TaskBrowser.hpp:86
std::stringstream sresult
static RTT::TaskContext * context
Definition: TaskBrowser.hpp:96
bool usehex
last program line number listed to screen
Do not use colors.
Use colors suitable for a dark background.
static std::string green
static RTT::Service::shared_ptr taskobject
Definition: TaskBrowser.hpp:97
std::map< std::pair< RTT::TaskContext *, std::string >, int > PTrace
boost::shared_ptr< Service > shared_ptr
RTT::internal::DataSource< bool >::shared_ptr accepted
Definition: TaskBrowser.hpp:98
std::string macroname
base::DataSourceBase::shared_ptr last_expr
const char * histfile
res evaluate()
static std::string prompt
boost::intrusive_ptr< DataSource< T > > shared_ptr
std::string macrotext
static RTT::TaskContext * peer
Definition: TaskBrowser.hpp:92
static std::string coloroff
int storedline
last program listed to screen
static RTT::TaskContext * tb
Definition: TaskBrowser.hpp:94
static std::string underline
static std::string blue
boost::intrusive_ptr< DataSourceBase > shared_ptr
static std::string red
std::string storedname
static std::string coloron


ocl
Author(s): OCL Development Team
autogenerated on Mon Mar 23 2020 04:47:19