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(
110 RTILog_printContextAndMsg(
113 "unknown exception");
117 static void return_loan_fwd(
118 void *stream_reader_data,
119 struct RTI_RoutingServiceStreamInfo **stream_info_array,
122 RTIOsapiUtility_unusedParameter(stream_info_array);
123 RTIOsapiUtility_unusedParameter(array_length);
126 StorageStreamInfoReaderForwarder *forwarder =
127 static_cast<StorageStreamInfoReaderForwarder *
>(
131 forwarder->storage_stream_reader_->return_loan(
132 forwarder->sample_seq_);
134 forwarder->sample_seq_.clear();
135 forwarder->native_sample_seq_.clear();
136 }
catch (
const std::exception& ex) {
137 RTILog_printContextAndMsg(
142 RTILog_printContextAndMsg(
145 "unknown exception");
149 static long long get_service_start_time_fwd(
void *stream_reader_data)
152 StorageStreamInfoReaderForwarder *forwarder =
153 static_cast<StorageStreamInfoReaderForwarder *
>(
156 forwarder->storage_stream_reader_->service_start_time();
157 }
catch (
const std::exception& ex) {
158 RTILog_printContextAndMsg(
163 RTILog_printContextAndMsg(
166 "unknown exception");
171 static long long get_service_stop_time_fwd(
void *stream_reader_data)
174 StorageStreamInfoReaderForwarder *forwarder =
175 static_cast<StorageStreamInfoReaderForwarder *
>(
178 forwarder->storage_stream_reader_->service_stop_time();
179 }
catch (
const std::exception& ex) {
180 RTILog_printContextAndMsg(
185 RTILog_printContextAndMsg(
188 "unknown exception");
193 static int finished_fwd(
void *stream_reader_data)
196 StorageStreamInfoReaderForwarder *forwarder =
197 static_cast<StorageStreamInfoReaderForwarder *
>(
199 return (forwarder->storage_stream_reader_->finished() ?
202 }
catch (
const std::exception& ex) {
203 RTILog_printContextAndMsg(
208 RTILog_printContextAndMsg(
211 "unknown exception");
216 static void reset_fwd(
void *stream_reader_data)
219 StorageStreamInfoReaderForwarder *forwarder =
220 static_cast<StorageStreamInfoReaderForwarder *
>(
222 forwarder->storage_stream_reader_->reset();
223 }
catch (
const std::exception& ex) {
224 RTILog_printContextAndMsg(
229 RTILog_printContextAndMsg(
232 "unknown exception");
236 StorageStreamInfoReader * stream_reader()
238 return storage_stream_reader_.get();
242 rtiboost::shared_ptr<StorageStreamInfoReader> storage_stream_reader_;
244 std::vector<rti::routing::StreamInfo *> sample_seq_;
245 std::vector<RTI_RoutingServiceStreamInfo *> native_sample_seq_;
246 std::vector<int32_t> domain_id_seq_;
252 #endif // RTI_RECORDING_STORAGE_DETAIL_STORAGE_DISC_STREAM_READER_FORWARDER_HPP_