Gazebo Gazebo

API Reference

6.16.0
gz/sim/comms/MsgManager.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_MSGMANAGER_HH_
19 #define GZ_GAZEBO_MSGMANAGER_HH_
20 
21 #include <deque>
22 #include <memory>
23 #include <string>
24 #include <unordered_map>
25 
26 #include <gz/transport/Node.hh>
27 #include <gz/utils/ImplPtr.hh>
28 #include "gz/sim/config.hh"
29 #include "gz/sim/Entity.hh"
30 #include "gz/sim/System.hh"
31 
32 namespace ignition
33 {
34 namespace msgs
35 {
36  // Forward declarations.
37  class Dataframe;
38 }
39 namespace gazebo
40 {
41 // Inline bracket to help doxygen filtering.
42 inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE {
43 namespace comms
44 {
45 
48 
51 using SubscriptionHandler =
53 
56 {
59 
62 
65 
68 
71 };
72 
76 
78 class IGNITION_GAZEBO_VISIBLE MsgManager
79 {
81  public: MsgManager();
82 
91  public: bool AddSubscriber(const std::string &_address,
92  const std::string &_modelName,
93  const std::string &_topic);
94 
98  public: void AddInbound(const std::string &_address,
99  const msgs::DataframeSharedPtr &_msg);
100 
104  public: void AddOutbound(const std::string &_address,
105  const msgs::DataframeSharedPtr &_msg);
106 
111  public: bool RemoveSubscriber(const std::string &_address,
112  const std::string &_topic);
113 
118  public: bool RemoveInbound(const std::string &_address,
119  const msgs::DataframeSharedPtr &_msg);
120 
125  public: bool RemoveOutbound(const std::string &_address,
126  const msgs::DataframeSharedPtr &_msg);
127 
130  public: void DeliverMsgs();
131 
135  public: const Registry &DataConst() const;
136 
140  public: Registry &Data();
141 
145  public: Registry Copy() const;
146 
149  public: void Set(const Registry &_newContent);
150 
152  IGN_UTILS_UNIQUE_IMPL_PTR(dataPtr)
153 };
154 }
155 }
156 }
157 }
158 
159 #endif
void AddInbound(const std::string &_address, const msgs::DataframeSharedPtr &_msg)
Add a new message to the inbound queue.
bool RemoveInbound(const std::string &_address, const msgs::DataframeSharedPtr &_msg)
Remove a message from the inbound queue.
void Set(const Registry &_newContent)
Set the data structure containing subscriptions and data queues.
uint64_t Entity
An Entity identifies a single object in simulation such as a model, link, or light....
Definition: gz/sim/Entity.hh:58
DataQueue inboundMsgs
Queue of inbound messages.
Definition: gz/sim/comms/MsgManager.hh:58
This library is part of the Gazebo project.
STL class.
STL class.
DataQueue outboundMsgs
Queue of outbound messages.
Definition: gz/sim/comms/MsgManager.hh:61
void Set(msgs::AxisAlignedBox *_b, const math::AxisAlignedBox &_v)
MsgManager()
Default constructor.
void DeliverMsgs()
This function delivers all the messages in the inbound queue to the appropriate subscribers....
const Registry & DataConst() const
Get an inmutable reference to the data containing subscriptions and data queues.
bool RemoveOutbound(const std::string &_address, const msgs::DataframeSharedPtr &_msg)
Remove a message from the outbound queue.
void AddOutbound(const std::string &_address, const msgs::DataframeSharedPtr &_msg)
Add a new message to the outbound queue.
Registry & Data()
Get a mutable reference to the data containing subscriptions and data queues.
std::string modelName
Model name associated to this address.
Definition: gz/sim/comms/MsgManager.hh:67
Registry Copy() const
Get a copy of the data structure containing subscriptions and data queues.
bool AddSubscriber(const std::string &_address, const std::string &_modelName, const std::string &_topic)
Add a new subscriber. It's possible to associate multiple topics to the same address/model pair....
All the information associated to an address.
Definition: gz/sim/comms/MsgManager.hh:55
Class to handle messages and subscriptions.
Definition: gz/sim/comms/MsgManager.hh:78
gazebo::Entity entity
Entity of the model associated to this address.
Definition: gz/sim/comms/MsgManager.hh:70
SubscriptionHandler subscriptions
Subscribers.
Definition: gz/sim/comms/MsgManager.hh:64
bool RemoveSubscriber(const std::string &_address, const std::string &_topic)
Remove an existing subscriber.