Gazebo Transport

API Reference

14.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 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 GZ_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 GZ_TRANSPORT_VISIBLE AdvertiseOptions
58 {
61
64 public: AdvertiseOptions(const AdvertiseOptions &_other);
65
67 public: virtual ~AdvertiseOptions();
68
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 GZ_TRANSPORT_VISIBLE AdvertiseMessageOptions
133 : public AdvertiseOptions
134 {
137
141
143 public: virtual ~AdvertiseMessageOptions();
144
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 GZ_TRANSPORT_VISIBLE AdvertiseServiceOptions
215 : public AdvertiseOptions
216 {
219
223
225 public: virtual ~AdvertiseServiceOptions();
226
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