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 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL 00026 00027 namespace OpenDDS { 00028 namespace DCPS { 00029 00030 /// Rake is an abbreviation for "read or take". This class manages the 00031 /// results from a read() or take() operation, which are the received_data 00032 /// and the info_seq sequences passed in by-reference from the user. 00033 class OpenDDS_Dcps_Export GroupRakeData { 00034 public: 00035 GroupRakeData(); 00036 00037 /// Returns false if the sample will definitely not be part of the 00038 /// resulting dataset, however if this returns true it still may be 00039 /// excluded (due to sorting and max_samples). 00040 bool insert_sample(ReceivedDataElement* sample, SubscriptionInstance_rch i, 00041 size_t index_in_instance); 00042 00043 void get_datareaders (DDS::DataReaderSeq & readers); 00044 00045 bool copy_to_user(); 00046 00047 void reset (); 00048 00049 RakeData get_data (); 00050 00051 private: 00052 00053 00054 GroupRakeData(const GroupRakeData&); // no copy construction 00055 GroupRakeData& operator=(const GroupRakeData&); // no assignment 00056 00057 class SortedSetCmp { 00058 public: 00059 bool operator()(const RakeData& lhs, const RakeData& rhs) const { 00060 if (!cmp_.in()) { 00061 // The following assumes that if no comparator is set 00062 // then BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS is used. 00063 return lhs.rde_->source_timestamp_ < rhs.rde_->source_timestamp_; 00064 } 00065 00066 return false; 00067 } 00068 SortedSetCmp(){} 00069 explicit SortedSetCmp(ComparatorBase::Ptr cmp) : cmp_(cmp){} 00070 00071 private: 00072 ComparatorBase::Ptr cmp_; 00073 }; 00074 00075 typedef OPENDDS_MULTISET_CMP(RakeData, SortedSetCmp) SortedSet; 00076 00077 // Contains data for QueryCondition/Ordered access 00078 SortedSet sorted_; 00079 00080 SortedSet::iterator current_sample_; 00081 }; 00082 00083 } // namespace DCPS 00084 } // namespace OpenDDS 00085 00086 OPENDDS_END_VERSIONED_NAMESPACE_DECL 00087 00088 #endif /* GROUPRAKEDATA_H */