00001 /* 00002 * topic_manager.h - micros topic manager 00003 * Copyright (C) 2015 Zaile Jiang 00004 * 00005 * This program is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU General Public License 00007 * as published by the Free Software Foundation; either version 2 00008 * of the License, or (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00018 */ 00019 #ifndef MICROSRTT_TOPIC_MANAGER_H 00020 #define MICROSRTT_TOPIC_MANAGER_H 00021 00022 #include "ros/ros.h" 00023 #include "ros/xmlrpc_manager.h" 00024 #include "micros_rtt/common.h" 00025 #include "micros_rtt/connection_base.h" 00026 00027 #include "XmlRpc.h" 00028 #include "XmlRpcValue.h" 00029 00030 namespace micros_rtt 00031 { 00032 class TopicManager; 00033 typedef boost::shared_ptr<TopicManager> TopicManagerPtr; 00034 00035 class TopicManager 00036 { 00037 public: 00038 TopicManager(); 00039 ~TopicManager(); 00040 static const TopicManagerPtr& instance(); 00041 00042 bool advertise(const std::string& topic, const std::string& data_type, uint32_t queue_size); 00043 00044 void addPubConnection(ConnectionBasePtr pub_connection); 00045 void addSubConnection(ConnectionBasePtr sub_connection); 00046 ConnectionBasePtr findSubConnection(const std::string& topic); 00047 ConnectionBasePtr findPubConnection(const std::string& topic); 00048 00049 private: 00050 void pubUpdateCallback(XmlRpc::XmlRpcValue& params, XmlRpc::XmlRpcValue& result); 00051 void requestTopicCallback(XmlRpc::XmlRpcValue& params, XmlRpc::XmlRpcValue& result); 00052 private: 00053 V_ConnectionBase advertised_topics_; 00054 V_ConnectionBase subscriptions_; 00055 00056 ros::XMLRPCManagerPtr xmlrpc_manager_; 00057 00058 }; 00059 00060 } 00061 00062 #endif