transport_hints.h
Go to the documentation of this file.
1 #include "sick_scan/sick_scan_base.h" /* Base definitions included in all header files, added by add_sick_scan_base_header.py. Do not edit this line. */
2 /*
3  * Copyright (C) 2009, Willow Garage, Inc.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright notice,
8  * this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the names of Stanford University or Willow Garage, Inc. nor the names of its
13  * contributors may be used to endorse or promote products derived from
14  * this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef ROSCPP_TRANSPORT_HINTS_H
30 #define ROSCPP_TRANSPORT_HINTS_H
31 
32 #include "common.h"
33 #include "ros/forwards.h"
34 
35 //#include <boost/lexical_cast.hpp>
36 
37 namespace roswrap
38 {
39 
56 {
57 public:
62  {
63  tcp();
64 
65  return *this;
66  }
67 
72  {
73  transports_.push_back("TCP");
74  return *this;
75  }
76 
83  TransportHints& tcpNoDelay(bool nodelay = true)
84  {
85  options_["tcp_nodelay"] = nodelay ? "true" : "false";
86  return *this;
87  }
88 
93  {
94  M_string::iterator it = options_.find("tcp_nodelay");
95  if (it == options_.end())
96  {
97  return false;
98  }
99 
100  const std::string& val = it->second;
101  if (val == "true")
102  {
103  return true;
104  }
105 
106  return false;
107  }
108 
115  {
116  options_["max_datagram_size"] = std::to_string(size); // boost::lexical_cast<std::string>(size);
117  return *this;
118  }
119 
125  {
126  M_string::iterator it = options_.find("max_datagram_size");
127  if (it == options_.end())
128  {
129  return 0;
130  }
131 
132  return std::stoi(it->second); // boost::lexical_cast<int>(it->second);
133  }
134 
139  {
140  udp();
141 
142  return *this;
143  }
144 
149  {
150  transports_.push_back("UDP");
151  return *this;
152  }
153 
157  const V_string& getTransports() { return transports_; }
161  const M_string& getOptions() { return options_; }
162 
163 private:
166 };
167 
168 }
169 
170 #endif
roswrap::TransportHints::tcpNoDelay
TransportHints & tcpNoDelay(bool nodelay=true)
If a TCP transport is used, specifies whether or not to use TCP_NODELAY to provide a potentially lowe...
Definition: transport_hints.h:83
roswrap::M_string
std::map< std::string, std::string > M_string
Definition: datatypes.h:46
roswrap::TransportHints::unreliable
TransportHints & unreliable()
Specifies an unreliable transport. Currently this means UDP.
Definition: transport_hints.h:138
roswrap::TransportHints::udp
TransportHints & udp()
Explicitly specifies a UDP transport.
Definition: transport_hints.h:148
roswrap::TransportHints::getOptions
const M_string & getOptions()
Returns the map of options created by other methods inside TransportHints.
Definition: transport_hints.h:161
roswrap::TransportHints::transports_
V_string transports_
Definition: transport_hints.h:164
roswrap::TransportHints::getMaxDatagramSize
int getMaxDatagramSize()
Returns the maximum datagram size specified on this TransportHints, or 0 if no size was specified.
Definition: transport_hints.h:124
roswrap
Definition: param_modi.cpp:41
roswrap::TransportHints::options_
M_string options_
Definition: transport_hints.h:165
common.h
roswrap::TransportHints::reliable
TransportHints & reliable()
Specifies a reliable transport. Currently this means TCP.
Definition: transport_hints.h:61
roswrap::TransportHints
Provides a way of specifying network transport hints to ros::NodeHandle::subscribe() and someday ros:...
Definition: transport_hints.h:55
roswrap::TransportHints::getTCPNoDelay
bool getTCPNoDelay()
Returns whether or not this TransportHints has specified TCP_NODELAY.
Definition: transport_hints.h:92
roswrap::TransportHints::getTransports
const V_string & getTransports()
Returns a vector of transports, ordered by preference.
Definition: transport_hints.h:157
sick_scan_base.h
ROSCPP_DECL
#define ROSCPP_DECL
Definition: roswrap/src/cfgsimu/sick_scan/ros/common.h:63
roswrap::TransportHints::maxDatagramSize
TransportHints & maxDatagramSize(int size)
If a UDP transport is used, specifies the maximum datagram size.
Definition: transport_hints.h:114
roswrap::V_string
std::vector< std::string > V_string
Definition: datatypes.h:44
roswrap::TransportHints::tcp
TransportHints & tcp()
Explicitly specifies the TCP transport.
Definition: transport_hints.h:71


sick_scan_xd
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Fri Oct 25 2024 02:47:12