Ignition Transport

API Reference

4.0.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/Export.hh"
26
27namespace ignition
28{
29 namespace transport
30 {
31 class AdvertiseOptionsPrivate;
32 class AdvertiseMessageOptionsPrivate;
33 class AdvertiseServiceOptionsPrivate;
34
37 enum class Scope_t
38 {
41 PROCESS,
44 HOST,
46 ALL
47 };
48
54 class IGNITION_TRANSPORT_VISIBLE AdvertiseOptions
55 {
58
61 public: AdvertiseOptions(const AdvertiseOptions &_other);
62
64 public: virtual ~AdvertiseOptions();
65
70
75 public: bool operator==(const AdvertiseOptions &_other) const;
76
81 public: bool operator!=(const AdvertiseOptions &_other) const;
82
86 public: friend std::ostream &operator<<(std::ostream &_out,
87 const AdvertiseOptions &_other)
88 {
89 _out << "Advertise options:\n"
90 << "\tScope: ";
91 if (_other.Scope() == Scope_t::PROCESS)
92 _out << "Process" << std::endl;
93 else if (_other.Scope() == Scope_t::HOST)
94 _out << "Host" << std::endl;
95 else
96 _out << "All" << std::endl;
97 return _out;
98 }
99
104 public: const Scope_t &Scope() const;
105
110 public: void SetScope(const Scope_t &_scope);
111
117 public: size_t Pack(char *_buffer) const;
118
122 public: size_t Unpack(const char *_buffer);
123
126 public: size_t MsgLength() const;
127
131 };
132
136 class IGNITION_TRANSPORT_VISIBLE AdvertiseMessageOptions
137 : public AdvertiseOptions
138 {
141
145
147 public: virtual ~AdvertiseMessageOptions();
148
153 const AdvertiseMessageOptions &_other);
154
159 public: bool operator==(const AdvertiseMessageOptions &_other) const;
160
165 public: bool operator!=(const AdvertiseMessageOptions &_other) const;
166
170 public: friend std::ostream &operator<<(std::ostream &_out,
171 const AdvertiseMessageOptions &_other)
172 {
173 _out << static_cast<AdvertiseOptions>(_other);
174 if (_other.Throttled())
175 {
176 _out << "\tThrottled? Yes" << std::endl;
177 _out << "\tRate: " << _other.MsgsPerSec() << " msgs/sec" << std::endl;
178 }
179 else
180 _out << "\tThrottled? No" << std::endl;
181
182 return _out;
183 }
184
189 public: bool Throttled() const;
190
193 public: uint64_t MsgsPerSec() const;
194
200 public: void SetMsgsPerSec(const uint64_t _newMsgsPerSec);
201
207 public: size_t Pack(char *_buffer) const;
208
211 public: size_t Unpack(const char *_buffer);
212
215 public: size_t MsgLength() const;
216
220 };
221
224 class IGNITION_TRANSPORT_VISIBLE AdvertiseServiceOptions
225 : public AdvertiseOptions
226 {
229
233
235 public: virtual ~AdvertiseServiceOptions();
236
241 const AdvertiseServiceOptions &_other);
242
247 public: bool operator==(const AdvertiseServiceOptions &_other) const;
248
253 public: bool operator!=(const AdvertiseServiceOptions &_other) const;
254
258 public: friend std::ostream &operator<<(std::ostream &_out,
259 const AdvertiseServiceOptions &_other)
260 {
261 _out << static_cast<AdvertiseOptions>(_other);
262 return _out;
263 }
264
270 public: size_t Pack(char *_buffer) const;
271
274 public: size_t Unpack(const char *_buffer);
275
278 public: size_t MsgLength() const;
279
283 };
284 }
285}
286#endif
A class for customizing the publication options for a topic advertised. E.g.: Set the rate of message...
Definition AdvertiseOptions.hh:138
size_t MsgLength() const
Get the total length of the message.
AdvertiseMessageOptions(const AdvertiseMessageOptions &_other)
Copy constructor.
AdvertiseMessageOptions & operator=(const AdvertiseMessageOptions &_other)
Assignment operator.
void SetMsgsPerSec(const uint64_t _newMsgsPerSec)
Set the maximum number of messages per second to be published. Note that we calculate the minimum per...
friend std::ostream & operator<<(std::ostream &_out, const AdvertiseMessageOptions &_other)
Stream insertion operator.
Definition AdvertiseOptions.hh:170
bool operator==(const AdvertiseMessageOptions &_other) const
Equality operator. This function checks if the given AdvertiseMessageOptions has identical content to...
bool Throttled() const
Whether the publication has been throttled.
size_t Pack(char *_buffer) const
Serialize the options. The caller has ownership of the buffer and is responsible for its [de]allocati...
size_t Unpack(const char *_buffer)
Unserialize the options.
uint64_t MsgsPerSec() const
Get the maximum number of messages per second to be published.
bool operator!=(const AdvertiseMessageOptions &_other) const
Inequality operator. This function checks if the given options do not have identical values to this o...
A class for customizing the publication options for a topic or service advertised....
Definition AdvertiseOptions.hh:55
AdvertiseOptions(const AdvertiseOptions &_other)
Copy constructor.
virtual ~AdvertiseOptions()
Destructor.
void SetScope(const Scope_t &_scope)
Set the scope of the topic or service.
size_t MsgLength() const
Get the total length of the message.
friend std::ostream & operator<<(std::ostream &_out, const AdvertiseOptions &_other)
Stream insertion operator.
Definition AdvertiseOptions.hh:86
bool operator==(const AdvertiseOptions &_other) const
Equality operator. This function checks if the given AdvertiseOptions has identical content to this o...
const Scope_t & Scope() const
Get the scope used in this topic/service.
size_t Pack(char *_buffer) const
Serialize the options. The caller has ownership of the buffer and is responsible for its [de]allocati...
size_t Unpack(const char *_buffer)
Deserialize and set the options. The input buffer is unpacked and used to set this object's options.
AdvertiseOptions & operator=(const AdvertiseOptions &_other)
Assignment operator.
bool operator!=(const AdvertiseOptions &_other) const
Inequality operator. This function checks if the given options do not have identical values to this o...
A class for customizing the publication options for a service advertised.
Definition AdvertiseOptions.hh:226
AdvertiseServiceOptions(const AdvertiseServiceOptions &_other)
Copy constructor.
size_t MsgLength() const
Get the total length of the message.
AdvertiseServiceOptions & operator=(const AdvertiseServiceOptions &_other)
Assignment operator.
friend std::ostream & operator<<(std::ostream &_out, const AdvertiseServiceOptions &_other)
Stream insertion operator.
Definition AdvertiseOptions.hh:258
bool operator==(const AdvertiseServiceOptions &_other) const
Equality operator. This function checks if the given AdvertiseMessageOptions has identical content to...
size_t Pack(char *_buffer) const
Serialize the options. The caller has ownership of the buffer and is responsible for its [de]allocati...
bool operator!=(const AdvertiseServiceOptions &_other) const
Inequality operator. This function checks if the given options do not have identical values to this o...
size_t Unpack(const char *_buffer)
Unserialize the options.
T endl(T... args)
Scope_t
Definition AdvertiseOptions.hh:38
@ ALL
Topic/service available to any subscriber (default scope).
@ HOST
Topic/service only available to subscribers in the same machine as the publisher.
@ PROCESS
Topic/service only available to subscribers in the same process as the publisher.
Definition AdvertiseOptions.hh:28