RTI Recording Service  Version 6.1.1
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 
17 #include "recordingservice/recordingservice_storagereader.h"
18 
19 namespace rti { namespace recording { namespace storage {
20 
21 class SelectorState;
22 
23 
28 public:
29  typedef RTI_RecordingServiceSelectorState native_type;
30 
31  static void initialize(native_type& native_value)
32  {
33  RTI_RecordingServiceSelectorState native_state =
34  RTI_RecordingServiceSelectorState_INITIALIZER;
35  memcpy(&native_value, &native_state, sizeof(native_state));
36  }
37 
38  static void finalize(native_type&)
39  {
40  }
41 
42  static void copy(native_type& destination, const native_type& source)
43  {
44  destination.sample_state = source.sample_state;
45  destination.time_range_start = source.time_range_start;
46  destination.time_range_end = source.time_range_end;
47  destination.max_samples = source.max_samples;
48  destination.instance_history = source.instance_history;
49  }
50 
51  static bool equals(const native_type& first, const native_type& second)
52  {
53  if (first.sample_state != second.sample_state) {
54  return false;
55  }
56  if (first.max_samples != second.max_samples) {
57  return false;
58  }
59  if (!DDS_Time_t_equals(
60  first.time_range_start,
61  second.time_range_start)) {
62  return false;
63  }
64  if (!DDS_Time_t_equals(
65  first.time_range_end,
66  second.time_range_end)) {
67  return false;
68  }
69  return first.instance_history.depth == second.instance_history.depth;
70  }
71 };
72 
73 } }
74 
75 /*
76  * Type native_type_traits needs to be defined in the rti::core namespace.
77  */
78 namespace core {
79 
80 template <>
81 struct native_type_traits<rti::recording::storage::SelectorState> {
83  typedef RTI_RecordingServiceSelectorState native_type;
84 };
85 
86 }
87 
88 namespace recording { namespace storage {
89 
98 class SelectorState : public rti::core::NativeValueType<SelectorState> {
99 public:
100  RTI_NATIVE_VALUE_TYPE_DEFINE_DEFAULT_MOVE_OPERATIONS(SelectorState)
101 
102  typedef rti::core::NativeValueType<SelectorState> Base;
103 
104  SelectorState()
105  {
106  }
107 
108  SelectorState(const RTI_RecordingServiceSelectorState &native) :
109  Base(native)
110  {
111  }
112 
128  inline dds::sub::status::SampleState sample_state() const
129  {
130  return dds::sub::status::SampleState(native().sample_state);
131  }
132 
136  SelectorState& sample_state(const dds::sub::status::SampleState& state)
137  {
138  native().sample_state =
139  static_cast<RTI_RecordingServiceSampleStateMask>(
140  state.to_ulong());
141  return *this;
142  }
143 
151  inline dds::core::Time time_range_start() const
152  {
153  return dds::core::Time(
154  native().time_range_start.sec,
155  native().time_range_start.nanosec);
156  }
157 
162  inline int64_t timestamp_range_start() const
163  {
164  int64_t timestamp =
165  (int64_t) native().time_range_start.sec
166  * rti::core::nanosec_per_sec
167  + native().time_range_start.nanosec;
168  return timestamp;
169  }
170 
174  SelectorState& time_range_start(const dds::core::Time& time_range_start)
175  {
176  native().time_range_start.sec = (DDS_Long) time_range_start.sec();
177  native().time_range_start.nanosec =
178  (DDS_UnsignedLong) time_range_start.nanosec();
179  return *this;
180  }
181 
188  inline dds::core::Time time_range_end() const
189  {
190  return dds::core::Time(
191  native().time_range_end.sec,
192  native().time_range_end.nanosec);
193  }
194 
199  inline int64_t timestamp_range_end() const
200  {
201  int64_t timestamp =
202  (int64_t) native().time_range_end.sec
203  * rti::core::nanosec_per_sec
204  + native().time_range_end.nanosec;
205  return timestamp;
206  }
207 
211  SelectorState& time_range_end(const dds::core::Time& time_range_end)
212  {
213  native().time_range_end.sec = (DDS_Long) time_range_end.sec();
214  native().time_range_end.nanosec =
215  (DDS_UnsignedLong) time_range_end.nanosec();
216  return *this;
217  }
218 
224  inline int32_t max_samples() const
225  {
226  return native().max_samples;
227  }
228 
233  SelectorState& max_samples(const int32_t max_samples)
234  {
235  native().max_samples = (int) max_samples;
236  return *this;
237  }
238 
239  inline int32_t instance_history_depth() const
240  {
241  return native().instance_history.depth;
242  }
243 
244  SelectorState& instance_history_depth(const int32_t depth)
245  {
246  native().instance_history.depth = (int) depth;
247  return *this;
248  }
249 
250 };
251 
252 
253 } } } /* namespace rti::recording::storage */
254 
255 #endif /* HPP_RTI_RECORDING_STORAGE_SAMPLESELECTOR_HPP_ */
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:162
Definition: SelectorState.hpp:27
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:199
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:224
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:233
SelectorState & sample_state(const dds::sub::status::SampleState &state)
Sets the sample state.
Definition: SelectorState.hpp:136
The RTI namespace.
Definition: RecordingServiceImpl.hpp:22
SelectorState & time_range_start(const dds::core::Time &time_range_start)
Sets the lower limit of the time range.
Definition: SelectorState.hpp:174
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:151
SelectorState & time_range_end(const dds::core::Time &time_range_end)
Sets the upper limit of the time range.
Definition: SelectorState.hpp:211
This class is used by Replay Service or Converter when asking the storage plugin for data...
Definition: SelectorState.hpp:98
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:128
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:188