Ignition Transport

API Reference

8.1.0
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 IGN_TRANSPORT_ADVERTISEOPTIONS_HH_
19 #define IGN_TRANSPORT_ADVERTISEOPTIONS_HH_
20 
21 #include <cstdint>
22 #include <iostream>
23 #include <memory>
24 
25 #include "ignition/transport/config.hh"
26 #include "ignition/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 
122  public: size_t IGN_DEPRECATED(8) Pack(char *_buffer) const;
123 
127  public: size_t IGN_DEPRECATED(8) Unpack(const char *_buffer);
128 
131  public: size_t IGN_DEPRECATED(8) MsgLength() const;
132 
133 #ifdef _WIN32
134 // Disable warning C4251 which is triggered by
135 // std::unique_ptr
136 #pragma warning(push)
137 #pragma warning(disable: 4251)
138 #endif
142 #ifdef _WIN32
143 #pragma warning(pop)
144 #endif
145  };
146 
150  class IGNITION_TRANSPORT_VISIBLE AdvertiseMessageOptions
151  : public AdvertiseOptions
152  {
154  public: AdvertiseMessageOptions();
155 
158  public: AdvertiseMessageOptions(const AdvertiseMessageOptions &_other);
159 
161  public: virtual ~AdvertiseMessageOptions();
162 
166  public: AdvertiseMessageOptions &operator=(
167  const AdvertiseMessageOptions &_other);
168 
173  public: bool operator==(const AdvertiseMessageOptions &_other) const;
174 
179  public: bool operator!=(const AdvertiseMessageOptions &_other) const;
180 
184  public: friend std::ostream &operator<<(std::ostream &_out,
185  const AdvertiseMessageOptions &_other)
186  {
187  _out << static_cast<AdvertiseOptions>(_other);
188  if (_other.Throttled())
189  {
190  _out << "\tThrottled? Yes" << std::endl;
191  _out << "\tRate: " << _other.MsgsPerSec() << " msgs/sec" << std::endl;
192  }
193  else
194  _out << "\tThrottled? No" << std::endl;
195 
196  return _out;
197  }
198 
203  public: bool Throttled() const;
204 
207  public: uint64_t MsgsPerSec() const;
208 
214  public: void SetMsgsPerSec(const uint64_t _newMsgsPerSec);
215 
221  public: size_t IGN_DEPRECATED(8) Pack(char *_buffer) const;
222 
225  public: size_t IGN_DEPRECATED(8) Unpack(const char *_buffer);
226 
229  public: size_t IGN_DEPRECATED(8) MsgLength() const;
230 
231 #ifdef _WIN32
232 // Disable warning C4251 which is triggered by
233 // std::unique_ptr
234 #pragma warning(push)
235 #pragma warning(disable: 4251)
236 #endif
240 #ifdef _WIN32
241 #pragma warning(pop)
242 #endif
243  };
244 
247  class IGNITION_TRANSPORT_VISIBLE AdvertiseServiceOptions
248  : public AdvertiseOptions
249  {
251  public: AdvertiseServiceOptions();
252 
255  public: AdvertiseServiceOptions(const AdvertiseServiceOptions &_other);
256 
258  public: virtual ~AdvertiseServiceOptions();
259 
263  public: AdvertiseServiceOptions &operator=(
264  const AdvertiseServiceOptions &_other);
265 
270  public: bool operator==(const AdvertiseServiceOptions &_other) const;
271 
276  public: bool operator!=(const AdvertiseServiceOptions &_other) const;
277 
281  public: friend std::ostream &operator<<(std::ostream &_out,
282  const AdvertiseServiceOptions &_other)
283  {
284  _out << static_cast<AdvertiseOptions>(_other);
285  return _out;
286  }
287 
293  public: size_t IGN_DEPRECATED(8) Pack(char *_buffer) const;
294 
297  public: size_t IGN_DEPRECATED(8) Unpack(const char *_buffer);
298 
301  public: size_t IGN_DEPRECATED(8) MsgLength() const;
302 
303 #ifdef _WIN32
304 // Disable warning C4251 which is triggered by
305 // std::unique_ptr
306 #pragma warning(push)
307 #pragma warning(disable: 4251)
308 #endif
312 #ifdef _WIN32
313 #pragma warning(pop)
314 #endif
315  };
316  }
317  }
318 }
319 #endif
bool Throttled() const
Whether the publication has been throttled.
Topic/service available to any subscriber (default scope).
Scope_t
Definition: AdvertiseOptions.hh:42
A class for customizing the publication options for a topic advertised. E.g.: Set the rate of message...
Definition: AdvertiseOptions.hh:150
uint64_t MsgsPerSec() const
Get the maximum number of messages per second to be published.
Topic/service only available to subscribers in the same machine as the publisher. ...
T endl(T... args)
friend std::ostream & operator<<(std::ostream &_out, const AdvertiseServiceOptions &_other)
Stream insertion operator.
Definition: AdvertiseOptions.hh:281
friend std::ostream & operator<<(std::ostream &_out, const AdvertiseOptions &_other)
Stream insertion operator.
Definition: AdvertiseOptions.hh:91
A class for customizing the publication options for a topic or service advertised. E.g.: Set the scope of a topic/service.
Definition: AdvertiseOptions.hh:59
friend std::ostream & operator<<(std::ostream &_out, const AdvertiseMessageOptions &_other)
Stream insertion operator.
Definition: AdvertiseOptions.hh:184
A class for customizing the publication options for a service advertised.
Definition: AdvertiseOptions.hh:247
const Scope_t & Scope() const
Get the scope used in this topic/service.
Topic/service only available to subscribers in the same process as the publisher. ...
Definition: AdvertiseOptions.hh:28
STL class.