Go to the documentation of this file.
18 #ifndef GZ_TRANSPORT_NODESHARED_HH_
19 #define GZ_TRANSPORT_NODESHARED_HH_
22 #pragma warning(push, 0)
24 #include <google/protobuf/message.h>
37 #include "gz/transport/config.hh"
38 #include "gz/transport/Export.hh"
54 inline namespace IGNITION_TRANSPORT_VERSION_NAMESPACE {
61 class NodeSharedPrivate;
74 public:
void RunReceptionTask();
89 const size_t _dataSize,
94 public:
void RecvMsgUpdate();
171 public:
void TriggerCallbacks(
179 public:
void RecvControlUpdate();
182 public:
void RecvSrvRequest();
185 public:
void RecvSrvResponse();
192 public:
void SendPendingRemoteReqs(
const std::string &_topic,
228 public:
bool TopicPublishers(
const std::string &_topic,
237 public:
bool DiscoverService(
const std::string &_topic)
const;
256 public:
int RcvHwm();
268 public:
int SndHwm();
276 public:
void EnableStats(
const std::string &_topic,
bool _enable,
285 public: std::optional<TopicStatistics> TopicStats(
297 private:
bool InitializeSockets();
312 #pragma warning(push)
313 #pragma warning(disable: 4251)
328 public:
static const int kDefaultMsgDiscPort = 10317;
331 public:
static const int kDefaultSrvDiscPort = 10318;
334 public:
int msgDiscPort = kDefaultMsgDiscPort;
337 public:
int srvDiscPort = kDefaultSrvDiscPort;
363 public:
bool HasSubscriber(
372 public:
bool HasSubscriber(
393 public:
bool RemoveHandlersForNode(
411 #pragma warning(push)
412 #pragma warning(disable: 4251)
443 private:
friend Node;
444 private:
friend NodePrivate;
std::string myReplierAddress
My replier service call address.
Definition: gz/transport/NodeShared.hh:433
HandlerStorage< ISubscriptionHandler > normal
Normal local subscriptions.
Definition: gz/transport/NodeShared.hh:398
void OnNewDisconnection(const MessagePublisher &_pub)
Callback executed when the discovery detects disconnections.
std::map< std::string, ISubscriptionHandler_M > localHandlers
This is a map of the standard local callback handlers. The key is the topic name, and the value is an...
Definition: gz/transport/NodeShared.hh:105
Encapsulates statistics for a single topic. The set of statistics include:
Definition: gz/transport/TopicStatistics.hh:113
This struct wraps up the two different types of subscription handlers: normal (deserialized) and raw ...
Definition: gz/transport/NodeShared.hh:355
This struct provides information about the Subscribers of a Publisher. It should only be retrieved us...
Definition: gz/transport/NodeShared.hh:141
Definition: gz/transport/AdvertiseOptions.hh:28
HandlerInfo contains information about callback handlers which is useful for local publishers and mes...
Definition: gz/transport/NodeShared.hh:100
void OnNewSrvConnection(const ServicePublisher &_pub)
Callback executed when the discovery detects a new service call.
std::string pUuid
Process UUID.
Definition: gz/transport/NodeShared.hh:316
std::optional< TopicStatistics > TopicStats(const std::string &_topic) const
Get the current statistics for a topic. Statistics must have been enabled using the EnableStatistics ...
std::string myControlAddress
My pub/sub control address.
Definition: gz/transport/NodeShared.hh:427
void SendPendingRemoteReqs(const std::string &_topic, const std::string &_reqType, const std::string &_repType)
Try to send all the requests for a given service call and a pair of request/response types.
bool HasSubscriber(const std::string &_fullyQualifiedTopic, const std::string &_msgType) const
Returns true if this wrapper contains any subscriber that matches the given topic name and message ty...
void RecvSrvResponse()
Method in charge of receiving the service call responses.
bool DiscoverService(const std::string &_topic) const
Pass through to bool Discovery::Discover(const std::string &_topic) const.
bool AdvertisePublisher(const ServicePublisher &_publisher)
Pass through to bool Advertise(const Pub &_publisher)
HandlerStorage< IReqHandler > requests
Pending service call requests.
Definition: gz/transport/NodeShared.hh:418
std::string discoveryIP
Default IP address used by the message discovery layer.
Definition: gz/transport/NodeShared.hh:325
std::recursive_mutex mutex
Mutex to guarantee exclusive access between all threads.
Definition: gz/transport/NodeShared.hh:322
void RecvSrvRequest()
Method in charge of receiving the service call requests.
static const int kDefaultSrvDiscPort
Default port used by the service discovery layer.
Definition: gz/transport/NodeShared.hh:331
void OnNewSrvDisconnection(const ServicePublisher &_pub)
Callback executed when a service call is no longer available.
virtual ~NodeShared()
Destructor.
This class stores all the information about a message publisher.
Definition: gz/transport/Publisher.hh:181
std::thread threadReception
thread in charge of receiving and handling incoming messages.
Definition: gz/transport/NodeShared.hh:319
int verbose
Print activity to stdout.
Definition: gz/transport/NodeShared.hh:421
A portable class for representing a Universally Unique Identifier.
Definition: gz/transport/Uuid.hh:45
void RecvMsgUpdate()
Method in charge of receiving the topic updates.
void OnEndRegistration(const MessagePublisher &_pub)
Callback executed when a remote subscriber unregisters.
int srvDiscPort
Port used by the service discovery layer.
Definition: gz/transport/NodeShared.hh:337
void OnNewConnection(const MessagePublisher &_pub)
Callback executed when the discovery detects new topics.
Uuid responseReceiverId
Response receiver socket identity.
Definition: gz/transport/NodeShared.hh:304
A class that allows a client to communicate with other peers. There are two main communication modes:...
Definition: gz/transport/Node.hh:95
std::string myRequesterAddress
My requester service call address.
Definition: gz/transport/NodeShared.hh:430
void RunReceptionTask()
Receive data and control messages.
std::map< std::string, RawSubscriptionHandler_M > rawHandlers
This is a map of the raw local callback handlers. The key is the topic name, and the value is another...
Definition: gz/transport/NodeShared.hh:110
A class that provides information about the message received.
Definition: gz/transport/MessageInfo.hh:37
HandlerWrapper localSubscribers
Definition: gz/transport/NodeShared.hh:406
bool TopicPublishers(const std::string &_topic, SrvAddresses_M &_publishers) const
Pass through to bool Publishers(const std::string &_topic, Addresses_M<Pub> &_publishers) const.
std::string myAddress
My pub/sub address.
Definition: gz/transport/NodeShared.hh:424
bool haveRemote
True if this Publisher has any remote subscribers.
Definition: gz/transport/NodeShared.hh:145
void TriggerCallbacks(const MessageInfo &_info, const std::string &_msgData, const HandlerInfo &_handlerInfo)
Call the SubscriptionHandler callbacks (local and raw) for this NodeShared.
HandlerStorage< RawSubscriptionHandler > raw
Raw local subscriptions. Keeping these separate from localSubscriptions allows us to avoid an unneces...
Definition: gz/transport/NodeShared.hh:403
void RecvControlUpdate()
Method in charge of receiving the control updates (when a new remote subscriber notifies its presence...
int RcvHwm()
Get the capacity of the buffer (High Water Mark) that stores incoming Ignition Transport messages....
TopicStorage< MessagePublisher > remoteSubscribers
Remote subscribers.
Definition: gz/transport/NodeShared.hh:346
bool RemoveHandlersForNode(const std::string &_fullyQualifiedTopic, const std::string &_nUuid)
Remove the handlers for the given topic name that belong to a specific node.
This class stores all the information about a service publisher.
Definition: gz/transport/Publisher.hh:296
HandlerStorage< IRepHandler > repliers
Service call repliers.
Definition: gz/transport/NodeShared.hh:415
Uuid replierId
Replier socket identity.
Definition: gz/transport/NodeShared.hh:307
std::string hostAddr
IP address of this host.
Definition: gz/transport/NodeShared.hh:436
std::vector< std::string > NodeUuids(const std::string &_fullyQualifiedTopic, const std::string &_msgTypeName) const
Get a set of node UUIDs for subscribers in this wrapper that match the topic and message type criteri...
static const int kDefaultMsgDiscPort
Default port used by the message discovery layer.
Definition: gz/transport/NodeShared.hh:328
Store address information about topics and provide convenient methods for adding new topics,...
Definition: gz/transport/TopicStorage.hh:41
bool haveLocal
True iff there are any standard local subscribers.
Definition: gz/transport/NodeShared.hh:113
void(void *_data, void *_hint) DeallocFunc
Definition: gz/transport/TransportTypes.hh:171
HandlerInfo CheckHandlerInfo(const std::string &_topic) const
Get information about the local and raw subscribers that are attached to this NodeShared.
bool Publish(const std::string &_topic, char *_data, const size_t _dataSize, DeallocFunc *_ffn, const std::string &_msgType)
Publish data.
Private data for the Node class. This class should not be directly used. You should use the Node clas...
Definition: gz/transport/NodeShared.hh:66
void OnNewRegistration(const MessagePublisher &_pub)
Callback executed when a remote subscriber connects.
void EnableStats(const std::string &_topic, bool _enable, std::function< void(const TopicStatistics &_stats)> _cb)
Turn topic statistics on or off.
SubscriberInfo CheckSubscriberInfo(const std::string &_topic, const std::string &_msgType) const
Get information about the nodes that are subscribed to the publishers of this NodeShared.
bool haveRaw
True iff there are any raw local subscribers.
Definition: gz/transport/NodeShared.hh:116
static NodeShared * Instance()
NodeShared is a singleton. This method gets the NodeShared instance shared between all the nodes.
Class to store and manage service call handlers.
Definition: gz/transport/HandlerStorage.hh:39
int msgDiscPort
Port used by the message discovery layer.
Definition: gz/transport/NodeShared.hh:334
int SndHwm()
Get the capacity of the buffer (High Water Mark) that stores outgoing Ignition Transport messages....