service_client_options.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009, Willow Garage, Inc.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  * * Redistributions of source code must retain the above copyright notice,
7  * this list of conditions and the following disclaimer.
8  * * Redistributions in binary form must reproduce the above copyright
9  * notice, this list of conditions and the following disclaimer in the
10  * documentation and/or other materials provided with the distribution.
11  * * Neither the names of Stanford University or Willow Garage, Inc. nor the names of its
12  * contributors may be used to endorse or promote products derived from
13  * this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  * POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #ifndef ROSCPP_SERVICE_CLIENT_OPTIONS_H
29 #define ROSCPP_SERVICE_CLIENT_OPTIONS_H
30 
31 #include "ros/forwards.h"
32 #include "common.h"
33 #include "ros/service_traits.h"
34 
35 namespace ros
36 {
37 
41 struct ROSCPP_DECL ServiceClientOptions
42 {
44  : persistent(false)
45  {
46  }
47 
48  /*
49  * \brief Constructor
50  * \param _service Name of the service to connect to
51  * \param _md5sum md5sum of the service
52  * \param _persistent Whether or not to keep the connection open to the service for future calls
53  * \param _header Any extra values to be passed along in the connection header
54  */
55  ServiceClientOptions(const std::string& _service, const std::string& _md5sum, bool _persistent, const M_string& _header)
56  : service(_service)
57  , md5sum(_md5sum)
58  , persistent(_persistent)
59  , header(_header)
60  {
61  }
62 
63  /*
64  * \brief Templated helper method, preventing you from needing to manually get the service md5sum
65  * \param MReq [template] Request message type
66  * \param MRes [template] Response message type
67  * \param _service Name of the service to connect to
68  * \param _persistent Whether or not to keep the connection open to the service for future calls
69  * \param _header Any extra values to be passed along in the connection header
70  */
71  template <class MReq, class MRes>
72  void init(const std::string& _service, bool _persistent, const M_string& _header)
73  {
74  namespace st = service_traits;
75 
76  service = _service;
77  md5sum = st::md5sum<MReq>();
78  persistent = _persistent;
79  header = _header;
80  }
81 
82  /*
83  * \brief Templated helper method, preventing you from needing to manually get the service md5sum
84  * \param Service [template] Service type
85  * \param _service Name of the service to connect to
86  * \param _persistent Whether or not to keep the connection open to the service for future calls
87  * \param _header Any extra values to be passed along in the connection header
88  */
89  template <class Service>
90  void init(const std::string& _service, bool _persistent, const M_string& _header)
91  {
92  namespace st = service_traits;
93 
94  service = _service;
95  md5sum = st::md5sum<Service>();
96  persistent = _persistent;
97  header = _header;
98  }
99 
100  std::string service;
101  std::string md5sum;
102  bool persistent;
104 };
105 
106 
107 }
108 
109 #endif
Encapsulates all options available for creating a ServiceClient.
std::string md5sum
Service md5sum.
ServiceClientOptions(const std::string &_service, const std::string &_md5sum, bool _persistent, const M_string &_header)
std::map< std::string, std::string > M_string
std::string service
Service to connect to.
void init(const std::string &_service, bool _persistent, const M_string &_header)
bool persistent
Whether or not the connection should persist.
void init(const std::string &_service, bool _persistent, const M_string &_header)
const char * md5sum()
const std::string header
M_string header
Extra key/value pairs to add to the connection header.


roscpp
Author(s): Morgan Quigley, Josh Faust, Brian Gerkey, Troy Straszheim
autogenerated on Sun Feb 3 2019 03:29:54