RTI Recording Service Version 7.3.0
SelectorState.hpp
1/*
2 * (c) Copyright, Real-Time Innovations, 2018-.
3 * All rights reserved.
4 * No duplications, whole or partial, manual or electronic, may be made
5 * without express written permission. Any such copies, or
6 * revisions thereof, must display this notice unaltered.
7 * This code contains trade secrets of Real-Time Innovations, Inc.
8 */
9
10#ifndef HPP_RTI_RECORDING_STORAGE_SAMPLESELECTOR_HPP_
11#define HPP_RTI_RECORDING_STORAGE_SAMPLESELECTOR_HPP_
12
13#include "dds/dds.hpp"
14#include "rti/core/NativeValueType.hpp"
15#include "rti/core/constants.hpp"
16#include "rti/apputils/util/Utils.hpp"
17
18#include "recordingservice/recordingservice_storagereader.h"
19
20namespace rti { namespace recording { namespace storage {
21
22class SelectorState;
23
24
29public:
30 typedef RTI_RecordingServiceSelectorState native_type;
31
32 static void initialize(native_type& native_value)
33 {
34 RTI_RecordingServiceSelectorState native_state =
35 RTI_RecordingServiceSelectorState_INITIALIZER;
36 memcpy(&native_value, &native_state, sizeof(native_state));
37 }
38
39 static void finalize(native_type&)
40 {
41 }
42
43 static void copy(native_type& destination, const native_type& source)
44 {
45 destination.sample_state = source.sample_state;
46 destination.time_range_start = source.time_range_start;
47 destination.time_range_end = source.time_range_end;
48 destination.max_samples = source.max_samples;
49 destination.instance_history = source.instance_history;
50 }
51
52 static bool equals(const native_type& first, const native_type& second)
53 {
54 if (first.sample_state != second.sample_state) {
55 return false;
56 }
57 if (first.max_samples != second.max_samples) {
58 return false;
59 }
60 if (!DDS_Time_t_equals(
61 first.time_range_start,
62 second.time_range_start)) {
63 return false;
64 }
65 if (!DDS_Time_t_equals(
66 first.time_range_end,
67 second.time_range_end)) {
68 return false;
69 }
70 return first.instance_history.depth == second.instance_history.depth;
71 }
72};
73
74} }
75
76/*
77 * Type native_type_traits needs to be defined in the rti::core namespace.
78 */
79namespace core {
80
81template <>
82struct native_type_traits<rti::recording::storage::SelectorState> {
84 typedef RTI_RecordingServiceSelectorState native_type;
85};
86
87}
88
89namespace recording { namespace storage {
90
99class SelectorState : public rti::core::NativeValueType<SelectorState> {
100public:
101 RTI_NATIVE_VALUE_TYPE_DEFINE_DEFAULT_MOVE_OPERATIONS(SelectorState)
102
103 typedef rti::core::NativeValueType<SelectorState> Base;
104
106 {
107 }
108
109 SelectorState(const RTI_RecordingServiceSelectorState &native) :
110 Base(native)
111 {
112 }
113
129 inline dds::sub::status::SampleState sample_state() const
130 {
131 return dds::sub::status::SampleState(native().sample_state);
132 }
133
137 SelectorState& sample_state(const dds::sub::status::SampleState& state)
138 {
139 native().sample_state =
140 static_cast<RTI_RecordingServiceSampleStateMask>(
141 state.to_ulong());
142 return *this;
143 }
144
152 inline dds::core::Time time_range_start() const
153 {
154 return dds::core::Time(
155 native().time_range_start.sec,
156 native().time_range_start.nanosec);
157 }
158
163 inline int64_t timestamp_range_start() const
164 {
165 return rti::apputils::util::convert_uint64_into_int64(
166 rti::apputils::util::to_nanosecs(time_range_start()));
167 }
168
173 {
174 native().time_range_start.sec = time_range_start.sec();
175 native().time_range_start.nanosec =
176 (DDS_UnsignedLong) time_range_start.nanosec();
177 return *this;
178 }
179
186 inline dds::core::Time time_range_end() const
187 {
188 return dds::core::Time(
189 native().time_range_end.sec,
190 native().time_range_end.nanosec);
191 }
192
197 inline int64_t timestamp_range_end() const
198 {
199 return rti::apputils::util::convert_uint64_into_int64(
200 rti::apputils::util::to_nanosecs(time_range_end()));
201 }
202
207 {
208 native().time_range_end.sec = time_range_end.sec();
209 native().time_range_end.nanosec =
210 static_cast<DDS_UnsignedLong>(time_range_end.nanosec());
211 return *this;
212 }
213
219 inline int32_t max_samples() const
220 {
221 return native().max_samples;
222 }
223
229 {
230 native().max_samples = (int) max_samples;
231 return *this;
232 }
233
234 inline int32_t instance_history_depth() const
235 {
236 return native().instance_history.depth;
237 }
238
239 SelectorState& instance_history_depth(const int32_t depth)
240 {
241 native().instance_history.depth = (int) depth;
242 return *this;
243 }
244
245};
246
247
248} } } /* namespace rti::recording::storage */
249
250#endif /* HPP_RTI_RECORDING_STORAGE_SAMPLESELECTOR_HPP_ */
Definition: SelectorState.hpp:28
This class is used by Replay Service or Converter when asking the storage plugin for data....
Definition: SelectorState.hpp:99
SelectorState & time_range_end(const dds::core::Time &time_range_end)
Sets the upper limit of the time range.
Definition: SelectorState.hpp:206
dds::core::Time time_range_start() const
Returns the time that represents the lower limit (inclusive) of the time range the retrieved data sam...
Definition: SelectorState.hpp:152
dds::core::Time time_range_end() const
Returns the time that represents the upper limit (inclusive) of the time range the retrieved samples ...
Definition: SelectorState.hpp:186
SelectorState & time_range_start(const dds::core::Time &time_range_start)
Sets the lower limit of the time range.
Definition: SelectorState.hpp:172
int32_t max_samples() const
Returns the maximum number of samples to be returned by a single read() call, when the value is posit...
Definition: SelectorState.hpp:219
SelectorState & sample_state(const dds::sub::status::SampleState &state)
Sets the sample state.
Definition: SelectorState.hpp:137
int64_t timestamp_range_start() const
Like the time_range_start() method, but returns the timestamp in long long (int-64) format.
Definition: SelectorState.hpp:163
int64_t timestamp_range_end() const
Like the time_range_end() method, but returns the timestamp in long long (int-64) format.
Definition: SelectorState.hpp:197
SelectorState & max_samples(const int32_t max_samples)
Sets the maximum number of samples to be returned by a single call to read().
Definition: SelectorState.hpp:228
dds::sub::status::SampleState sample_state() const
Returns the sample state. This is used to represent the state of the samples asked for,...
Definition: SelectorState.hpp:129
The RTI namespace.
Definition: RecordingServiceImpl.hpp:22