Listener#
constellation::listener
Namespace#
-
class CMDPListener : public constellation::pools::SubscriberPool<message::CMDP1Message, protocol::CHIRP::ServiceIdentifier::MONITORING>#
Subclassed by DummyListener, constellation::listener::LogListener
Public Types
-
using SubscriberPoolT = pools::SubscriberPool<message::CMDP1Message, protocol::CHIRP::ServiceIdentifier::MONITORING>#
Public Functions
-
CMDPListener(std::string_view log_topic, std::function<void(message::CMDP1Message&&)> callback)#
Construct CMDPListener.
- Parameters:
log_topic – Logger topic to be used for this component
callback – Callback function pointer for received messages
-
virtual ~CMDPListener() = default#
-
void subscribeTopic(std::string topic)#
Subscribe to a given topic for all sockets.
- Parameters:
topic – Topic to subscribe to
-
void unsubscribeTopic(std::string topic)#
Unsubscribe from a given topic for all sockets.
- Parameters:
topic – Topic to unsubscribe from
-
void multiscribeTopics(const std::vector<std::string> &unsubscribe_topics, const std::vector<std::string> &subscribe_topics)#
Unsubscribe from and subscribe to multiple topics for all sockets.
- Parameters:
unsubscribe_topics – List of topics to unsubscribe from
subscribe_topics – List of topics to subscribe to
-
std::set<std::string> getTopicSubscriptions()#
Get set of subscribed topics for all sockets.
- Returns:
Set containing the currently subscribed topics
-
void subscribeExtraTopic(const std::string &host, std::string topic)#
Subscribe to a given topic for a specific socket.
Note
Extra topics are topics subscribed to in addition to the topics for every socket
- Parameters:
host – Canonical name of the host to subscribe to
topic – Topic to subscribe to
-
void unsubscribeExtraTopic(const std::string &host, std::string topic)#
Unsubscribe from a given topic for a specific socket.
Note
Only unsubscribes if not in topics that every socket is subscribed to
- Parameters:
host – Canonical name of the host to unsubscribe from
topic – Topic to unsubscribe from
-
void multiscribeExtraTopics(const std::string &host, const std::vector<std::string> &unsubscribe_topics, const std::vector<std::string> &subscribe_topics)#
Unsubscribe from and subscribe to multiple extra topics for a specific socket.
- Parameters:
host – Canonical name of the host to unsubscribe from and subscribe to
unsubscribe_topics – List of topics to unsubscribe from
subscribe_topics – List of topics to subscribe to
-
std::set<std::string> getExtraTopicSubscriptions(const std::string &host)#
Get set of subscribed extra topics for a specific socket.
Note
Extra topics are topics subscribed to in addition to the topics for every socket
- Returns:
Set containing the currently subscribed extra topics for given host
-
void removeExtraTopicSubscriptions(const std::string &host)#
Remove extra topics for a specific socket.
- Parameters:
host – Canonical name of the host
-
void removeExtraTopicSubscriptions()#
Remove extra topics for all sockets.
-
std::map<std::string, std::string> getAvailableTopics(std::string_view sender) const#
Obtain available topics for given sender. Topics are parsed from CMDP notification messages and cached per sender. Returns an empty map if the sender is not known or has not sent a topic notification yet.
- Parameters:
sender – Sending CMDP host to get available topics for
- Returns:
Map with available topics as keys and their description as values
-
std::map<std::string, std::string> getAvailableTopics() const#
Obtain all available topics from any sender.
- Returns:
Map with available topics as keys and their description as values
-
bool isTopicAvailable(std::string_view topic) const#
Check if a given topic is in the list of available topics.
Note
the comparison here is case-sensitive.
- Parameters:
topic – Topic to search for
- Returns:
Boolean indicating whether the topic is available or not
-
bool isSenderAvailable(std::string_view sender) const#
Check if a given sender is known and available.
Note
the comparison here is case-sensitive.
- Parameters:
sender – Sender to search for
- Returns:
Boolean indicating whether the sender is available or not
Protected Functions
-
virtual void host_connected(const chirp::DiscoveredService &service) override#
Method for derived classes to act on newly connected sockets.
Warning
Derived functions should always call
CMDPListener::host_connected()
to ensure that sockets are subscribed to the correct topics.
-
virtual void host_disconnected(const chirp::DiscoveredService &service) override#
Method for derived classes to act on sockets before disconnecting.
Warning
Derived functions should always call
CMDPListener::host_disconnected()
-
virtual void topics_changed(std::string_view sender)#
Method for derived classes to act on topic notifications.
- Parameters:
sender – CMDP sending host of the topic notification
-
virtual void sender_connected(std::string_view sender)#
Method for derived classes to act on new senders.
- Parameters:
sender – New CMDP sending host
-
virtual void sender_disconnected(std::string_view sender)#
Method for derived classes to act on disconnecting senders.
- Parameters:
sender – Disconnected CMDP sending host
-
using SubscriberPoolT = pools::SubscriberPool<message::CMDP1Message, protocol::CHIRP::ServiceIdentifier::MONITORING>#
-
class LogListener : public constellation::listener::CMDPListener#
Subclassed by QLogListener
Public Functions
-
LogListener(std::string_view log_topic, std::function<void(message::CMDP1LogMessage&&)> callback)#
Construct log listener.
- Parameters:
log_topic – Logger topic to be used for this component
callback – Callback function pointer for received messages
-
void setGlobalLogLevel(log::Level level)#
Set log level for global log subscription.
This subscribes to
LOG/<level>
and all higher levels.- Parameters:
level – Lowest log level to subscribe to
-
log::Level getGlobalLogLevel() const#
Get log level for global log subscription.
- Returns:
Lowest subscribed global log level
-
void subscribeLogTopic(const std::string &log_topic, log::Level level)#
Subscribe to a specific log topic.
This subscribes to
LOG/<level>/<topic>
and all higher levels.Note
The log topic might not be empty (use
setGlobalLogLevel()
instead)- Parameters:
log_topic – Topic to subscribe to
level – Lowest log level to subscribe to
-
void unsubscribeLogTopic(const std::string &log_topic)#
Unsubscribe from a specific log topic.
- Parameters:
log_topic – Topic to unsubscribe from
-
std::map<std::string, log::Level> getLogTopicSubscriptions()#
Get map of subscribed log topics.
- Returns:
Map with log topics and their lowest subscribed levels
-
void subscribeExtaLogTopic(const std::string &host, const std::string &log_topic, log::Level level)#
Subscribe from an extra log topic for a specific host.
This subscribes to
LOG/<level>/<topic>
and all higher levels.Note
The log topic can be empty to set a lower generic subscription for a host
- Parameters:
host – Canonical name of the host
log_topic – Topic to subscribe to
level – Lowest log level to subscribe to
-
void unsubscribeExtraLogTopic(const std::string &host, const std::string &log_topic)#
Unsubscribe from an extra log topic for a specific host.
- Parameters:
host – Canonical name of the host
log_topic – Topic to unsubscribe from
-
LogListener(std::string_view log_topic, std::function<void(message::CMDP1LogMessage&&)> callback)#