Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * webview_thread.h - Webview ROS integration thread 00004 * 00005 * Created: Fri May 06 10:46:57 2011 00006 * Copyright 2006-2011 Tim Niemueller [www.niemueller.de] 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU Library General Public License for more details. 00019 * 00020 * Read the full text in the LICENSE.GPL file in the doc directory. 00021 */ 00022 00023 #ifndef __PLUGINS_ROS_WEBVIEW_THREAD_H_ 00024 #define __PLUGINS_ROS_WEBVIEW_THREAD_H_ 00025 00026 #include <core/threading/thread.h> 00027 #include <core/utils/lockptr.h> 00028 #include <aspect/logging.h> 00029 #include <aspect/configurable.h> 00030 #include <aspect/clock.h> 00031 #include <aspect/webview.h> 00032 #include <plugins/ros/aspect/ros.h> 00033 00034 #include <ros/service_server.h> 00035 #include <webview_msgs/UrlRegistration.h> 00036 #include <webview_msgs/NavRegistration.h> 00037 00038 #include <map> 00039 #include <string> 00040 00041 class ROSWebviewRequestProcessor; 00042 00043 class ROSWebviewThread 00044 : public fawkes::Thread, 00045 public fawkes::LoggingAspect, 00046 public fawkes::ConfigurableAspect, 00047 public fawkes::ClockAspect, 00048 public fawkes::ROSAspect, 00049 public fawkes::WebviewAspect 00050 { 00051 public: 00052 ROSWebviewThread(); 00053 virtual ~ROSWebviewThread(); 00054 00055 virtual void init(); 00056 virtual void loop(); 00057 virtual void finalize(); 00058 00059 private: 00060 bool srv_register_cb(webview_msgs::UrlRegistration::Request &req, 00061 webview_msgs::UrlRegistration::Response &resp); 00062 00063 bool srv_unregister_cb(webview_msgs::UrlRegistration::Request &req, 00064 webview_msgs::UrlRegistration::Response &resp); 00065 00066 bool srv_add_nav_cb(webview_msgs::NavRegistration::Request &req, 00067 webview_msgs::NavRegistration::Response &resp); 00068 00069 bool srv_remove_nav_cb(webview_msgs::NavRegistration::Request &req, 00070 webview_msgs::NavRegistration::Response &resp); 00071 00072 /** Stub to see name in backtrace for easier debugging. @see Thread::run() */ 00073 protected: virtual void run() { Thread::run(); } 00074 00075 private: 00076 ros::ServiceServer __srv_register; 00077 ros::ServiceServer __srv_unregister; 00078 ros::ServiceServer __srv_add_nav; 00079 ros::ServiceServer __srv_remove_nav; 00080 00081 std::map<std::string, ROSWebviewRequestProcessor *> __procs; 00082 std::map<std::string, std::string> __nav_entries; 00083 }; 00084 00085 #endif