diff --git a/autowiring/AutoPacket.h b/autowiring/AutoPacket.h index d39848509..483f2d2bc 100644 --- a/autowiring/AutoPacket.h +++ b/autowiring/AutoPacket.h @@ -146,6 +146,9 @@ class AutoPacket: /// True if the indicated type has been requested for use by some consumer bool HasSubscribers(const DecorationKey& key) const; + /// Zero if there are no publishers, otherwise the number of publishers + size_t HasPublishers(const DecorationKey& key) const; + /// A reference to the satisfaction counter for the specified type /// /// If the type is not a subscriber GetSatisfaction().GetType() == nullptr will be true @@ -529,9 +532,15 @@ class AutoPacket: std::shared_ptr Successor(void); /// True if the indicated type has been requested for use by some consumer - template + template bool HasSubscribers(void) const { - return HasSubscribers(DecorationKey(auto_id::key(), 0)); + return HasSubscribers(DecorationKey{auto_id::key(), 0}); + } + + /// Zero if there are no publishers, otherwise the number of publishers + template + size_t HasPublishers(void) const { + return HasPublishers(DecorationKey{auto_id::key(), 0}); } struct SignalStub { diff --git a/src/autowiring/AutoPacket.cpp b/src/autowiring/AutoPacket.cpp index 1c891e37f..02c1ca6bf 100644 --- a/src/autowiring/AutoPacket.cpp +++ b/src/autowiring/AutoPacket.cpp @@ -371,7 +371,20 @@ const DecorationDisposition* AutoPacket::GetDisposition(const DecorationKey& key bool AutoPacket::HasSubscribers(const DecorationKey& key) const { std::lock_guard lk(m_lock); - return m_decorations.count(key) != 0; + auto q = m_decorations.find(key); + return + q == m_decorations.end() ? + false : + q->second.m_subscribers.size() != 0; +} + +size_t AutoPacket::HasPublishers(const DecorationKey& key) const { + std::lock_guard lk(m_lock); + auto q = m_decorations.find(key); + return + q == m_decorations.end() ? + 0 : + q->second.m_publishers.size(); } const SatCounter& AutoPacket::GetSatisfaction(const std::type_info& subscriber) const {