Listener#
constellation::listener
Namespace#
-
class CMDPListener : public constellation::pools::SubscriberPool<message::CMDP1Message, protocol::CHIRP::ServiceIdentifier::MONITORING>#
Subclassed by 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.
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
CMDPPool::socket_connected()
to ensure that sockets are subscribed to the correct topics.
-
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)#