LCOV - code coverage report
Current view: top level - DCPS - RakeResults_T.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 10 0.0 %
Date: 2023-04-30 01:32:43 Functions: 0 216 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_RAKERESULTS_T_H
       7             : #define OPENDDS_DCPS_RAKERESULTS_T_H
       8             : 
       9             : #include <ace/config-macros.h>
      10             : #ifndef ACE_LACKS_PRAGMA_ONCE
      11             : #  pragma once
      12             : #endif
      13             : 
      14             : #include "Comparator_T.h"
      15             : #include "PoolAllocator.h"
      16             : #include "RakeData.h"
      17             : #include "TypeSupportImpl.h"
      18             : 
      19             : #include <dds/DdsDcpsSubscriptionC.h>
      20             : 
      21             : OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
      22             : 
      23             : namespace OpenDDS {
      24             : namespace DCPS {
      25             : 
      26             : enum Operation_t { DDS_OPERATION_READ, DDS_OPERATION_TAKE };
      27             : 
      28             : /// Rake is an abbreviation for "read or take".  This class manages the
      29             : /// results from a read() or take() operation, which are the received_data
      30             : /// and the info_seq sequences passed in by-reference from the user.
      31             : template <class MessageType>
      32             : class RakeResults {
      33             : 
      34             :   typedef typename DDSTraits<MessageType>::MessageSequenceType SampleSeq;
      35             :   typedef typename DDSTraits<MessageType>::MessageSequenceAdapterType MessageSequenceAdapterType;
      36             : 
      37             : public:
      38             :   RakeResults(DataReaderImpl* reader,
      39             :               SampleSeq& received_data,
      40             :               DDS::SampleInfoSeq& info_seq,
      41             :               CORBA::Long max_samples,
      42             :               DDS::PresentationQosPolicy presentation,
      43             : #ifndef OPENDDS_NO_QUERY_CONDITION
      44             :               DDS::QueryCondition_ptr cond,
      45             : #endif
      46             :               Operation_t oper);
      47             : 
      48             :   /// Returns false if the sample will definitely not be part of the
      49             :   /// resulting dataset, however if this returns true it still may be
      50             :   /// excluded (due to sorting and max_samples).
      51             :   bool insert_sample(ReceivedDataElement* sample,
      52             :                      ReceivedDataElementList* rdel,
      53             :                      SubscriptionInstance_rch instance,
      54             :                      size_t index_in_instance);
      55             : 
      56             :   bool copy_to_user();
      57             : 
      58             : private:
      59             :   template <class FwdIter>
      60             :   bool copy_into(FwdIter begin, FwdIter end,
      61             :                  MessageSequenceAdapterType& received_data_p);
      62             : 
      63             :   RakeResults(const RakeResults&); // no copy construction
      64             :   RakeResults& operator=(const RakeResults&); // no assignment
      65             : 
      66             :   DataReaderImpl* reader_;
      67             :   SampleSeq& received_data_;
      68             :   DDS::SampleInfoSeq& info_seq_;
      69             :   CORBA::ULong max_samples_;
      70             : #ifndef OPENDDS_NO_QUERY_CONDITION
      71             :   DDS::QueryCondition_ptr cond_;
      72             : #endif
      73             :   Operation_t oper_;
      74             : 
      75             :   class SortedSetCmp {
      76             :   public:
      77           0 :     bool operator()(const RakeData& lhs, const RakeData& rhs) const {
      78           0 :       if (!cmp_.in()) {
      79             :         // The following assumes that if no comparator is set
      80             :         // then PRESENTATION ordered access applies (TOPIC).
      81           0 :         return lhs.rde_->source_timestamp_ < rhs.rde_->source_timestamp_;
      82             :       }
      83             : 
      84           0 :       return cmp_->compare(lhs.rde_->registered_data_,
      85           0 :                            rhs.rde_->registered_data_);
      86             :     }
      87             : 
      88           0 :     SortedSetCmp(){}
      89           0 :     explicit SortedSetCmp(ComparatorBase::Ptr cmp) : cmp_(cmp) {}
      90             : 
      91             :   private:
      92             :     ComparatorBase::Ptr cmp_;
      93             :   };
      94             : 
      95             :   bool do_sort_, do_filter_;
      96             :   typedef OPENDDS_MULTISET_CMP(RakeData, SortedSetCmp) SortedSet;
      97             : 
      98             :   // Contains data for QueryCondition/Ordered access
      99             :   SortedSet sorted_;
     100             : 
     101             :   // Contains data for all other use cases
     102             :   OPENDDS_VECTOR(RakeData) unsorted_;
     103             : 
     104             :   // data structures used by copy_into()
     105             :   typedef OPENDDS_VECTOR(CORBA::ULong) IndexList;
     106             :   struct InstanceData {
     107             :     bool most_recent_generation_;
     108             :     size_t MRSIC_index_;
     109             :     IndexList sampleinfo_positions_;
     110             :     CORBA::Long MRSIC_disposed_gc_, MRSIC_nowriters_gc_,
     111             :     MRS_disposed_gc_, MRS_nowriters_gc_;
     112           0 :     InstanceData() : most_recent_generation_(false), MRSIC_index_(0),
     113           0 :       MRSIC_disposed_gc_(0), MRSIC_nowriters_gc_(0), MRS_disposed_gc_(0),
     114           0 :       MRS_nowriters_gc_(0) {}
     115             :   };
     116             : };
     117             : 
     118             : } // namespace DCPS
     119             : } // namespace OpenDDS
     120             : 
     121             : OPENDDS_END_VERSIONED_NAMESPACE_DECL
     122             : 
     123             : #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
     124             : #include "RakeResults_T.cpp"
     125             : #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
     126             : 
     127             : #endif /* RAKERESULTS_H  */

Generated by: LCOV version 1.16