00001
00002
00003
00004
00005
00006
00007
00008 #ifndef RAKERESULTS_H
00009 #define RAKERESULTS_H
00010
00011 #include "ace/pre.h"
00012
00013 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00014 # pragma once
00015 #endif
00016
00017 #include "dds/DdsDcpsSubscriptionC.h"
00018 #include "RakeData.h"
00019 #include "Comparator_T.h"
00020 #include "PoolAllocator.h"
00021
00022 namespace OpenDDS {
00023 namespace DCPS {
00024
00025 enum Operation_t { DDS_OPERATION_READ, DDS_OPERATION_TAKE };
00026
00027
00028
00029
00030 template <class SampleSeq>
00031 class RakeResults {
00032 public:
00033 RakeResults(DataReaderImpl* reader,
00034 SampleSeq& received_data,
00035 DDS::SampleInfoSeq& info_seq,
00036 CORBA::Long max_samples,
00037 DDS::PresentationQosPolicy presentation,
00038 #ifndef OPENDDS_NO_QUERY_CONDITION
00039 DDS::QueryCondition_ptr cond,
00040 #endif
00041 Operation_t oper);
00042
00043
00044
00045
00046 bool insert_sample(ReceivedDataElement* sample, SubscriptionInstance* i,
00047 size_t index_in_instance);
00048
00049 bool copy_to_user();
00050
00051 private:
00052 template <class FwdIter>
00053 bool copy_into(FwdIter begin, FwdIter end,
00054 typename SampleSeq::PrivateMemberAccess& received_data_p);
00055
00056 RakeResults(const RakeResults&);
00057 RakeResults& operator=(const RakeResults&);
00058
00059 DataReaderImpl* reader_;
00060 SampleSeq& received_data_;
00061 DDS::SampleInfoSeq& info_seq_;
00062 CORBA::ULong max_samples_;
00063 #ifndef OPENDDS_NO_QUERY_CONDITION
00064 DDS::QueryCondition_ptr cond_;
00065 #endif
00066 Operation_t oper_;
00067
00068 class SortedSetCmp {
00069 public:
00070 bool operator()(const RakeData& lhs, const RakeData& rhs) const {
00071 if (!cmp_.in()) {
00072
00073
00074 return lhs.rde_->source_timestamp_ < rhs.rde_->source_timestamp_;
00075 }
00076
00077 return cmp_->compare(lhs.rde_->registered_data_,
00078 rhs.rde_->registered_data_);
00079 }
00080
00081 explicit SortedSetCmp(ComparatorBase::Ptr cmp = 0) : cmp_(cmp) {}
00082
00083 private:
00084 ComparatorBase::Ptr cmp_;
00085 };
00086
00087 bool do_sort_, do_filter_;
00088 typedef OPENDDS_MULTISET_CMP(RakeData, SortedSetCmp) SortedSet;
00089
00090
00091 SortedSet sorted_;
00092
00093
00094 OPENDDS_VECTOR(RakeData) unsorted_;
00095
00096
00097 typedef OPENDDS_VECTOR(CORBA::ULong) IndexList;
00098 struct InstanceData {
00099 bool most_recent_generation_;
00100 size_t MRSIC_index_;
00101 IndexList sampleinfo_positions_;
00102 CORBA::Long MRSIC_disposed_gc_, MRSIC_nowriters_gc_,
00103 MRS_disposed_gc_, MRS_nowriters_gc_;
00104 InstanceData() : most_recent_generation_(false), MRSIC_index_(0),
00105 MRSIC_disposed_gc_(0), MRSIC_nowriters_gc_(0), MRS_disposed_gc_(0),
00106 MRS_nowriters_gc_(0) {}
00107 };
00108 };
00109
00110 }
00111 }
00112
00113 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
00114 #include "dds/DCPS/RakeResults_T.cpp"
00115 #endif
00116
00117 #include "ace/post.h"
00118
00119 #endif