Gazebo Transport

API Reference

11.4.1
gz/transport/AdvertiseOptions.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 #ifndef GZ_TRANSPORT_ADVERTISEOPTIONS_HH_
19 #define GZ_TRANSPORT_ADVERTISEOPTIONS_HH_
20 
21 #include <cstdint>
22 #include <iostream>
23 #include <memory>
24 
25 #include "gz/transport/config.hh"
26 #include "gz/transport/Export.hh"
27 
28 namespace ignition
29 {
30  namespace transport
31  {
32  // Inline bracket to help doxygen filtering.
33  inline namespace IGNITION_TRANSPORT_VERSION_NAMESPACE {
34  //
35  // Forward declarations.
36  class AdvertiseOptionsPrivate;
37  class AdvertiseMessageOptionsPrivate;
38  class AdvertiseServiceOptionsPrivate;
39 
42  enum class Scope_t
43  {
46  PROCESS,
49  HOST,
51  ALL
52  };
53 
59  class IGNITION_TRANSPORT_VISIBLE AdvertiseOptions
60  {
62  public: AdvertiseOptions();
63 
66  public: AdvertiseOptions(const AdvertiseOptions &_other);
67 
69  public: virtual ~AdvertiseOptions();
70 
74  public: AdvertiseOptions &operator=(const AdvertiseOptions &_other);
75 
80  public: bool operator==(const AdvertiseOptions &_other) const;
81 
86  public: bool operator!=(const AdvertiseOptions &_other) const;
87 
91  public: friend std::ostream &operator<<(std::ostream &_out,
92  const AdvertiseOptions &_other)
93  {
94  _out << "Advertise options:\n"
95  << "\tScope: ";
96  if (_other.Scope() == Scope_t::PROCESS)
97  _out << "Process" << std::endl;
98  else if (_other.Scope() == Scope_t::HOST)
99  _out << "Host" << std::endl;
100  else
101  _out << "All" << std::endl;
102  return _out;
103  }
104 
109  public: const Scope_t &Scope() const;
110 
115  public: void SetScope(const Scope_t &_scope);
116 
117 #ifdef _WIN32
118 // Disable warning C4251 which is triggered by
119 // std::unique_ptr
120 #pragma warning(push)
121 #pragma warning(disable: 4251)
122 #endif
126 #ifdef _WIN32
127 #pragma warning(pop)
128 #endif
129  };
130 
134  class IGNITION_TRANSPORT_VISIBLE AdvertiseMessageOptions
135  : public AdvertiseOptions
136  {
138  public: AdvertiseMessageOptions();
139 
142  public: AdvertiseMessageOptions(const AdvertiseMessageOptions &_other);
143 
145  public: virtual ~AdvertiseMessageOptions();
146 
150  public: AdvertiseMessageOptions &operator=(
151  const AdvertiseMessageOptions &_other);
152 
157  public: bool operator==(const AdvertiseMessageOptions &_other) const;
158 
163  public: bool operator!=(const AdvertiseMessageOptions &_other) const;
164 
168  public: friend std::ostream &operator<<(std::ostream &_out,
169  const AdvertiseMessageOptions &_other)
170  {
171  _out << static_cast<AdvertiseOptions>(_other);
172  if (_other.Throttled())
173  {
174  _out << "\tThrottled? Yes" << std::endl;
175  _out << "\tRate: " << _other.MsgsPerSec() << " msgs/sec" << std::endl;
176  }
177  else
178  _out << "\tThrottled? No" << std::endl;
179 
180  return _out;
181  }
182 
187  public: bool Throttled() const;
188 
191  public: uint64_t MsgsPerSec() const;
192 
198  public: void SetMsgsPerSec(const uint64_t _newMsgsPerSec);
199 
200 #ifdef _WIN32
201 // Disable warning C4251 which is triggered by
202 // std::unique_ptr
203 #pragma warning(push)
204 #pragma warning(disable: 4251)
205 #endif
209 #ifdef _WIN32
210 #pragma warning(pop)
211 #endif
212  };
213 
216  class IGNITION_TRANSPORT_VISIBLE AdvertiseServiceOptions
217  : public AdvertiseOptions
218  {
220  public: AdvertiseServiceOptions();
221 
224  public: AdvertiseServiceOptions(const AdvertiseServiceOptions &_other);
225 
227  public: virtual ~AdvertiseServiceOptions();
228 
232  public: AdvertiseServiceOptions &operator=(
233  const AdvertiseServiceOptions &_other);
234 
239  public: bool operator==(const AdvertiseServiceOptions &_other) const;
240 
245  public: bool operator!=(const AdvertiseServiceOptions &_other) const;
246 
250  public: friend std::ostream &operator<<(std::ostream &_out,
251  const AdvertiseServiceOptions &_other)
252  {
253  _out << static_cast<AdvertiseOptions>(_other);
254  return _out;
255  }
256 
257 #ifdef _WIN32
258 // Disable warning C4251 which is triggered by
259 // std::unique_ptr
260 #pragma warning(push)
261 #pragma warning(disable: 4251)
262 #endif
266 #ifdef _WIN32
267 #pragma warning(pop)
268 #endif
269  };
270  }
271  }
272 }
273 #endif
bool operator==(const AdvertiseServiceOptions &_other) const
Equality operator. This function checks if the given AdvertiseMessageOptions has identical content to...
void SetMsgsPerSec(const uint64_t _newMsgsPerSec)
Set the maximum number of messages per second to be published. Note that we calculate the minimum per...
bool operator!=(const AdvertiseOptions &_other) const
Inequality operator. This function checks if the given options do not have identical values to this o...
@ HOST
Topic/service only available to subscribers in the same machine as the publisher.
Definition: gz/transport/AdvertiseOptions.hh:28
bool operator!=(const AdvertiseMessageOptions &_other) const
Inequality operator. This function checks if the given options do not have identical values to this o...
friend std::ostream & operator<<(std::ostream &_out, const AdvertiseMessageOptions &_other)
Stream insertion operator.
Definition: gz/transport/AdvertiseOptions.hh:168
bool Throttled() const
Whether the publication has been throttled.
@ ALL
Topic/service available to any subscriber (default scope).
friend std::ostream & operator<<(std::ostream &_out, const AdvertiseOptions &_other)
Stream insertion operator.
Definition: gz/transport/AdvertiseOptions.hh:91
void SetScope(const Scope_t &_scope)
Set the scope of the topic or service.
A class for customizing the publication options for a topic or service advertised....
Definition: gz/transport/AdvertiseOptions.hh:59
const Scope_t & Scope() const
Get the scope used in this topic/service.
A class for customizing the publication options for a topic advertised. E.g.: Set the rate of message...
Definition: gz/transport/AdvertiseOptions.hh:134
AdvertiseMessageOptions & operator=(const AdvertiseMessageOptions &_other)
Assignment operator.
STL class.
bool operator!=(const AdvertiseServiceOptions &_other) const
Inequality operator. This function checks if the given options do not have identical values to this o...
friend std::ostream & operator<<(std::ostream &_out, const AdvertiseServiceOptions &_other)
Stream insertion operator.
Definition: gz/transport/AdvertiseOptions.hh:250
AdvertiseServiceOptions & operator=(const AdvertiseServiceOptions &_other)
Assignment operator.
uint64_t MsgsPerSec() const
Get the maximum number of messages per second to be published.
virtual ~AdvertiseOptions()
Destructor.
Scope_t
This strongly typed enum defines the different options for the scope of a topic/service.
Definition: gz/transport/AdvertiseOptions.hh:42
T endl(T... args)
bool operator==(const AdvertiseMessageOptions &_other) const
Equality operator. This function checks if the given AdvertiseMessageOptions has identical content to...
A class for customizing the publication options for a service advertised.
Definition: gz/transport/AdvertiseOptions.hh:216
AdvertiseOptions & operator=(const AdvertiseOptions &_other)
Assignment operator.
@ PROCESS
Topic/service only available to subscribers in the same process as the publisher.
bool operator==(const AdvertiseOptions &_other) const
Equality operator. This function checks if the given AdvertiseOptions has identical content to this o...