11 #ifndef RTI_RECORDING_STORAGE_DETAIL_STORAGE_STREAM_WRITER_FORWARDER_HPP_
12 #define RTI_RECORDING_STORAGE_DETAIL_STORAGE_STREAM_WRITER_FORWARDER_HPP_
17 #include "log/log_common.h"
18 #include "recordingservice/recordingservice_storagewriter.h"
20 #include "rtiboost/smart_ptr/shared_ptr.hpp"
21 #include "rti/routing/detail/ForwarderUtils.hpp"
24 #include "rti/recording/storage/StorageStreamWriter.hpp"
26 namespace rti {
namespace recording {
namespace storage {
namespace detail {
36 : storage_writer_parent_(storage_writer_parent)
38 RTIBOOST_ASSERT(storage_writer_parent != NULL);
43 if (stream_writer_instance != NULL) {
45 stream_writer_instance);
53 class StorageStreamWriterForwarder :
54 public RTI_RecordingServiceStorageStreamWriter {
57 StorageStreamWriterForwarder(
60 : storage_stream_writer_(
64 store = StorageStreamWriterForwarder::store_fwd;
65 stream_writer_data =
this;
68 ~StorageStreamWriterForwarder()
72 static void store_fwd(
73 void *stream_writer_data,
74 const RTI_RoutingServiceSample *samples,
75 const RTI_RoutingServiceSampleInfo *sample_infos,
79 StorageStreamWriterForwarder *forwarder =
80 static_cast<StorageStreamWriterForwarder *
>(
83 forwarder->sample_seq_.assign(samples, samples + count);
87 if (sample_infos != NULL) {
88 forwarder->info_seq_.assign(sample_infos, sample_infos + count);
91 forwarder->storage_stream_writer_->store(
92 forwarder->sample_seq_,
93 forwarder->info_seq_);
94 }
catch (
const std::exception& ex) {
95 RTILog_printContextAndMsg(
100 RTILog_printContextAndMsg(
103 "unknown exception");
107 StorageStreamWriter * stream_writer()
109 return storage_stream_writer_.get();
113 rtiboost::shared_ptr<StorageStreamWriter> storage_stream_writer_;
115 std::vector<StorageStreamWriter::SamplePtr> sample_seq_;
116 std::vector<StorageStreamWriter::InfoPtr> info_seq_;
129 template<
typename NativeStreamWriterType,
typename NativeStoredType>
136 : storage_stream_writer_(
146 static void store_fwd(
147 void *stream_writer_data,
148 const NativeStoredType **samples,
149 const RTI_RoutingServiceSampleInfo *sample_infos,
164 if (forwarder->storage_stream_writer_.get() == NULL) {
168 StorageStreamWriter::SamplePtr *untyped_samples =
169 (StorageStreamWriter::SamplePtr *) samples;
170 forwarder->sample_seq_.assign(
172 untyped_samples + count);
178 if (sample_infos != NULL) {
179 forwarder->info_seq_.assign(sample_infos, sample_infos + count);
182 forwarder->storage_stream_writer_->store(
183 forwarder->sample_seq_,
184 forwarder->info_seq_);
185 }
catch (
const std::exception& ex) {
186 RTILog_printContextAndMsg(
191 RTILog_printContextAndMsg(
194 "unknown exception");
200 return storage_stream_writer_.get();
204 rtiboost::shared_ptr<StorageStreamWriter> storage_stream_writer_;
206 std::vector<StorageStreamWriter::SamplePtr> sample_seq_;
207 std::vector<StorageStreamWriter::InfoPtr> info_seq_;
211 class StorageParticipantWriterForwarder :
213 RTI_RecordingServiceStorageParticipantWriter,
214 DDS_ParticipantBuiltinTopicData> {
217 StorageParticipantWriterForwarder(
221 RTI_RecordingServiceStorageParticipantWriter,
222 DDS_ParticipantBuiltinTopicData>(
224 storage_writer_parent)
227 stream_writer_data =
this;
231 class StoragePublicationWriterForwarder :
232 public StorageGenericStreamWriterForwarder<
233 RTI_RecordingServiceStoragePublicationWriter,
234 DDS_PublicationBuiltinTopicData> {
237 StoragePublicationWriterForwarder(
238 StorageStreamWriter *stream_writer,
239 StorageWriter *storage_writer_parent) :
240 StorageGenericStreamWriterForwarder<
241 RTI_RecordingServiceStoragePublicationWriter,
242 DDS_PublicationBuiltinTopicData>(
244 storage_writer_parent)
247 stream_writer_data =
this;
251 class StorageSubscriptionWriterForwarder :
252 public StorageGenericStreamWriterForwarder<
253 RTI_RecordingServiceStorageSubscriptionWriter,
254 DDS_SubscriptionBuiltinTopicData> {
257 StorageSubscriptionWriterForwarder(
258 StorageStreamWriter *stream_writer,
259 StorageWriter *storage_writer_parent) :
260 StorageGenericStreamWriterForwarder<
261 RTI_RecordingServiceStorageSubscriptionWriter,
262 DDS_SubscriptionBuiltinTopicData>(
264 storage_writer_parent)
267 stream_writer_data =
this;
273 #endif // RTI_RECORDING_STORAGE_DETAIL_STORAGE_STREAM_WRITER_FORWARDER_HPP_