RTI Recording Service  Version 6.0.1
 All Data Structures Namespaces Files Functions Typedefs Enumerations Enumerator Groups
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  }
49 
50  static bool equals(const native_type& first, const native_type& second)
51  {
52  if (first.sample_state != second.sample_state) {
53  return false;
54  }
55  if (first.max_samples != second.max_samples) {
56  return false;
57  }
58  if (!DDS_Time_t_equals(
59  first.time_range_start,
60  second.time_range_start)) {
61  return false;
62  }
63  return DDS_Time_t_equals(
64  first.time_range_end,
65  second.time_range_end);
66  }
67 };
68 
69 } }
70 
71 /*
72  * Type native_type_traits needs to be defined in the rti::core namespace.
73  */
74 namespace core {
75 
76 template <>
77 struct native_type_traits<rti::recording::storage::SelectorState> {
79  typedef RTI_RecordingServiceSelectorState native_type;
80 };
81 
82 }
83 
84 namespace recording { namespace storage {
85 
94 class SelectorState : public rti::core::NativeValueType<SelectorState> {
95 public:
96  RTI_NATIVE_VALUE_TYPE_DEFINE_DEFAULT_MOVE_OPERATIONS(SelectorState)
97 
98  typedef rti::core::NativeValueType<SelectorState> Base;
99 
100  SelectorState()
101  {
102  }
103 
104  SelectorState(const RTI_RecordingServiceSelectorState &native) :
105  Base(native)
106  {
107  }
108 
124  inline dds::sub::status::SampleState sample_state() const
125  {
126  return dds::sub::status::SampleState(native().sample_state);
127  }
128 
132  SelectorState& sample_state(const dds::sub::status::SampleState& state)
133  {
134  native().sample_state = state.to_ulong();
135  return *this;
136  }
137 
145  inline dds::core::Time time_range_start() const
146  {
147  return dds::core::Time(
148  native().time_range_start.sec,
149  native().time_range_start.nanosec);
150  }
151 
156  inline int64_t timestamp_range_start() const
157  {
158  int64_t timestamp =
159  (int64_t) native().time_range_start.sec
160  * rti::core::nanosec_per_sec
161  + native().time_range_start.nanosec;
162  return timestamp;
163  }
164 
169  {
170  native().time_range_start.sec = (DDS_Long) time_range_start.sec();
171  native().time_range_start.nanosec =
172  (DDS_UnsignedLong) time_range_start.nanosec();
173  return *this;
174  }
175 
182  inline dds::core::Time time_range_end() const
183  {
184  return dds::core::Time(
185  native().time_range_end.sec,
186  native().time_range_end.nanosec);
187  }
188 
193  inline int64_t timestamp_range_end() const
194  {
195  int64_t timestamp =
196  (int64_t) native().time_range_end.sec
197  * rti::core::nanosec_per_sec
198  + native().time_range_end.nanosec;
199  return timestamp;
200  }
201 
205  SelectorState& time_range_end(const dds::core::Time& time_range_end)
206  {
207  native().time_range_end.sec = (DDS_Long) time_range_end.sec();
208  native().time_range_end.nanosec =
209  (DDS_UnsignedLong) time_range_end.nanosec();
210  return *this;
211  }
212 
218  inline int32_t max_samples() const
219  {
220  return native().max_samples;
221  }
222 
228  {
229  native().max_samples = (int) max_samples;
230  return *this;
231  }
232 
233 };
234 
235 
236 } } } /* namespace rti::recording::storage */
237 
238 #endif /* HPP_RTI_RECORDING_STORAGE_SAMPLESELECTOR_HPP_ */

RTI Recording Service Version 6.0.1 Copyright © Sun Nov 17 2019 Real-Time Innovations, Inc