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
00029
00030
00031
00032
00033
00034
00035 #ifndef ROSCPP_SERVICE_SERVER_LINK_H
00036 #define ROSCPP_SERVICE_SERVER_LINK_H
00037
00038 #include "ros/common.h"
00039
00040 #include <boost/thread/mutex.hpp>
00041 #include <boost/shared_array.hpp>
00042 #include <boost/enable_shared_from_this.hpp>
00043 #include <boost/thread.hpp>
00044
00045 #include <queue>
00046
00047 namespace ros
00048 {
00049 class Header;
00050 class Message;
00051 class Connection;
00052 typedef boost::shared_ptr<Connection> ConnectionPtr;
00053
00058 class ROSCPP_DECL ServiceServerLink : public boost::enable_shared_from_this<ServiceServerLink>
00059 {
00060 private:
00061 struct CallInfo
00062 {
00063 SerializedMessage req_;
00064 SerializedMessage* resp_;
00065
00066 bool finished_;
00067 boost::condition_variable finished_condition_;
00068 boost::mutex finished_mutex_;
00069 boost::thread::id caller_thread_id_;
00070
00071 bool success_;
00072 bool call_finished_;
00073
00074 std::string exception_string_;
00075 };
00076 typedef boost::shared_ptr<CallInfo> CallInfoPtr;
00077 typedef std::queue<CallInfoPtr> Q_CallInfo;
00078
00079 public:
00080 typedef std::map<std::string, std::string> M_string;
00081 ServiceServerLink(const std::string& service_name, bool persistent, const std::string& request_md5sum, const std::string& response_md5sum, const M_string& header_values);
00082 virtual ~ServiceServerLink();
00083
00084
00085 bool initialize(const ConnectionPtr& connection);
00086
00090 bool isValid() const;
00094 bool isPersistent() const { return persistent_; }
00095
00096 const ConnectionPtr& getConnection() const { return connection_; }
00097
00098 const std::string& getServiceName() const { return service_name_; }
00099 const std::string& getRequestMD5Sum() const { return request_md5sum_; }
00100 const std::string& getResponseMD5Sum() const { return response_md5sum_; }
00101
00108 bool call(const SerializedMessage& req, SerializedMessage& resp);
00109
00110 private:
00111 void onConnectionDropped(const ConnectionPtr& conn);
00112 bool onHeaderReceived(const ConnectionPtr& conn, const Header& header);
00113
00118 void callFinished();
00123 void processNextCall();
00127 void clearCalls();
00131 void cancelCall(const CallInfoPtr& info);
00132
00133 void onHeaderWritten(const ConnectionPtr& conn);
00134 void onRequestWritten(const ConnectionPtr& conn);
00135 void onResponseOkAndLength(const ConnectionPtr& conn, const boost::shared_array<uint8_t>& buffer, uint32_t size, bool success);
00136 void onResponse(const ConnectionPtr& conn, const boost::shared_array<uint8_t>& buffer, uint32_t size, bool success);
00137
00138 ConnectionPtr connection_;
00139 std::string service_name_;
00140 bool persistent_;
00141 std::string request_md5sum_;
00142 std::string response_md5sum_;
00143
00144 M_string extra_outgoing_header_values_;
00145 bool header_written_;
00146 bool header_read_;
00147
00148 Q_CallInfo call_queue_;
00149 boost::mutex call_queue_mutex_;
00150
00151 CallInfoPtr current_call_;
00152
00153 bool dropped_;
00154 };
00155 typedef boost::shared_ptr<ServiceServerLink> ServiceServerLinkPtr;
00156
00157 }
00158
00159 #endif // ROSCPP_SERVICE_SERVER_LINK_H
00160
00161
00162
roscpp
Author(s): Morgan Quigley, Josh Faust, Brian Gerkey, Troy Straszheim
autogenerated on Tue Mar 7 2017 03:44:47