Go to the documentation of this file.00001
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 #ifndef ROSCPP_TOPIC_MANAGER_H
00029 #define ROSCPP_TOPIC_MANAGER_H
00030
00031 #include "forwards.h"
00032 #include "common.h"
00033 #include "ros/serialization.h"
00034 #include "rosout_appender.h"
00035
00036 #include "XmlRpcValue.h"
00037
00038 #include <boost/thread/mutex.hpp>
00039 #include <boost/thread/recursive_mutex.hpp>
00040
00041 namespace ros
00042 {
00043
00044 class Message;
00045 struct SubscribeOptions;
00046 struct AdvertiseOptions;
00047
00048 class TopicManager;
00049 typedef boost::shared_ptr<TopicManager> TopicManagerPtr;
00050
00051 class PollManager;
00052 typedef boost::shared_ptr<PollManager> PollManagerPtr;
00053
00054 class XMLRPCManager;
00055 typedef boost::shared_ptr<XMLRPCManager> XMLRPCManagerPtr;
00056
00057 class ConnectionManager;
00058 typedef boost::shared_ptr<ConnectionManager> ConnectionManagerPtr;
00059
00060 class SubscriptionCallbackHelper;
00061 typedef boost::shared_ptr<SubscriptionCallbackHelper> SubscriptionCallbackHelperPtr;
00062
00063 class ROSCPP_DECL TopicManager
00064 {
00065 public:
00066 static const TopicManagerPtr& instance();
00067
00068 TopicManager();
00069 ~TopicManager();
00070
00071 void start();
00072 void shutdown();
00073
00074 bool subscribe(const SubscribeOptions& ops);
00075 bool unsubscribe(const std::string &_topic, const SubscriptionCallbackHelperPtr& helper);
00076
00077 bool advertise(const AdvertiseOptions& ops, const SubscriberCallbacksPtr& callbacks);
00078 bool unadvertise(const std::string &topic, const SubscriberCallbacksPtr& callbacks);
00079
00084 void getAdvertisedTopics(V_string& topics);
00085
00090 void getSubscribedTopics(V_string& topics);
00091
00102 PublicationPtr lookupPublication(const std::string& topic);
00103
00110 size_t getNumSubscribers(const std::string &_topic);
00111 size_t getNumSubscriptions();
00112
00119 size_t getNumPublishers(const std::string &_topic);
00120
00121 template<typename M>
00122 void publish(const std::string& topic, const M& message)
00123 {
00124 using namespace serialization;
00125
00126 SerializedMessage m;
00127 publish(topic, boost::bind(serializeMessage<M>, boost::ref(message)), m);
00128 }
00129
00130 void publish(const std::string &_topic, const boost::function<SerializedMessage(void)>& serfunc, SerializedMessage& m);
00131
00132 void incrementSequence(const std::string &_topic);
00133 bool isLatched(const std::string& topic);
00134
00135 private:
00141 bool addSubCallback(const SubscribeOptions& ops);
00142
00155 bool requestTopic(const std::string &topic, XmlRpc::XmlRpcValue &protos, XmlRpc::XmlRpcValue &ret);
00156
00157
00158 bool isTopicAdvertised(const std::string& topic);
00159
00160 bool registerSubscriber(const SubscriptionPtr& s, const std::string& datatype);
00161 bool unregisterSubscriber(const std::string& topic);
00162 bool unregisterPublisher(const std::string& topic);
00163
00164 PublicationPtr lookupPublicationWithoutLock(const std::string &topic);
00165
00166 void processPublishQueues();
00167
00174 void getBusStats(XmlRpc::XmlRpcValue &stats);
00175
00182 void getBusInfo(XmlRpc::XmlRpcValue &info);
00183
00190 void getSubscriptions(XmlRpc::XmlRpcValue &subscriptions);
00191
00198 void getPublications(XmlRpc::XmlRpcValue &publications);
00199
00210 bool pubUpdate(const std::string &topic, const std::vector<std::string> &pubs);
00211
00212 void pubUpdateCallback(XmlRpc::XmlRpcValue& params, XmlRpc::XmlRpcValue& result);
00213 void requestTopicCallback(XmlRpc::XmlRpcValue& params, XmlRpc::XmlRpcValue& result);
00214 void getBusStatsCallback(XmlRpc::XmlRpcValue& params, XmlRpc::XmlRpcValue& result);
00215 void getBusInfoCallback(XmlRpc::XmlRpcValue& params, XmlRpc::XmlRpcValue& result);
00216 void getSubscriptionsCallback(XmlRpc::XmlRpcValue& params, XmlRpc::XmlRpcValue& result);
00217 void getPublicationsCallback(XmlRpc::XmlRpcValue& params, XmlRpc::XmlRpcValue& result);
00218
00219 bool isShuttingDown() { return shutting_down_; }
00220
00221 boost::mutex subs_mutex_;
00222 L_Subscription subscriptions_;
00223
00224 boost::recursive_mutex advertised_topics_mutex_;
00225 V_Publication advertised_topics_;
00226 std::list<std::string> advertised_topic_names_;
00227 boost::mutex advertised_topic_names_mutex_;
00228
00229 volatile bool shutting_down_;
00230 boost::mutex shutting_down_mutex_;
00231
00232 PollManagerPtr poll_manager_;
00233 ConnectionManagerPtr connection_manager_;
00234 XMLRPCManagerPtr xmlrpc_manager_;
00235 };
00236
00237 }
00238
00239 #endif // ROSCPP_TOPIC_MANAGER_H
roscpp
Author(s): Morgan Quigley, Josh Faust, Brian Gerkey, Troy Straszheim
autogenerated on Thu Jun 6 2019 21:10:05