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