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

          Line data    Source code
       1             : /*
       2             :  *
       3             :  *
       4             :  * Distributed under the OpenDDS License.
       5             :  * See: http://www.opendds.org/license.html
       6             :  */
       7             : 
       8             : #ifndef OPENDDS_DCPS_TOPIC_DESCRIPTION_IMPL_H
       9             : #define OPENDDS_DCPS_TOPIC_DESCRIPTION_IMPL_H
      10             : 
      11             : #include "Atomic.h"
      12             : #include "Definitions.h"
      13             : #include "LocalObject.h"
      14             : 
      15             : #include <dds/DdsDcpsTopicC.h>
      16             : #include <dds/DdsDcpsTypeSupportExtC.h>
      17             : 
      18             : #include <ace/SString.h>
      19             : 
      20             : #if !defined (ACE_LACKS_PRAGMA_ONCE)
      21             : #pragma once
      22             : #endif /* ACE_LACKS_PRAGMA_ONCE */
      23             : 
      24             : OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
      25             : 
      26             : namespace OpenDDS {
      27             : namespace DCPS {
      28             : 
      29             : class DomainParticipantImpl;
      30             : 
      31             : /**
      32             : * @class TopicDescriptionImpl
      33             : *
      34             : * @brief Implements the DDS::TopicDescription interface.
      35             : *
      36             : * See the DDS specification, OMG formal/2015-04-10, for a description of
      37             : * the interface this class is implementing.
      38             : *
      39             : */
      40             : class OpenDDS_Dcps_Export TopicDescriptionImpl
      41             :   : public virtual OpenDDS::DCPS::LocalObject<DDS::TopicDescription> {
      42             : public:
      43             :   TopicDescriptionImpl(const char*            topic_name,
      44             :                        const char*            type_name,
      45             :                        TypeSupport_ptr        type_support,
      46             :                        DomainParticipantImpl* participant);
      47             : 
      48             :   virtual ~TopicDescriptionImpl();
      49             : 
      50             :   virtual char * get_type_name();
      51             : 
      52             :   virtual char * get_name();
      53             : 
      54             :   virtual DDS::DomainParticipant_ptr get_participant();
      55             : 
      56             :   /** This method is not defined in the IDL and is defined for
      57             :   *  internal use.
      58             :   *  Return the type support of the topic.
      59             :   */
      60             :   OpenDDS::DCPS::TypeSupport_ptr get_type_support();
      61             : 
      62           0 :   bool has_entity_refs() const {
      63           0 :     return entity_refs_ > 0;
      64             :   }
      65             : 
      66           0 :   void add_entity_ref() {
      67           0 :     RcObject::_add_ref();
      68           0 :     ++entity_refs_;
      69           0 :   }
      70             : 
      71           0 :   void remove_entity_ref() {
      72           0 :     --entity_refs_;
      73           0 :     RcObject::_remove_ref();
      74           0 :   }
      75             : 
      76             : protected:
      77             :   /// The name of the topic.
      78             :   ACE_CString                    topic_name_;
      79             :   /// The datatype of the topic.
      80             :   ACE_CString                    type_name_;
      81             : 
      82             :   /// The participant that creates this topic.
      83             :   DomainParticipantImpl*         participant_;
      84             : 
      85             :   /// The type_support for this topic.
      86             :   OpenDDS::DCPS::TypeSupport_var type_support_;
      87             : 
      88             :   /// The number of entities using this topic
      89             :   Atomic<ACE_UINT32> entity_refs_;
      90             : };
      91             : 
      92             : template <typename Topic>
      93             : class TopicDescriptionPtr
      94             : {
      95             : public:
      96           0 :   TopicDescriptionPtr(Topic* topic=0)
      97           0 :     : topic_(topic)
      98             :   {
      99           0 :     if (topic_) {
     100           0 :       topic_->add_entity_ref();
     101             :     }
     102           0 :   }
     103             : 
     104           0 :   ~TopicDescriptionPtr()
     105             :   {
     106           0 :     if (topic_) {
     107           0 :       topic_->remove_entity_ref();
     108             :     }
     109           0 :   }
     110             : 
     111           0 :   TopicDescriptionPtr(const TopicDescriptionPtr& other)
     112           0 :     : topic_(other.topic_)
     113             :   {
     114           0 :     if (topic_) {
     115           0 :       topic_->add_entity_ref();
     116             :     }
     117           0 :   }
     118             : 
     119           0 :   TopicDescriptionPtr& operator=(Topic* other)
     120             :   {
     121           0 :     TopicDescriptionPtr tmp(other);
     122           0 :     std::swap(this->topic_, tmp.topic_);
     123           0 :     return *this;
     124           0 :   }
     125             : 
     126             :   TopicDescriptionPtr& operator=(const TopicDescriptionPtr& other)
     127             :   {
     128             :     TopicDescriptionPtr tmp(other);
     129             :     std::swap(this->topic_, tmp.topic_);
     130             :     return *this;
     131             :   }
     132             : 
     133           0 :   Topic* operator->() const
     134             :   {
     135           0 :     return topic_;
     136             :   }
     137             : 
     138           0 :   Topic* get() const
     139             :   {
     140           0 :     return topic_;
     141             :   }
     142             : 
     143           0 :   operator bool() const
     144             :   {
     145           0 :     return topic_;
     146             :   }
     147             : 
     148             : private:
     149             :   Topic* topic_;
     150             : };
     151             : 
     152             : } // namespace DCPS
     153             : } // namespace OpenDDS
     154             : 
     155             : OPENDDS_END_VERSIONED_NAMESPACE_DECL
     156             : 
     157             : #endif /* OPENDDS_DCPS_TOPIC_DESCRIPTION_IMPL_H  */

Generated by: LCOV version 1.16