Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
webview_thread.h
1 
2 /***************************************************************************
3  * webview_thread.h - Webview ROS integration thread
4  *
5  * Created: Fri May 06 10:46:57 2011
6  * Copyright 2006-2011 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef __PLUGINS_ROS_WEBVIEW_THREAD_H_
24 #define __PLUGINS_ROS_WEBVIEW_THREAD_H_
25 
26 #include <core/threading/thread.h>
27 #include <core/utils/lockptr.h>
28 #include <aspect/logging.h>
29 #include <aspect/configurable.h>
30 #include <aspect/clock.h>
31 #include <aspect/webview.h>
32 #include <plugins/ros/aspect/ros.h>
33 
34 #include <ros/service_server.h>
35 #include <webview_msgs/UrlRegistration.h>
36 #include <webview_msgs/NavRegistration.h>
37 
38 #include <map>
39 #include <string>
40 
42 
44 : public fawkes::Thread,
45  public fawkes::LoggingAspect,
47  public fawkes::ClockAspect,
48  public fawkes::ROSAspect,
50 {
51  public:
53  virtual ~ROSWebviewThread();
54 
55  virtual void init();
56  virtual void loop();
57  virtual void finalize();
58 
59  private:
60  bool srv_register_cb(webview_msgs::UrlRegistration::Request &req,
61  webview_msgs::UrlRegistration::Response &resp);
62 
63  bool srv_unregister_cb(webview_msgs::UrlRegistration::Request &req,
64  webview_msgs::UrlRegistration::Response &resp);
65 
66  bool srv_add_nav_cb(webview_msgs::NavRegistration::Request &req,
67  webview_msgs::NavRegistration::Response &resp);
68 
69  bool srv_remove_nav_cb(webview_msgs::NavRegistration::Request &req,
70  webview_msgs::NavRegistration::Response &resp);
71 
72  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
73  protected: virtual void run() { Thread::run(); }
74 
75  private:
76  ros::ServiceServer __srv_register;
77  ros::ServiceServer __srv_unregister;
78  ros::ServiceServer __srv_add_nav;
79  ros::ServiceServer __srv_remove_nav;
80 
81  std::map<std::string, ROSWebviewRequestProcessor *> __procs;
82  std::map<std::string, std::string> __nav_entries;
83 };
84 
85 #endif