LCOV - code coverage report
Current view: top level - DCPS/RTPS - AssociationRecord.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 38 38 100.0 %
Date: 2023-04-30 01:32:43 Functions: 15 15 100.0 %

          Line data    Source code
       1             : /*
       2             :  * Distributed under the OpenDDS License.
       3             :  * See: http://www.opendds.org/license.html
       4             :  */
       5             : #ifndef OPENDDS_DCPS_RTPS_ASSOCIATION_RECORD_H
       6             : #define OPENDDS_DCPS_RTPS_ASSOCIATION_RECORD_H
       7             : 
       8             : #include <dds/Versioned_Namespace.h>
       9             : #include <dds/DCPS/transport/framework/TransportClient.h>
      10             : 
      11             : #ifndef ACE_LACKS_PRAGMA_ONCE
      12             : #  pragma once
      13             : #endif
      14             : 
      15             : OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
      16             : 
      17             : namespace OpenDDS {
      18             : namespace RTPS {
      19             : 
      20             : const int AC_EMPTY = 0;
      21             : const int AC_REMOTE_RELIABLE = 1 << 0;
      22             : const int AC_REMOTE_DURABLE = 1 << 1;
      23             : const int AC_GENERATE_REMOTE_MATCHED_CRYPTO_HANDLE = 1 << 2;
      24             : const int AC_SEND_LOCAL_TOKEN = 1 << 3;
      25             : const int AC_LOCAL_TOKENS_SENT = 1 << 4;
      26             : 
      27             : class BuiltinAssociationRecord {
      28             : public:
      29           3 :   BuiltinAssociationRecord(DCPS::TransportClient_rch transport_client,
      30             :                            const DCPS::GUID_t& remote_id,
      31             :                            int flags)
      32           3 :     : transport_client_(transport_client)
      33           3 :     , remote_id_(remote_id)
      34           3 :     , flags_(flags)
      35           3 :   {}
      36             : 
      37           1 :   const DCPS::GUID_t local_id() const
      38             :   {
      39           1 :     return transport_client_->get_guid();
      40             :   }
      41             : 
      42           1 :   const DCPS::GUID_t& remote_id() const
      43             :   {
      44             :     // FUTURE: Remove this and just store the entity id.
      45           1 :     return remote_id_;
      46             :   }
      47             : 
      48           2 :   bool remote_reliable() const
      49             :   {
      50           2 :     return flags_ & AC_REMOTE_RELIABLE;
      51             :   }
      52             : 
      53           2 :   bool remote_durable() const
      54             :   {
      55           2 :     return flags_ & AC_REMOTE_DURABLE;
      56             :   }
      57             : 
      58           2 :   bool generate_remote_matched_crypto_handle() const
      59             :   {
      60           2 :     return flags_ & AC_GENERATE_REMOTE_MATCHED_CRYPTO_HANDLE;
      61             :   }
      62             : 
      63           2 :   bool send_local_token() const
      64             :   {
      65           2 :     return flags_ & AC_SEND_LOCAL_TOKEN;
      66             :   }
      67             : 
      68           2 :   void local_tokens_sent(bool flag)
      69             :   {
      70           2 :     if (flag) {
      71           1 :       flags_ |= AC_LOCAL_TOKENS_SENT;
      72             :     } else {
      73           1 :       flags_ &= ~AC_LOCAL_TOKENS_SENT;
      74             :     }
      75           2 :   }
      76             : 
      77           3 :   bool local_tokens_sent() const
      78             :   {
      79           3 :     return flags_ & AC_LOCAL_TOKENS_SENT;
      80             :   }
      81             : 
      82             :   const DCPS::TransportClient_rch transport_client_;
      83             : 
      84             : private:
      85             :   const DCPS::GUID_t remote_id_;
      86             :   int flags_;
      87             : };
      88             : 
      89             : class WriterAssociationRecord : public DCPS::RcObject {
      90             : public:
      91           1 :   WriterAssociationRecord(DCPS::DataWriterCallbacks_wrch callbacks,
      92             :                           const DCPS::GUID_t& writer_id,
      93             :                           const DCPS::ReaderAssociation& reader_association)
      94           2 :     : callbacks_(callbacks)
      95           1 :     , writer_id_(writer_id)
      96           1 :     , reader_association_(reader_association)
      97           1 :   {}
      98             : 
      99           1 :   const DCPS::GUID_t& writer_id() const { return writer_id_; }
     100           1 :   const DCPS::GUID_t& reader_id() const { return reader_association_.readerId; }
     101             : 
     102             :   const DCPS::DataWriterCallbacks_wrch callbacks_;
     103             :   const DCPS::GUID_t writer_id_;
     104             :   const DCPS::ReaderAssociation reader_association_;
     105             : };
     106             : typedef DCPS::RcHandle<WriterAssociationRecord> WriterAssociationRecord_rch;
     107             : 
     108             : class ReaderAssociationRecord : public DCPS::RcObject {
     109             : public:
     110           1 :   ReaderAssociationRecord(DCPS::DataReaderCallbacks_wrch callbacks,
     111             :                           const DCPS::GUID_t& reader_id,
     112             :                           const DCPS::WriterAssociation& writer_association)
     113           2 :     : callbacks_(callbacks)
     114           1 :     , reader_id_(reader_id)
     115           1 :     , writer_association_(writer_association)
     116           1 :   {}
     117             : 
     118           1 :   const DCPS::GUID_t& reader_id() const { return reader_id_; }
     119           1 :   const DCPS::GUID_t& writer_id() const { return writer_association_.writerId; }
     120             : 
     121             :   const DCPS::DataReaderCallbacks_wrch callbacks_;
     122             :   const DCPS::GUID_t reader_id_;
     123             :   const DCPS::WriterAssociation writer_association_;
     124             : };
     125             : typedef DCPS::RcHandle<ReaderAssociationRecord> ReaderAssociationRecord_rch;
     126             : 
     127             : }
     128             : }
     129             : 
     130             : OPENDDS_END_VERSIONED_NAMESPACE_DECL
     131             : 
     132             : #endif // OPENDDS_DCPS_RTPS_ASSOCIATION_RECORD_H

Generated by: LCOV version 1.16