LCOV - code coverage report
Current view: top level - DCPS - DataWriterImpl_T.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 40 0.0 %
Date: 2023-04-30 01:32:43 Functions: 0 702 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_DATAWRITERIMPL_T_H
       7             : #define OPENDDS_DCPS_DATAWRITERIMPL_T_H
       8             : 
       9             : #include "Sample.h"
      10             : #include "PublicationInstance.h"
      11             : #include "DataWriterImpl.h"
      12             : #include "Util.h"
      13             : #include "TypeSupportImpl.h"
      14             : #include "dcps_export.h"
      15             : #include "SafetyProfileStreams.h"
      16             : #include "DCPS_Utils.h"
      17             : 
      18             : #ifdef OPENDDS_SECURITY
      19             : #  include <dds/DdsSecurityCoreC.h>
      20             : #endif
      21             : 
      22             : OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
      23             : 
      24             : namespace OpenDDS {
      25             : namespace DCPS {
      26             : 
      27             : /**
      28             :  * Servant for DataWriter interface of the MessageType data type.
      29             :  *
      30             :  * See the DDS specification, OMG formal/2015-04-10, for a description of
      31             :  * this interface.
      32             :  */
      33             : template <typename MessageType>
      34             : class
      35             : #if ( __GNUC__ == 4 && __GNUC_MINOR__ == 1)
      36             :   OpenDDS_Dcps_Export
      37             : #endif
      38             : DataWriterImpl_T
      39             : : public virtual LocalObject<typename DDSTraits<MessageType>::DataWriterType>
      40             : , public virtual DataWriterImpl
      41             : {
      42             : public:
      43           0 :   DataWriterImpl_T()
      44           0 :   {
      45           0 :   }
      46             : 
      47           0 :   virtual ~DataWriterImpl_T()
      48             :   {
      49           0 :   }
      50             : 
      51           0 :   DDS::InstanceHandle_t register_instance(const MessageType& instance)
      52             :   {
      53           0 :     return register_instance_w_timestamp(instance, SystemTimePoint::now().to_dds_time());
      54             :   }
      55             : 
      56           0 :   DDS::InstanceHandle_t register_instance_w_timestamp(
      57             :     const MessageType& instance, const DDS::Time_t& timestamp)
      58             :   {
      59           0 :     const SampleType sample(instance, Sample::KeyOnly);
      60           0 :     return DataWriterImpl::register_instance_w_timestamp(sample, timestamp);
      61           0 :   }
      62             : 
      63           0 :   DDS::ReturnCode_t unregister_instance(const MessageType& instance, DDS::InstanceHandle_t handle)
      64             :   {
      65           0 :     return unregister_instance_w_timestamp(instance, handle, SystemTimePoint::now().to_dds_time());
      66             :   }
      67             : 
      68           0 :   DDS::ReturnCode_t unregister_instance_w_timestamp(
      69             :     const MessageType& instance_data,
      70             :     DDS::InstanceHandle_t instance_handle,
      71             :     const DDS::Time_t& timestamp)
      72             :   {
      73           0 :     const SampleType sample(instance_data, Sample::KeyOnly);
      74           0 :     return DataWriterImpl::unregister_instance_w_timestamp(sample, instance_handle, timestamp);
      75           0 :   }
      76             : 
      77             :   //WARNING: If the handle is non-nil and the instance is not registered
      78             :   //         then this operation may cause an access violation.
      79             :   //         This lack of safety helps performance.
      80           0 :   DDS::ReturnCode_t write(const MessageType& instance_data, DDS::InstanceHandle_t handle)
      81             :   {
      82           0 :     return write_w_timestamp(instance_data, handle, SystemTimePoint::now().to_dds_time());
      83             :   }
      84             : 
      85             :   //WARNING: If the handle is non-nil and the instance is not registered
      86             :   //         then this operation may cause an access violation.
      87             :   //         This lack of safety helps performance.
      88           0 :   DDS::ReturnCode_t write_w_timestamp(
      89             :     const MessageType& instance_data,
      90             :     DDS::InstanceHandle_t handle,
      91             :     const DDS::Time_t& source_timestamp)
      92             :   {
      93           0 :     const SampleType sample(instance_data);
      94           0 :     return DataWriterImpl::write_w_timestamp(sample, handle, source_timestamp);
      95           0 :   }
      96             : 
      97           0 :   DDS::ReturnCode_t dispose(const MessageType& instance_data, DDS::InstanceHandle_t instance_handle)
      98             :   {
      99           0 :     return dispose_w_timestamp(instance_data, instance_handle, SystemTimePoint::now().to_dds_time());
     100             :   }
     101             : 
     102           0 :   DDS::ReturnCode_t dispose_w_timestamp(
     103             :     const MessageType& instance_data,
     104             :     DDS::InstanceHandle_t instance_handle,
     105             :     const DDS::Time_t& source_timestamp)
     106             :   {
     107           0 :     const SampleType sample(instance_data, Sample::KeyOnly);
     108           0 :     return DataWriterImpl::dispose_w_timestamp(sample, instance_handle, source_timestamp);
     109           0 :   }
     110             : 
     111           0 :   DDS::ReturnCode_t get_key_value(MessageType& key_holder, DDS::InstanceHandle_t handle)
     112             :   {
     113           0 :     Sample_rch sample;
     114           0 :     const DDS::ReturnCode_t rc = DataWriterImpl::get_key_value(sample, handle);
     115           0 :     if (sample) {
     116           0 :       key_holder = dynamic_rchandle_cast<SampleType>(sample)->data();
     117             :     }
     118           0 :     return rc;
     119           0 :   }
     120             : 
     121           0 :   DDS::InstanceHandle_t lookup_instance(const MessageType& instance_data)
     122             :   {
     123           0 :     const SampleType sample(instance_data, Sample::KeyOnly);
     124           0 :     return DataWriterImpl::lookup_instance(sample);
     125           0 :   }
     126             : 
     127             : private:
     128             :   typedef Sample_T<MessageType> SampleType;
     129             : 
     130             :   // A class, normally provided by an unit test, that needs access to
     131             :   // private methods/members.
     132             :   friend class ::DDS_TEST;
     133             : };
     134             : 
     135             : } // namespace DCPS
     136             : } // namepsace OpenDDS
     137             : 
     138             : OPENDDS_END_VERSIONED_NAMESPACE_DECL
     139             : 
     140             : #endif /* OPENDDS_DDS_DCPS_DATAWRITERIMPL_T_H */

Generated by: LCOV version 1.16