All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
26 
27 namespace 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 
55  {
57  public: AdvertiseOptions();
58 
61  public: AdvertiseOptions(const AdvertiseOptions &_other);
62 
64  public: virtual ~AdvertiseOptions();
65 
69  public: AdvertiseOptions &operator=(const AdvertiseOptions &_other);
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 
130  private: std::unique_ptr<AdvertiseOptionsPrivate> dataPtr;
131  };
132 
137  : public AdvertiseOptions
138  {
140  public: AdvertiseMessageOptions();
141 
144  public: AdvertiseMessageOptions(const AdvertiseMessageOptions &_other);
145 
147  public: virtual ~AdvertiseMessageOptions();
148 
152  public: AdvertiseMessageOptions &operator=(
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 
219  private: std::unique_ptr<AdvertiseMessageOptionsPrivate> dataPtr;
220  };
221 
225  : public AdvertiseOptions
226  {
228  public: AdvertiseServiceOptions();
229 
232  public: AdvertiseServiceOptions(const AdvertiseServiceOptions &_other);
233 
235  public: virtual ~AdvertiseServiceOptions();
236 
240  public: AdvertiseServiceOptions &operator=(
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 
282  private: std::unique_ptr<AdvertiseServiceOptionsPrivate> dataPtr;
283  };
284  }
285 }
286 #endif
Topic/service available to any subscriber (default scope).
A class for customizing the publication options for a topic advertised.
Definition: AdvertiseOptions.hh:136
bool Throttled() const
Whether the publication has been throttled.
friend std::ostream & operator<<(std::ostream &_out, const AdvertiseServiceOptions &_other)
Stream insertion operator.
Definition: AdvertiseOptions.hh:258
friend std::ostream & operator<<(std::ostream &_out, const AdvertiseOptions &_other)
Stream insertion operator.
Definition: AdvertiseOptions.hh:86
Topic/service only available to subscribers in the same process as the publisher. ...
ignition/transport/AdvertiseOptions.hh
Definition: AdvertiseOptions.hh:54
friend std::ostream & operator<<(std::ostream &_out, const AdvertiseMessageOptions &_other)
Stream insertion operator.
Definition: AdvertiseOptions.hh:170
uint64_t MsgsPerSec() const
Get the maximum number of messages per second to be published.
A class for customizing the publication options for a service advertised.
Definition: AdvertiseOptions.hh:224
#define IGNITION_TRANSPORT_VISIBLE
Use to represent "symbol visible" if supported.
Definition: Helpers.hh:57
const Scope_t & Scope() const
Get the scope used in this topic/service.
Scope_t
Definition: AdvertiseOptions.hh:37
Topic/service only available to subscribers in the same machine as the publisher. ...