OpenDDS  Snapshot(2023/04/28-20:55)
GroupRakeData.h
Go to the documentation of this file.
1 /*
2  * Distributed under the OpenDDS License.
3  * See: http://www.opendds.org/license.html
4  */
5 
6 #ifndef OPENDDS_DCPS_GROUPRAKEDATA_H
7 #define OPENDDS_DCPS_GROUPRAKEDATA_H
8 
9 #include <ace/config-macros.h>
10 #ifndef ACE_LACKS_PRAGMA_ONCE
11 # pragma once
12 #endif
13 
14 #include "RakeData.h"
15 #include "Comparator_T.h"
16 #include "PoolAllocator.h"
17 #include "dcps_export.h"
18 
19 #include <dds/DdsDcpsSubscriptionC.h>
20 #include <dds/DdsDcpsInfrastructureC.h>
21 
23 
24 namespace OpenDDS {
25 namespace DCPS {
26 
27 /// Rake is an abbreviation for "read or take". This class manages the
28 /// results from a read() or take() operation, which are the received_data
29 /// and the info_seq sequences passed in by-reference from the user.
31 public:
32  GroupRakeData();
33 
34  /// Returns false if the sample will definitely not be part of the
35  /// resulting dataset, however if this returns true it still may be
36  /// excluded (due to sorting and max_samples).
37  bool insert_sample(ReceivedDataElement* sample,
40  size_t index_in_instance);
41 
42  void get_datareaders (DDS::DataReaderSeq & readers);
43 
44  bool copy_to_user();
45 
46  void reset ();
47 
48  RakeData get_data ();
49 
50 private:
51 
52 
53  GroupRakeData(const GroupRakeData&); // no copy construction
54  GroupRakeData& operator=(const GroupRakeData&); // no assignment
55 
56  class SortedSetCmp {
57  public:
58  bool operator()(const RakeData& lhs, const RakeData& rhs) const {
59  if (!cmp_.in()) {
60  // The following assumes that if no comparator is set
61  // then BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS is used.
62  return lhs.rde_->source_timestamp_ < rhs.rde_->source_timestamp_;
63  }
64 
65  return false;
66  }
68  explicit SortedSetCmp(ComparatorBase::Ptr cmp) : cmp_(cmp){}
69 
70  private:
72  };
73 
74  typedef OPENDDS_MULTISET_CMP(RakeData, SortedSetCmp) SortedSet;
75 
76  // Contains data for QueryCondition/Ordered access
77  SortedSet sorted_;
78 
79  SortedSet::iterator current_sample_;
80 };
81 
82 } // namespace DCPS
83 } // namespace OpenDDS
84 
86 
87 #endif /* GROUPRAKEDATA_H */
#define OPENDDS_MULTISET_CMP(K, C)
DDS::Time_t source_timestamp_
Source time stamp for this data sample.
#define OpenDDS_Dcps_Export
Definition: dcps_export.h:24
SortedSet::iterator current_sample_
Definition: GroupRakeData.h:79
bool operator()(const RakeData &lhs, const RakeData &rhs) const
Definition: GroupRakeData.h:58
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
ReceivedDataElement * rde_
Definition: RakeData.h:25
sequence< DataReader > DataReaderSeq
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28