Gazebo Gazebo

API Reference

6.18.0
gz/sim/comms/Broker.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2022 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_GAZEBO_BROKER_HH_
19 #define GZ_GAZEBO_BROKER_HH_
20 
21 #include <memory>
22 
23 #include <gz/utils/ImplPtr.hh>
24 #include <sdf/sdf.hh>
26 #include "gz/sim/config.hh"
27 
28 namespace ignition
29 {
30 namespace msgs
31 {
32  // Forward declarations.
33  class Boolean;
34  class Dataframe;
35  class StringMsg_V;
36 }
37 namespace gazebo
38 {
39 // Inline bracket to help doxygen filtering.
40 inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE {
41 namespace comms
42 {
43  // Forward declarations.
44  class MsgManager;
45 
85  class IGNITION_GAZEBO_VISIBLE Broker
86  {
88  public: Broker();
89 
93 
98  public: void Start();
99 
102  public: std::chrono::steady_clock::duration Time() const;
103 
106  public: void SetTime(const std::chrono::steady_clock::duration &_time);
107 
117  public: bool OnBind(const ignition::msgs::StringMsg_V &_req,
118  ignition::msgs::Boolean &_rep);
119 
125  public: void OnUnbind(const ignition::msgs::StringMsg_V &_req);
126 
130  public: void OnMsg(const ignition::msgs::Dataframe &_msg);
131 
134  public: void DeliverMsgs();
135 
139 
141  public: void Lock();
142 
144  public: void Unlock();
145 
147  IGN_UTILS_UNIQUE_IMPL_PTR(dataPtr)
148  };
149 }
150 }
151 }
152 }
153 
154 #endif
A class to store messages to be delivered using a comms model. This class should be used in combinati...
Definition: gz/sim/comms/Broker.hh:86
void Start()
Start handling comms services.
void SetTime(const std::chrono::steady_clock::duration &_time)
Set the current time.
void OnUnbind(const ignition::msgs::StringMsg_V &_req)
Unbind a given client address. The client associated to this address will not receive any more messag...
std::chrono::steady_clock::duration Time() const
Get the current time.
MsgManager & DataManager()
Get a mutable reference to the message manager.
void OnMsg(const ignition::msgs::Dataframe &_msg)
Callback executed to process a communication request from one of the clients.
void DeliverMsgs()
Process all the messages in the inbound queue and deliver them to the destination clients.
void Lock()
Lock the mutex to access the message manager.
void Unlock()
Unlock the mutex to access the message manager.
void Load(std::shared_ptr< const sdf::Element > _sdf)
Configure the broker via SDF.
bool OnBind(const ignition::msgs::StringMsg_V &_req, ignition::msgs::Boolean &_rep)
This method associates an address with a client topic used as callback for receiving messages....
Class to handle messages and subscriptions.
Definition: gz/sim/comms/MsgManager.hh:79
This library is part of the Gazebo project.
Definition: gz/sim/Actor.hh:34