LCOV - code coverage report
Current view: top level - DCPS - TopicDetails.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 66 0.0 %
Date: 2023-04-30 01:32:43 Functions: 0 21 0.0 %

          Line data    Source code
       1             : /*
       2             :  * Distributed under the OpenDDS License.
       3             :  * See: http://www.opendds.org/license.html
       4             :  */
       5             : 
       6             : #ifndef OPENDDS_DCPS_TOPICDETAILS_H
       7             : #define OPENDDS_DCPS_TOPICDETAILS_H
       8             : 
       9             : #include "TopicCallbacks.h"
      10             : #include "GuidUtils.h"
      11             : #include "debug.h"
      12             : #include "Definitions.h"
      13             : #include "XTypes/TypeObject.h"
      14             : 
      15             : #if !defined (ACE_LACKS_PRAGMA_ONCE)
      16             : #pragma once
      17             : #endif /* ACE_LACKS_PRAGMA_ONCE */
      18             : 
      19             : OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
      20             : 
      21             : namespace OpenDDS {
      22             :   namespace DCPS {
      23             : 
      24             :     struct TopicDetails {
      25             : 
      26           0 :       TopicDetails()
      27           0 :         : topic_id_()
      28           0 :         , has_dcps_key_(false)
      29           0 :         , topic_callbacks_(0)
      30           0 :         , inconsistent_topic_count_(0)
      31           0 :         , assertion_count_(0)
      32           0 :       {}
      33             : 
      34           0 :       void init(const OPENDDS_STRING& name,
      35             :                 const DCPS::GUID_t& topic_id) {
      36           0 :         name_ = name;
      37           0 :         topic_id_ = topic_id;
      38           0 :       }
      39             : 
      40           0 :       void set_local(const OPENDDS_STRING& data_type_name,
      41             :                      const DDS::TopicQos& qos,
      42             :                      bool has_dcps_key,
      43             :                      TopicCallbacks* topic_callbacks)
      44             :       {
      45           0 :         OPENDDS_ASSERT(topic_callbacks != 0);
      46             : 
      47           0 :         local_data_type_name_ = data_type_name;
      48           0 :         local_qos_ = qos;
      49           0 :         has_dcps_key_ = has_dcps_key;
      50           0 :         topic_callbacks_ = topic_callbacks;
      51           0 :         ++assertion_count_;
      52           0 :       }
      53             : 
      54           0 :       void unset_local()
      55             :       {
      56           0 :         if (--assertion_count_ == 0) {
      57           0 :           OPENDDS_ASSERT(local_publications_.empty());
      58           0 :           OPENDDS_ASSERT(local_subscriptions_.empty());
      59           0 :           topic_callbacks_ = 0;
      60             :         }
      61           0 :       }
      62             : 
      63             :       void update(const DDS::TopicQos& qos)
      64             :       {
      65             :         local_qos_ = qos;
      66             :       }
      67             : 
      68           0 :       void add_local_publication(const DCPS::GUID_t& guid)
      69             :       {
      70           0 :         local_publications_.insert(guid);
      71           0 :       }
      72             : 
      73           0 :       void remove_local_publication(const DCPS::GUID_t& guid)
      74             :       {
      75           0 :         local_publications_.erase(guid);
      76           0 :       }
      77             : 
      78           0 :       const RepoIdSet& local_publications() const
      79             :       {
      80           0 :         return local_publications_;
      81             :       }
      82             : 
      83           0 :       void add_local_subscription(const DCPS::GUID_t& guid)
      84             :       {
      85           0 :         local_subscriptions_.insert(guid);
      86           0 :       }
      87             : 
      88           0 :       void remove_local_subscription(const DCPS::GUID_t& guid)
      89             :       {
      90           0 :         local_subscriptions_.erase(guid);
      91           0 :       }
      92             : 
      93           0 :       const RepoIdSet& local_subscriptions() const
      94             :       {
      95           0 :         return local_subscriptions_;
      96             :       }
      97             : 
      98             :       void add_discovered_publication(const DCPS::GUID_t& guid)
      99             :       {
     100             :         discovered_publications_.insert(guid);
     101             :       }
     102             : 
     103           0 :       void remove_discovered_publication(const DCPS::GUID_t& guid)
     104             :       {
     105           0 :         discovered_publications_.erase(guid);
     106           0 :       }
     107             : 
     108           0 :       const RepoIdSet& discovered_publications() const
     109             :       {
     110           0 :         return discovered_publications_;
     111             :       }
     112             : 
     113             :       void add_discovered_subscription(const DCPS::GUID_t& guid)
     114             :       {
     115             :         discovered_subscriptions_.insert(guid);
     116             :       }
     117             : 
     118           0 :       void remove_discovered_subscription(const DCPS::GUID_t& guid)
     119             :       {
     120           0 :         discovered_subscriptions_.erase(guid);
     121           0 :       }
     122             : 
     123           0 :       const RepoIdSet& discovered_subscriptions() const
     124             :       {
     125           0 :         return discovered_subscriptions_;
     126             :       }
     127             : 
     128           0 :       void increment_inconsistent()
     129             :       {
     130           0 :         ++inconsistent_topic_count_;
     131           0 :         topic_callbacks_->inconsistent_topic(inconsistent_topic_count_);
     132           0 :       }
     133             : 
     134           0 :       const OPENDDS_STRING local_data_type_name() const { return local_data_type_name_; }
     135           0 :       const DDS::TopicQos local_qos() const { return local_qos_; }
     136           0 :       const DCPS::GUID_t& topic_id() const { return topic_id_; }
     137           0 :       bool has_dcps_key() const { return has_dcps_key_; }
     138           0 :       bool local_is_set() const { return topic_callbacks_; }
     139             : 
     140           0 :       bool is_dead() const
     141             :       {
     142           0 :         return topic_callbacks_ == 0 &&
     143           0 :           local_publications_.empty() &&
     144           0 :           local_subscriptions_.empty() &&
     145           0 :           discovered_publications_.empty() &&
     146           0 :           discovered_subscriptions_.empty();
     147             :       }
     148             : 
     149             :     private:
     150             :       OPENDDS_STRING name_;
     151             :       OPENDDS_STRING local_data_type_name_;
     152             :       DDS::TopicQos local_qos_;
     153             :       DCPS::GUID_t topic_id_;
     154             :       bool has_dcps_key_;
     155             :       TopicCallbacks* topic_callbacks_;
     156             : 
     157             :       RepoIdSet local_publications_;
     158             :       RepoIdSet local_subscriptions_;
     159             :       RepoIdSet discovered_publications_;
     160             :       RepoIdSet discovered_subscriptions_;
     161             :       int inconsistent_topic_count_;
     162             :       int assertion_count_;
     163             :     };
     164             : 
     165             :     typedef OPENDDS_MAP(String, TopicDetails) TopicDetailsMap;
     166             :   } // namespace DCPS
     167             : } // namespace OpenDDS
     168             : 
     169             : OPENDDS_END_VERSIONED_NAMESPACE_DECL
     170             : 
     171             : #endif /* OPENDDS_DCPS_TOPICDETAILS_H  */

Generated by: LCOV version 1.16