10 #ifndef HPP_RTI_RECORDING_STORAGE_STORAGEDEFS_HPP_
11 #define HPP_RTI_RECORDING_STORAGE_STORAGEDEFS_HPP_
13 #ifndef dds_c_builtin_h
14 #include "dds_c/dds_c_builtin.h"
17 #include <dds/core/Exception.hpp>
18 #include "rtiboost/smart_ptr/shared_ptr.hpp"
19 #include "rti/routing/PropertySet.hpp"
21 #include "recordingservice/recordingservice_storagereader.h"
22 #include "recordingservice/recordingservice_storagewriter.h"
24 namespace rti {
namespace recording {
27 typedef rtiboost::shared_ptr<RTI_RecordingServiceStorageWriter>
28 StorageWriterSharedPtr;
29 typedef rtiboost::shared_ptr<RTI_RecordingServiceStorageStreamWriter>
30 StorageStreamWriterSharedPtr;
31 typedef rtiboost::shared_ptr<RTI_RecordingServiceStorageParticipantWriter>
32 StorageParticipantWriterSharedPtr;
33 typedef rtiboost::shared_ptr<RTI_RecordingServiceStoragePublicationWriter>
34 StoragePublicationWriterSharedPtr;
35 typedef rtiboost::shared_ptr<RTI_RecordingServiceStorageSubscriptionWriter>
36 StorageSubscriptionWriterSharedPtr;
39 typedef rtiboost::shared_ptr<RTI_RecordingServiceStorageReader>
40 StorageReaderSharedPtr;
41 typedef rtiboost::shared_ptr<RTI_RecordingServiceStorageStreamReader>
42 StorageStreamReaderSharedPtr;
43 typedef rtiboost::shared_ptr<RTI_RecordingServiceStorageStreamInfoReader>
44 StorageStreamInfoReaderSharedPtr;
51 class NativeStorageStreamWriterDeleter {
53 NativeStorageStreamWriterDeleter(
54 RTI_RecordingServiceStorageWriter *storage_writer_parent)
55 : storage_writer_parent_(storage_writer_parent)
57 RTIBOOST_ASSERT(storage_writer_parent != NULL);
60 void operator ()(RTI_RecordingServiceStorageStreamWriter *instance)
62 if (instance != NULL) {
63 storage_writer_parent_->delete_stream_writer(
64 storage_writer_parent_,
69 void operator ()(RTI_RecordingServiceStorageParticipantWriter *instance)
74 && storage_writer_parent_->delete_participant_writer != NULL) {
75 storage_writer_parent_->delete_participant_writer(
76 storage_writer_parent_,
81 void operator ()(RTI_RecordingServiceStoragePublicationWriter *instance)
86 && storage_writer_parent_->delete_publication_writer != NULL) {
87 storage_writer_parent_->delete_publication_writer(
88 storage_writer_parent_,
93 void operator ()(RTI_RecordingServiceStorageSubscriptionWriter *instance)
98 && storage_writer_parent_->delete_subscription_writer != NULL) {
99 storage_writer_parent_->delete_subscription_writer(
100 storage_writer_parent_,
106 RTI_RecordingServiceStorageWriter *storage_writer_parent_;
109 class NativeStorageStreamInfoReaderDeleter {
111 NativeStorageStreamInfoReaderDeleter(
112 RTI_RecordingServiceStorageReader *storage_reader_parent)
113 : storage_reader_parent_(storage_reader_parent)
115 RTIBOOST_ASSERT(storage_reader_parent != NULL);
118 void operator ()(RTI_RecordingServiceStorageStreamInfoReader *instance)
120 if (instance != NULL) {
121 storage_reader_parent_->delete_stream_info_reader(
122 storage_reader_parent_,
128 RTI_RecordingServiceStorageReader *storage_reader_parent_;
131 class NativeStorageStreamReaderDeleter {
133 NativeStorageStreamReaderDeleter(
134 RTI_RecordingServiceStorageReader *storage_reader_parent)
135 : storage_reader_parent_(storage_reader_parent)
137 RTIBOOST_ASSERT(storage_reader_parent != NULL);
140 void operator ()(RTI_RecordingServiceStorageStreamReader *instance)
142 if (instance != NULL) {
143 storage_reader_parent_->delete_stream_reader(
144 storage_reader_parent_,
150 RTI_RecordingServiceStorageReader *storage_reader_parent_;
153 inline bool is_discovery_stream(
const std::string& stream_name)
155 if (stream_name.compare(DDS_PARTICIPANT_TOPIC_NAME) == 0
156 || stream_name.compare(DDS_PUBLICATION_TOPIC_NAME) == 0
157 || stream_name.compare(DDS_SUBSCRIPTION_TOPIC_NAME) == 0) {
163 inline std::string domain_id_property_name()
165 return RTI_RECORDING_SERVICE_DOMAIN_ID_PROPERTY_NAME;
168 inline std::string start_timestamp_property_name()
170 return RTI_RECORDING_SERVICE_START_TIMESTAMP_PROPERTY_NAME;
173 inline std::string end_timestamp_property_name()
175 return RTI_RECORDING_SERVICE_END_TIMESTAMP_PROPERTY_NAME;
178 template <
typename T>
179 inline T get_from_properties(
180 const rti::routing::PropertySet& properties,
181 const std::string& property_name)
183 rti::routing::PropertySet::const_iterator found =
184 properties.find(property_name);
185 if (found == properties.end()) {
186 throw dds::core::Error(
187 "!found property with name=" + property_name);
190 std::stringstream str_stream(found->second);
192 if (str_stream.fail()) {
193 throw dds::core::Error(
194 "!parse value from property with name=" + property_name);
199 template <
typename T>
200 inline void add_to_properties(
201 rti::routing::PropertySet& properties,
202 const std::string& property_name,
205 rti::routing::PropertySet::const_iterator found =
206 properties.find(property_name);
207 if (found != properties.end()) {
210 std::stringstream str_stream;
212 if (str_stream.fail()) {
213 throw dds::core::Error(
214 "!add value for property with name=" + property_name);
216 properties[property_name] = str_stream.str();