11 #ifndef RTI_RECORDING_STORAGE_DETAIL_STORAGE_DISC_STREAM_READER_FORWARDER_HPP_
12 #define RTI_RECORDING_STORAGE_DETAIL_STORAGE_DISC_STREAM_READER_FORWARDER_HPP_
17 #include "rti/recording/storage/StorageStreamInfoReader.hpp"
18 #include "log/log_common.h"
19 #include "recordingservice/recordingservice_storagereader.h"
21 #include "rtiboost/smart_ptr/shared_ptr.hpp"
22 #include "rti/routing/detail/ForwarderUtils.hpp"
26 namespace rti {
namespace recording {
namespace storage {
namespace detail {
36 : storage_reader_parent_(storage_reader_parent)
38 RTIBOOST_ASSERT(storage_reader_parent != NULL);
43 RTIBOOST_ASSERT(stream_reader_instance != NULL);
45 stream_reader_instance);
52 class StorageStreamInfoReaderForwarder :
53 public RTI_RecordingServiceStorageStreamInfoReader {
56 StorageStreamInfoReaderForwarder(
59 : storage_stream_reader_(
63 read = StorageStreamInfoReaderForwarder::read_fwd;
64 return_loan = StorageStreamInfoReaderForwarder::return_loan_fwd;
65 get_service_start_time =
66 StorageStreamInfoReaderForwarder::get_service_start_time_fwd;
67 get_service_stop_time =
68 StorageStreamInfoReaderForwarder::get_service_stop_time_fwd;
69 finished = StorageStreamInfoReaderForwarder::finished_fwd;
70 reset = StorageStreamInfoReaderForwarder::reset_fwd;
71 stream_reader_data =
this;
74 ~StorageStreamInfoReaderForwarder()
80 void *stream_reader_data,
81 RTI_RoutingServiceStreamInfo ***stream_info_array,
83 const struct RTI_RecordingServiceSelectorState *native_selector)
86 StorageStreamInfoReaderForwarder *forwarder =
87 static_cast<StorageStreamInfoReaderForwarder *
>(
89 forwarder->storage_stream_reader_->read(
90 forwarder->sample_seq_,
91 SelectorState(*native_selector));
93 *array_length = forwarder->sample_seq_.size();
94 if (*array_length > 0) {
95 forwarder->native_sample_seq_.resize(*array_length);
96 for (
size_t i = 0; i < forwarder->sample_seq_.size(); i++) {
97 forwarder->native_sample_seq_[i] =
98 &(forwarder->sample_seq_[i]->native());
101 reinterpret_cast<RTI_RoutingServiceStreamInfo **
>(
102 forwarder->native_sample_seq_.data());
104 }
catch (
const std::exception& ex) {
105 RTILog_printContextAndMsg(
106 RTI_LOG_BIT_EXCEPTION,
111 RTILog_printContextAndMsg(
112 RTI_LOG_BIT_EXCEPTION,
115 "unknown exception");
119 static void return_loan_fwd(
120 void *stream_reader_data,
121 struct RTI_RoutingServiceStreamInfo **stream_info_array,
124 RTIOsapiUtility_unusedParameter(stream_info_array);
125 RTIOsapiUtility_unusedParameter(array_length);
128 StorageStreamInfoReaderForwarder *forwarder =
129 static_cast<StorageStreamInfoReaderForwarder *
>(
133 forwarder->storage_stream_reader_->return_loan(
134 forwarder->sample_seq_);
136 forwarder->sample_seq_.clear();
137 forwarder->native_sample_seq_.clear();
138 }
catch (
const std::exception& ex) {
139 RTILog_printContextAndMsg(
140 RTI_LOG_BIT_EXCEPTION,
145 RTILog_printContextAndMsg(
146 RTI_LOG_BIT_EXCEPTION,
149 "unknown exception");
153 static long long get_service_start_time_fwd(
void *stream_reader_data)
156 StorageStreamInfoReaderForwarder *forwarder =
157 static_cast<StorageStreamInfoReaderForwarder *
>(
160 forwarder->storage_stream_reader_->service_start_time();
161 }
catch (
const std::exception& ex) {
162 RTILog_printContextAndMsg(
163 RTI_LOG_BIT_EXCEPTION,
168 RTILog_printContextAndMsg(
169 RTI_LOG_BIT_EXCEPTION,
172 "unknown exception");
177 static long long get_service_stop_time_fwd(
void *stream_reader_data)
180 StorageStreamInfoReaderForwarder *forwarder =
181 static_cast<StorageStreamInfoReaderForwarder *
>(
184 forwarder->storage_stream_reader_->service_stop_time();
185 }
catch (
const std::exception& ex) {
186 RTILog_printContextAndMsg(
187 RTI_LOG_BIT_EXCEPTION,
192 RTILog_printContextAndMsg(
193 RTI_LOG_BIT_EXCEPTION,
196 "unknown exception");
201 static int finished_fwd(
void *stream_reader_data)
204 StorageStreamInfoReaderForwarder *forwarder =
205 static_cast<StorageStreamInfoReaderForwarder *
>(
207 return (forwarder->storage_stream_reader_->finished() ?
210 }
catch (
const std::exception& ex) {
211 RTILog_printContextAndMsg(
212 RTI_LOG_BIT_EXCEPTION,
217 RTILog_printContextAndMsg(
218 RTI_LOG_BIT_EXCEPTION,
221 "unknown exception");
226 static void reset_fwd(
void *stream_reader_data)
229 StorageStreamInfoReaderForwarder *forwarder =
230 static_cast<StorageStreamInfoReaderForwarder *
>(
232 forwarder->storage_stream_reader_->reset();
233 }
catch (
const std::exception& ex) {
234 RTILog_printContextAndMsg(
235 RTI_LOG_BIT_EXCEPTION,
240 RTILog_printContextAndMsg(
241 RTI_LOG_BIT_EXCEPTION,
244 "unknown exception");
248 StorageStreamInfoReader * stream_reader()
250 return storage_stream_reader_.get();
254 rtiboost::shared_ptr<StorageStreamInfoReader> storage_stream_reader_;
256 std::vector<rti::routing::StreamInfo *> sample_seq_;
257 std::vector<RTI_RoutingServiceStreamInfo *> native_sample_seq_;
258 std::vector<int32_t> domain_id_seq_;
264 #endif // RTI_RECORDING_STORAGE_DETAIL_STORAGE_DISC_STREAM_READER_FORWARDER_HPP_