RTI Recording Service  Version 6.0.1
 All Data Structures Namespaces Files Functions Typedefs Enumerations Enumerator Groups
StorageReaderForwarder.hpp
1 /*
2  * (c) Copyright, Real-Time Innovations, 2017.
3  * All rights reserved.
4  *
5  * No duplications, whole or partial, manual or electronic, may be made
6  * without express written permission. Any such copies, or
7  * revisions thereof, must display this notice unaltered.
8  * This code contains trade secrets of Real-Time Innovations, Inc.
9  */
10 
11 #ifndef RTI_RECORDING_STORAGE_DETAIL_STORAGE_READER_FORWARDER_HPP_
12 #define RTI_RECORDING_STORAGE_DETAIL_STORAGE_READER_FORWARDER_HPP_
13 
14 
15 #include "log/log_common.h"
16 
17 #include "rti/routing/detail/ForwarderUtils.hpp"
18 #include "rti/routing/ServiceProperty.hpp"
19 
20 #include "recordingservice/recordingservice_storagereader.h"
21 #include "rti/recording/storage/detail/StorageStreamReaderForwarder.hpp"
22 #include "StorageStreamInfoReaderForwarder.hpp"
23 
24 namespace rti { namespace recording { namespace storage { namespace detail {
25 
26 class StorageReaderForwarder : public RTI_RecordingServiceStorageReader {
27 public:
28 
29  StorageReaderForwarder(StorageReader *storage_reader)
30  : storage_reader_(storage_reader)
31  {
32  create_stream_reader = StorageReaderForwarder::create_stream_reader_fwd;
33  delete_stream_reader = StorageReaderForwarder::delete_stream_reader_fwd;
34  create_stream_info_reader =
35  StorageReaderForwarder::create_stream_info_reader_fwd;
36  delete_stream_info_reader =
37  StorageReaderForwarder::delete_stream_info_reader_fwd;
38  delete_instance = StorageReaderForwarder::delete_instance_fwd;
39 
40  storage_reader_data = this;
41  }
42 
43  ~StorageReaderForwarder()
44  {
45  }
46 
47  static void delete_instance_fwd(
48  struct RTI_RecordingServiceStorageReader *storage_reader)
49  {
50  try {
51  StorageReaderForwarder *forwarder =
52  static_cast<StorageReaderForwarder *>(storage_reader);
53  delete forwarder;
54  } catch (const std::exception& ex) {
55  RTILog_printContextAndMsg(
56  RTI_LOG_BIT_EXCEPTION,
57  RTI_FUNCTION_NAME,
58  &RTI_LOG_ANY_s,
59  ex.what());
60  } catch (...) {
61  RTILog_printContextAndMsg(
62  RTI_LOG_BIT_EXCEPTION,
63  RTI_FUNCTION_NAME,
64  &RTI_LOG_ANY_s,
65  "unknown exception");
66  }
67  }
68 
69  static RTI_RecordingServiceStorageStreamReader * create_stream_reader_fwd(
70  void *storage_reader,
71  const struct RTI_RoutingServiceStreamInfo *native_stream_info,
72  const struct RTI_RoutingServiceProperties *native_properties)
73  {
74  try {
75  StorageReaderForwarder *forwarder =
76  static_cast<StorageReaderForwarder *>(storage_reader);
77  rti::routing::StreamInfo stream_info(*native_stream_info);
78  rti::routing::PropertySet properties;
79  rti::routing::PropertyAdapter::add_properties_from_native(
80  properties,
81  native_properties);
82  StorageStreamReaderForwarder *stream_reader_forwarder =
83  new StorageStreamReaderForwarder(
84  forwarder->storage_reader_->create_stream_reader(
85  stream_info,
86  properties),
87  forwarder->storage_reader_.get());
88  return stream_reader_forwarder;
89  } catch (const std::exception& ex) {
90  RTILog_printContextAndMsg(
91  RTI_LOG_BIT_EXCEPTION,
92  RTI_FUNCTION_NAME,
93  &RTI_LOG_ANY_s,
94  ex.what());
95  return NULL;
96  } catch (...) {
97  RTILog_printContextAndMsg(
98  RTI_LOG_BIT_EXCEPTION,
99  RTI_FUNCTION_NAME,
100  &RTI_LOG_ANY_s,
101  "unknown exception");
102  }
103  return NULL;
104  }
105 
106  static void delete_stream_reader_fwd(
107  void *,
108  RTI_RecordingServiceStorageStreamReader *storage_stream_reader)
109  {
110  try {
111  StorageStreamReaderForwarder *stream_reader_forwarder =
112  static_cast<StorageStreamReaderForwarder *>(
113  storage_stream_reader);
114  delete stream_reader_forwarder;
115  } catch (const std::exception& ex) {
116  RTILog_printContextAndMsg(
117  RTI_LOG_BIT_EXCEPTION,
118  RTI_FUNCTION_NAME,
119  &RTI_LOG_ANY_s,
120  ex.what());
121  } catch (...) {
122  RTILog_printContextAndMsg(
123  RTI_LOG_BIT_EXCEPTION,
124  RTI_FUNCTION_NAME,
125  &RTI_LOG_ANY_s,
126  "unknown exception");
127  }
128  }
129 
130  static RTI_RecordingServiceStorageStreamInfoReader *
131  create_stream_info_reader_fwd(
132  void *storage_reader_data,
133  const struct RTI_RoutingServiceProperties *native_properties)
134  {
135  try {
136  StorageReaderForwarder *forwarder =
137  static_cast<StorageReaderForwarder *>(storage_reader_data);
138  rti::routing::PropertySet properties;
139  rti::routing::PropertyAdapter::add_properties_from_native(
140  properties,
141  native_properties);
142  StorageStreamInfoReaderForwarder *disc_reader_forwarder =
143  new StorageStreamInfoReaderForwarder(
144  forwarder->storage_reader_->create_stream_info_reader(
145  properties),
146  forwarder->storage_reader_.get());
147  return disc_reader_forwarder;
148  } catch (const std::exception& ex) {
149  RTILog_printContextAndMsg(
150  RTI_LOG_BIT_EXCEPTION,
151  RTI_FUNCTION_NAME,
152  &RTI_LOG_ANY_s,
153  ex.what());
154  return NULL;
155  } catch (...) {
156  RTILog_printContextAndMsg(
157  RTI_LOG_BIT_EXCEPTION,
158  RTI_FUNCTION_NAME,
159  &RTI_LOG_ANY_s,
160  "unknown exception");
161  }
162  return NULL;
163  }
164 
165  static void delete_stream_info_reader_fwd(
166  void *,
167  RTI_RecordingServiceStorageStreamInfoReader *stream_info_reader)
168  {
169  try {
170  StorageStreamInfoReaderForwarder *disc_reader_forwarder =
171  static_cast<StorageStreamInfoReaderForwarder *>(
172  stream_info_reader);
173  delete disc_reader_forwarder;
174  } catch (const std::exception& ex) {
175  RTILog_printContextAndMsg(
176  RTI_LOG_BIT_EXCEPTION,
177  RTI_FUNCTION_NAME,
178  &RTI_LOG_ANY_s,
179  ex.what());
180  } catch (...) {
181  RTILog_printContextAndMsg(
182  RTI_LOG_BIT_EXCEPTION,
183  RTI_FUNCTION_NAME,
184  &RTI_LOG_ANY_s,
185  "unknown exception");
186  }
187  }
188 
189 private:
190 
191  rtiboost::shared_ptr<StorageReader> storage_reader_;
192 
193 };
194 
195 } } } }
196 
197 #endif // RTI_RECORDING_STORAGE_DETAIL_STORAGE_WRITER_FORWARDER_HPP_

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