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 
29 {
30  // Inline bracket to help doxygen filtering.
31  inline namespace IGNITION_TRANSPORT_VERSION_NAMESPACE {
32  //
33  // Forward declarations.
34  class AdvertiseOptionsPrivate;
35  class AdvertiseMessageOptionsPrivate;
36  class AdvertiseServiceOptionsPrivate;
37 
40  enum class Scope_t
41  {
44  PROCESS,
47  HOST,
49  ALL
50  };
51 
57  class IGNITION_TRANSPORT_VISIBLE AdvertiseOptions
58  {
60  public: AdvertiseOptions();
61 
64  public: AdvertiseOptions(const AdvertiseOptions &_other);
65 
67  public: virtual ~AdvertiseOptions();
68 
72  public: AdvertiseOptions &operator=(const AdvertiseOptions &_other);
73 
78  public: bool operator==(const AdvertiseOptions &_other) const;
79 
84  public: bool operator!=(const AdvertiseOptions &_other) const;
85 
89  public: friend std::ostream &operator<<(std::ostream &_out,
90  const AdvertiseOptions &_other)
91  {
92  _out << "Advertise options:\n"
93  << "\tScope: ";
94  if (_other.Scope() == Scope_t::PROCESS)
95  _out << "Process" << std::endl;
96  else if (_other.Scope() == Scope_t::HOST)
97  _out << "Host" << std::endl;
98  else
99  _out << "All" << std::endl;
100  return _out;
101  }
102 
107  public: const Scope_t &Scope() const;
108 
113  public: void SetScope(const Scope_t &_scope);
114 
115 #ifdef _WIN32
116 // Disable warning C4251 which is triggered by
117 // std::unique_ptr
118 #pragma warning(push)
119 #pragma warning(disable: 4251)
120 #endif
124 #ifdef _WIN32
125 #pragma warning(pop)
126 #endif
127  };
128 
132  class IGNITION_TRANSPORT_VISIBLE AdvertiseMessageOptions
133  : public AdvertiseOptions
134  {
136  public: AdvertiseMessageOptions();
137 
140  public: AdvertiseMessageOptions(const AdvertiseMessageOptions &_other);
141 
143  public: virtual ~AdvertiseMessageOptions();
144 
148  public: AdvertiseMessageOptions &operator=(
149  const AdvertiseMessageOptions &_other);
150 
155  public: bool operator==(const AdvertiseMessageOptions &_other) const;
156 
161  public: bool operator!=(const AdvertiseMessageOptions &_other) const;
162 
166  public: friend std::ostream &operator<<(std::ostream &_out,
167  const AdvertiseMessageOptions &_other)
168  {
169  _out << static_cast<AdvertiseOptions>(_other);
170  if (_other.Throttled())
171  {
172  _out << "\tThrottled? Yes" << std::endl;
173  _out << "\tRate: " << _other.MsgsPerSec() << " msgs/sec" << std::endl;
174  }
175  else
176  _out << "\tThrottled? No" << std::endl;
177 
178  return _out;
179  }
180 
185  public: bool Throttled() const;
186 
189  public: uint64_t MsgsPerSec() const;
190 
196  public: void SetMsgsPerSec(const uint64_t _newMsgsPerSec);
197 
198 #ifdef _WIN32
199 // Disable warning C4251 which is triggered by
200 // std::unique_ptr
201 #pragma warning(push)
202 #pragma warning(disable: 4251)
203 #endif
207 #ifdef _WIN32
208 #pragma warning(pop)
209 #endif
210  };
211 
214  class IGNITION_TRANSPORT_VISIBLE AdvertiseServiceOptions
215  : public AdvertiseOptions
216  {
218  public: AdvertiseServiceOptions();
219 
222  public: AdvertiseServiceOptions(const AdvertiseServiceOptions &_other);
223 
225  public: virtual ~AdvertiseServiceOptions();
226 
230  public: AdvertiseServiceOptions &operator=(
231  const AdvertiseServiceOptions &_other);
232 
237  public: bool operator==(const AdvertiseServiceOptions &_other) const;
238 
243  public: bool operator!=(const AdvertiseServiceOptions &_other) const;
244 
248  public: friend std::ostream &operator<<(std::ostream &_out,
249  const AdvertiseServiceOptions &_other)
250  {
251  _out << static_cast<AdvertiseOptions>(_other);
252  return _out;
253  }
254 
255 #ifdef _WIN32
256 // Disable warning C4251 which is triggered by
257 // std::unique_ptr
258 #pragma warning(push)
259 #pragma warning(disable: 4251)
260 #endif
264 #ifdef _WIN32
265 #pragma warning(pop)
266 #endif
267  };
268  }
269 }
270 #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.
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:166
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:89
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:57
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:132
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:248
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:40
T endl(T... args)
Definition: gz/transport/AdvertiseOptions.hh:28
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:214
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...