GroupRakeData.h

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * Distributed under the OpenDDS License.
00005  * See: http://www.opendds.org/license.html
00006  */
00007 
00008 #ifndef GROUPRAKEDATA_H
00009 #define GROUPRAKEDATA_H
00010 
00011 #include /**/ "ace/pre.h"
00012 #include "dcps_export.h"
00013 
00014 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00015 # pragma once
00016 #endif /* ACE_LACKS_PRAGMA_ONCE */
00017 
00018 #include "dds/DdsDcpsSubscriptionC.h"
00019 #include "dds/DdsDcpsInfrastructureC.h"
00020 #include "RakeData.h"
00021 #include "Comparator_T.h"
00022 
00023 #include "PoolAllocator.h"
00024 
00025 namespace OpenDDS {
00026 namespace DCPS {
00027 
00028 /// Rake is an abbreviation for "read or take".  This class manages the
00029 /// results from a read() or take() operation, which are the received_data
00030 /// and the info_seq sequences passed in by-reference from the user.
00031 class OpenDDS_Dcps_Export GroupRakeData {
00032 public:
00033   GroupRakeData();
00034 
00035   /// Returns false if the sample will definitely not be part of the
00036   /// resulting dataset, however if this returns true it still may be
00037   /// excluded (due to sorting and max_samples).
00038   bool insert_sample(ReceivedDataElement* sample, SubscriptionInstance* i,
00039                      size_t index_in_instance);
00040 
00041   void get_datareaders (DDS::DataReaderSeq & readers);
00042 
00043   bool copy_to_user();
00044 
00045   void reset ();
00046 
00047   RakeData get_data ();
00048 
00049 private:
00050 
00051 
00052   GroupRakeData(const GroupRakeData&); // no copy construction
00053   GroupRakeData& operator=(const GroupRakeData&); // no assignment
00054 
00055   class SortedSetCmp {
00056   public:
00057     bool operator()(const RakeData& lhs, const RakeData& rhs) const {
00058       if (!cmp_.in()) {
00059         // The following assumes that if no comparator is set
00060         // then BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS is used.
00061         return lhs.rde_->source_timestamp_ < rhs.rde_->source_timestamp_;
00062       }
00063 
00064       return false;
00065     }
00066 
00067     explicit SortedSetCmp(ComparatorBase::Ptr cmp = 0) : cmp_(cmp){}
00068 
00069   private:
00070     ComparatorBase::Ptr cmp_;
00071   };
00072 
00073   typedef OPENDDS_MULTISET_CMP(RakeData, SortedSetCmp) SortedSet;
00074 
00075   // Contains data for QueryCondition/Ordered access
00076   SortedSet sorted_;
00077 
00078   SortedSet::iterator current_sample_;
00079 };
00080 
00081 } // namespace DCPS
00082 } // namespace OpenDDS
00083 
00084 
00085 #endif /* GROUPRAKEDATA_H  */

Generated on Fri Feb 12 20:05:23 2016 for OpenDDS by  doxygen 1.4.7