Discovery.hh
Go to the documentation of this file.
T at(T... args)
T cbegin(T... args)
T boolalpha(T... args)
T c_str(T... args)
A class that is used to store information about an advertised publisher. An instance of this class is...
Definition Node.hh:521
A class for customizing the publication options for a topic or service advertised....
Definition AdvertiseOptions.hh:55
A discovery class that implements a distributed topic discovery protocol. It uses UDP multicast for s...
Definition Discovery.hh:97
void WaitForInit() const
Check if ready/initialized. If not, then wait on the initializedCv condition variable.
Definition Discovery.hh:539
void Start()
Start the discovery service. You probably want to register the callbacks for receiving discovery noti...
Definition Discovery.hh:245
bool Advertise(const Pub &_publisher)
Advertise a new message.
Definition Discovery.hh:269
unsigned int ActivityInterval() const
The discovery checks the validity of the topic information every 'activity interval' milliseconds.
Definition Discovery.hh:412
unsigned int HeartbeatInterval() const
Each node broadcasts periodic heartbeats to keep its topic information alive in other nodes....
Definition Discovery.hh:423
std::string HostAddr() const
Get the IP address of this host.
Definition Discovery.hh:402
std::map< std::string, Timestamp > activity
Activity information. Every time there is a message from a remote node, its activity information is u...
Definition Discovery.hh:1113
bool Unadvertise(const std::string &_topic, const std::string &_nUuid)
Unadvertise a new message. Broadcast a discovery message that will cancel all the discovery informati...
Definition Discovery.hh:374
void SetHeartbeatInterval(const unsigned int _ms)
Set the heartbeat interval.
Definition Discovery.hh:451
unsigned int SilenceInterval() const
Get the maximum time allowed without receiving any discovery information from a node before canceling...
Definition Discovery.hh:433
void PrintCurrentState() const
Print the current discovery state.
Definition Discovery.hh:487
void SetSilenceInterval(const unsigned int _ms)
Set the maximum silence interval.
Definition Discovery.hh:460
const TopicStorage< Pub > & Info() const
Get the discovery information.
Definition Discovery.hh:350
bool Publishers(const std::string &_topic, Addresses_M< Pub > &_publishers) const
Get all the publishers' information known for a given topic.
Definition Discovery.hh:360
void ConnectionsCb(const DiscoveryCallback< Pub > &_cb)
Register a callback to receive discovery connection events. Each time a new topic is connected,...
Definition Discovery.hh:470
bool Discover(const std::string &_topic) const
Request discovery information about a topic. When using this method, the user might want to use SetCo...
Definition Discovery.hh:300
void SetActivityInterval(const unsigned int _ms)
Set the activity interval.
Definition Discovery.hh:442
void DisconnectionsCb(const DiscoveryCallback< Pub > &_cb)
Register a callback to receive discovery disconnection events. Each time a topic is no longer active,...
Definition Discovery.hh:480
virtual ~Discovery()
Destructor.
Definition Discovery.hh:214
void TopicList(std::vector< std::string > &_topics) const
Get the list of topics currently advertised in the network.
Definition Discovery.hh:530
Discovery(const std::string &_pUuid, const int _port, const bool _verbose=false)
Constructor.
Definition Discovery.hh:103
This class stores all the information about a publisher. It stores the topic name that publishes,...
Definition Publisher.hh:38
Store address information about topics and provide convenient methods for adding new topics,...
Definition TopicStorage.hh:38
bool HasAnyPublishers(const std::string &_topic, const std::string &_pUuid) const
Return if there is any publisher stored for the given topic and process UUID.
Definition TopicStorage.hh:130
bool DelPublisherByNode(const std::string &_topic, const std::string &_pUuid, const std::string &_nUuid)
Remove a publisher associated to a given topic and UUID pair.
Definition TopicStorage.hh:218
bool Publisher(const std::string &_topic, const std::string &_pUuid, const std::string &_nUuid, T &_publisher) const
Get the address information for a given topic and node UUID.
Definition TopicStorage.hh:165
bool DelPublishersByProc(const std::string &_pUuid)
Remove all the publishers associated to a given process.
Definition TopicStorage.hh:258
bool AddPublisher(const T &_publisher)
Add a new address associated to a given topic and node UUID.
Definition TopicStorage.hh:49
bool Publishers(const std::string &_topic, std::map< std::string, std::vector< T > > &_info) const
Get the map of publishers stored for a given topic.
Definition TopicStorage.hh:203
void PublishersByProc(const std::string &_pUuid, std::map< std::string, std::vector< T > > &_pubs) const
Given a process UUID, the function returns the list of publishers contained in this process UUID with...
Definition TopicStorage.hh:282
void Print() const
Print all the information for debugging purposes.
Definition TopicStorage.hh:342
void TopicList(std::vector< std::string > &_topics) const
Get the list of topics currently stored.
Definition TopicStorage.hh:335
T duration_cast(T... args)
T empty(T... args)
T cend(T... args)
T endl(T... args)
T erase(T... args)
T join(T... args)
T joinable(T... args)
T lock(T... args)
T max(T... args)
T min(T... args)
std::chrono::steady_clock::time_point Timestamp
Definition TransportTypes.hh:151
std::string determineHost()
Determine IP or hostname. Reference: https://github.com/ros/ros_comm/blob/hydro-devel/clients/ roscpp...
bool pollSockets(const std::vector< int > &_sockets, const int _timeout)
std::unique_lock< std::recursive_mutex > lk(this->Shared() ->mutex)
*brief Advertise a new service without any output parameter *In this version the callback is a free function *param[in] _topic Topic name associated to the service *param[in] _cb Callback to handle the service request with the *following void(* _cb)(const RequestT &_req)
Definition Node.hh:527
@ 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.
bool env(const std::string &_name, std::string &_value)
Find the environment variable '_name' and return its value.
static const std::vector< std::string > MsgTypesStr
Used for debugging the message type received/send.
Definition Packet.hh:44
std::vector< std::string > determineInterfaces()
Determine the list of network interfaces for this machine. Reference: https://github....
*brief Advertise a new service without any output parameter *In this version the callback is a free function *param[in] _topic Topic name associated to the service *param[in] _cb Callback to handle the service request with the *following void(*) const AdvertiseServiceOptions ReplyT const std::string _topic)
Definition Node.hh:558
cb(_internalRep, _internalResult)
Definition AdvertiseOptions.hh:28
T notify_all(T... args)
T now(T... args)
T push_back(T... args)
T resize(T... args)
T unlock(T... args)
T wait(T... args)