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(
96 RTI_LOG_BIT_EXCEPTION,
101 RTILog_printContextAndMsg(
102 RTI_LOG_BIT_EXCEPTION,
105 "unknown exception");
109 StorageStreamWriter * stream_writer()
111 return storage_stream_writer_.get();
115 rtiboost::shared_ptr<StorageStreamWriter> storage_stream_writer_;
117 std::vector<StorageStreamWriter::SamplePtr> sample_seq_;
118 std::vector<StorageStreamWriter::InfoPtr> info_seq_;
131 template<
typename NativeStreamWriterType,
typename NativeStoredType>
138 : storage_stream_writer_(
148 static void store_fwd(
149 void *stream_writer_data,
150 const NativeStoredType **samples,
151 const RTI_RoutingServiceSampleInfo *sample_infos,
166 if (forwarder->storage_stream_writer_.get() == NULL) {
170 StorageStreamWriter::SamplePtr *untyped_samples =
171 (StorageStreamWriter::SamplePtr *) samples;
172 forwarder->sample_seq_.assign(
174 untyped_samples + count);
180 if (sample_infos != NULL) {
181 forwarder->info_seq_.assign(sample_infos, sample_infos + count);
184 forwarder->storage_stream_writer_->store(
185 forwarder->sample_seq_,
186 forwarder->info_seq_);
187 }
catch (
const std::exception& ex) {
188 RTILog_printContextAndMsg(
189 RTI_LOG_BIT_EXCEPTION,
194 RTILog_printContextAndMsg(
195 RTI_LOG_BIT_EXCEPTION,
198 "unknown exception");
204 return storage_stream_writer_.get();
208 rtiboost::shared_ptr<StorageStreamWriter> storage_stream_writer_;
210 std::vector<StorageStreamWriter::SamplePtr> sample_seq_;
211 std::vector<StorageStreamWriter::InfoPtr> info_seq_;
215 class StorageParticipantWriterForwarder :
217 RTI_RecordingServiceStorageParticipantWriter,
218 DDS_ParticipantBuiltinTopicData> {
221 StorageParticipantWriterForwarder(
225 RTI_RecordingServiceStorageParticipantWriter,
226 DDS_ParticipantBuiltinTopicData>(
228 storage_writer_parent)
231 stream_writer_data =
this;
235 class StoragePublicationWriterForwarder :
236 public StorageGenericStreamWriterForwarder<
237 RTI_RecordingServiceStoragePublicationWriter,
238 DDS_PublicationBuiltinTopicData> {
241 StoragePublicationWriterForwarder(
242 StorageStreamWriter *stream_writer,
243 StorageWriter *storage_writer_parent) :
244 StorageGenericStreamWriterForwarder<
245 RTI_RecordingServiceStoragePublicationWriter,
246 DDS_PublicationBuiltinTopicData>(
248 storage_writer_parent)
251 stream_writer_data =
this;
255 class StorageSubscriptionWriterForwarder :
256 public StorageGenericStreamWriterForwarder<
257 RTI_RecordingServiceStorageSubscriptionWriter,
258 DDS_SubscriptionBuiltinTopicData> {
261 StorageSubscriptionWriterForwarder(
262 StorageStreamWriter *stream_writer,
263 StorageWriter *storage_writer_parent) :
264 StorageGenericStreamWriterForwarder<
265 RTI_RecordingServiceStorageSubscriptionWriter,
266 DDS_SubscriptionBuiltinTopicData>(
268 storage_writer_parent)
271 stream_writer_data =
this;
277 #endif // RTI_RECORDING_STORAGE_DETAIL_STORAGE_STREAM_WRITER_FORWARDER_HPP_