Adds immediate migration results

This commit is contained in:
torsten committed 2026-08-18 22:12:24 +02:00
1 parent ba4121728b
commit 6a2a0667ab
2395 files changed
+357322 -2524

No files matched your search

@@ -0,0 +1,174 @@
/*
* (c) Copyright, Real-Time Innovations, 2017.
* All rights reserved.
*
* No duplications, whole or partial, manual or electronic, may be made
* without express written permission. Any such copies, or
* revisions thereof, must display this notice unaltered.
* This code contains trade secrets of Real-Time Innovations, Inc.
*/
#ifndef RTI_RECORDING_LOGGER_HPP_
#define RTI_RECORDING_LOGGER_HPP_
#include "recordingservice/recordingservice_dll.h"
#include <dds/core/Reference.hpp>
#include <rti/config/Logger.hpp>
namespace rti { namespace recording {
/** \ingroup RTI_RecordingServiceLibModule
*
* @brief The singleton type used to configure @product verbosity
*
* For configuring other aspects such as output file, print format or
* RTI Connext specific logging, use rti::config::Logger.
*
*/
class RECORDERDllExport Logger
{
public:
typedef rti::config::Verbosity Verbosity;
typedef rti::config::LogCategory LogCategory;
typedef rti::config::PrintFormat PrintFormat;
static Logger& instance();
/**
* @brief Logs as message with EXCEPTION level
*
* The generated log will be part of logging stream of the running service
* if the service verbosity contains EXCEPTION messages. The result log
* message may include additional information according to the
* Connext logging configuration, such as Advlog Context, thread ID,
* line number, etc. Additionally, the result log message will contain a
* newline character at the end, so the format does not need to contain it.
*
* @param[in] msg Message to be logged
*/
void error(const std::string& msg);
/**
* @brief overload of error(const std::string& msg)
*/
void error(const char *msg);
/**
* @brief Logs as message with WARNING level
*
* This operation behaves similar to error() except the log level is
* WARNING.
*
* @param[in] msg Message to be logged
*
* @see rti::recording::Logger::error
*
*/
void warn(const std::string& msg);
/**
* @brief overload of warn(const std::string& msg)
*/
void warn(const char *msg);
/**
* @brief Logs as message with WARNING level
*
* This operation behaves similar to error() except the log level is
* STATUS_LOCAL.
*
* @param[in] msg Message to be logged
*
* @see rti::recording::Logger::error
*
*/
void local(const std::string& msg);
/**
* @brief overload of local(const std::string& msg)
*/
void local(const char *msg);
/**
* @brief Logs as message with WARNING level
*
* This operation behaves similar to error() except the log level is
* STATUS_REMOTE.
*
* @param[in] msg Message to be logged
*
* @see rti::recording::Logger::error
*
*/
void remote(const std::string& msg);
/**
* @brief overload of remote(const std::string& msg)
*/
void remote(const char *msg);
/**
* @brief Logs as message with WARNING level
*
* This operation behaves similar to error() except the log level is
* STATUS_DEBUG.
*
* @param[in] msg Message to be logged
*
* @see rti::recording::Logger::error
*
*/
void debug(const std::string& msg);
/**
* @brief overload of debug(const std::string& msg)
*/
void debug(const char *msg);
/**
* @brief Sets the verbosity for the log messages generated at the
* @product level.
*
* @param[in] verbosity
* The verbosity of the service logs
*/
void service_verbosity(rti::config::Verbosity verbosity);
/**
* @brief Getter for the same attribute
*
* @see verbosity(rti::config::Verbosity)
*/
rti::config::Verbosity service_verbosity();
/**
* @deprecated
* @see service_verbosity
*/
void verbosity(rti::config::Verbosity verbosity);
/**
* @deprecated
* @see service_verbosity
*/
rti::config::Verbosity verbosity();
virtual ~Logger();
private:
void message(const rti::config::LogLevel& level, const char* msg);
Logger();
// Disable copy
Logger(const Logger&);
Logger& operator=(const Logger&);
};
}}
#endif // RTI_RECORDING_LOGGER_HPP_
@@ -0,0 +1,13 @@
#ifndef RTI_RECORDING_PROPERTYSET_HPP
#define RTI_RECORDING_PROPERTYSET_HPP
#include <rti/routing/PropertySet.hpp>
namespace rti { namespace recording {
typedef rti::routing::PropertySet PropertySet;
}}
#endif /* RTI_RECORDING_PROPERTYSET_HPP */
@@ -0,0 +1,6 @@
#ifndef RTI_RECORDING_RECORDING_SERVICE_HPP_
#define RTI_RECORDING_RECORDING_SERVICE_HPP_
#include <rti/recording/Service.hpp>
#endif
@@ -0,0 +1,295 @@
/*
* (c) Copyright, Real-Time Innovations, 2017.
* All rights reserved.
*
* No duplications, whole or partial, manual or electronic, may be made
* without express written permission. Any such copies, or
* revisions thereof, must display this notice unaltered.
* This code contains trade secrets of Real-Time Innovations, Inc.
*/
#ifndef RTI_RECORDING_SERVICE_HPP_
#define RTI_RECORDING_SERVICE_HPP_
#include <dds/core/Reference.hpp>
#include <rti/config/Logger.hpp>
#include <rti/recording/Logger.hpp>
#include <rti/recording/ServiceProperty.hpp>
#include <rti/recording/detail/RecordingServiceImpl.hpp>
namespace rti { namespace recording {
/*e \defgroup RTI_RecordingServiceLibModule RTI Recording Library API
*
* @brief @product can be deployed as a native library linked into your
* application in select architectures.
*
* This API allows you to create, configure and start @product instances from
* your application.
*
* The following code shows the typical use of the API:
*
* \code
*
* int main ()
* {
* rti::recording::Service service(
* rti::recording::ServiceProperty()
* .cfg_file("MyRecorder.xml")
* .service_name("MyRecorder"));
* ...
*
* service.start();
*
* while(keep_running) {
* sleep();
* ...
* }
*
* return 0;
* }
*
* \endcode
*
* Instead of a file, you can use XML strings to configure @product.
* See ServiceProperty for more information.
* <p>
* To build your application you need to link with the @product native library
* in <b> &lt;@ndds home&gt;/bin/&lt;architecture&gt;/ </b>.
*
* ### Development Requirements
*
* | | Linux Systems | Windows Systems |
* | --------------: | :----------------: | :-------------: |
* | Shared Libraries| libnddscpp2.so | nddscpp2.dll |
* | Shared Libraries| librtiroutingservice.so | rtiroutingservice.dll |
* | ^ | librtirsinfrastructure.so | rtirsinfrastructure.dll |
* | ^ | librtirecordingservicecore.so | rtirecordingservicecore.dll |
* | ^ | librtidlc.so | rtidlc.dll |
* | ^ | libnddsmetp.so | nddsmetp.dll |
* | ^ | libnddsc.so | nddsc.dll |
* | ^ | librtixml2.so | rtixml2.dll |
* | ^ | libnddscore.so | nddscore.dll |
* | Headers | rti/recording/RecordingService.hpp ||
*
*/
/** \ingroup RTI_RecordingServiceLibModule
*
* @brief The @product.
*
*/
class Service : public dds::core::Reference<RecordingServiceImpl> {
public:
typedef RTI::Service::Admin::CommandRequest CommandRequest;
typedef RTI::Service::Admin::CommandReply CommandReply;
typedef dds::core::Reference<RecordingServiceImpl> Base;
OMG_DDS_REF_TYPE_NOTYPENAME(
Service,
dds::core::Reference,
RecordingServiceImpl);
/**
* @brief Creates a @product instance
*
* @param[in] property
* The property to configure @product instance.
*
* @mtsafety On non-Linux, non-Windows systems (i.e. VxWorks):
* UNSAFE for multiple threads to simultaneously make the FIRST
* call to any of the Service constructors. Subsequent calls are
* thread safe.
* On Windows and Linux systems, these calls are thread-safe.
*/
explicit Service(const ServiceProperty& property)
: Base(new RecordingServiceImpl(property))
{
this->delegate()->remember_reference(this->delegate());
}
/**
* @brief Creates a @product instance
*
* A callable shutdown hook can optionally be provided to handle the
* shutdown command received through remote administration or upon execution
* termination in the case of the REPLAY role. Upon reception
* of this command, @product will notify the installed hook.
*
* The following example shows simple implementation of a shutdown hook
* that sets a boolean flag to true when invoked:
*
* \code
*
* // Hook implementation
* struct FlagShutdownHook {
* public:
* FlagShutdownHook(bool& the_flag) : flag(the_flag) {
* flag = false;
* }
* void operator()() {
* flag = true;
* }
*
* bool& flag;
* };
*
* // Instantiate service with hook
* bool my_flag;
* rti::recording::Service recording_service(
* property,
* FlagShutdownHook(my_flag));
* ...
*
*
* \endcode
*
* @param[in] property
* The property to configure @product instance.
*
* @param[in] shutdown_hook
* Callable object to handle the shutdown command. The expected
* type is a void operator()() (C++11 equivalent is
* std::function<void()>)
*
* @mtsafety On non-Linux, non-Windows systems (i.e. VxWorks):
* UNSAFE for multiple threads to simultaneously make the FIRST
* call to any of the Service constructors. Subsequent calls are
* thread safe.
* On Windows and Linux systems, these calls are thread-safe.
*/
template <typename HookFunc>
explicit Service(
const ServiceProperty& property,
HookFunc& shutdown_hook)
: Base(new RecordingServiceImpl(
property,
new rti::routing::detail::ShutdownHookForwarder<HookFunc>(
shutdown_hook)))
{
this->delegate()->remember_reference(this->delegate());
}
explicit Service(Base::DELEGATE_REF_T reference) : Base(reference)
{
if (this->delegate()) {
this->delegate()->remember_reference(this->delegate());
}
}
/**
* @brief Starts @product.
*
* This is a non-blocking operation. @product will create its own set of
* threads to perform its tasks.
*/
void start()
{
this->delegate()->start();
}
/**
* @brief Stops @product.
*
* This operation will bloc the instance is fully stopped.
*/
void stop()
{
this->delegate()->stop();
}
/**
* @brief Executes an Administration command on this service.
*
* This operation directly executes the specified \p request in this
* service as if it was directly received from an administration requester.
*
* The request can represent any of the available administration operations
* as documented in the Administration chapter in the user's manual. This
* operation gives you an alternative way to control the service using
* the same remote administration interface but allowing you to call
* the operation directly.
*
* This operation can also throw an exception if an internal error
* occurs.
*
* Example:
*
* \code
*
* using namespace rti::recording;
* using namespace RTI::Service;
* using namespace RTI::Service::Admin;
*
* // Instantiate a RecordingService
* RecordingService service(...);
*
* // Prepare a request for any command, for example stop the service
* CommandRequest request;
* request.action(CommandActionKind::UPDATE_ACTION);
* request.resource_identifier("/recording_services/MyRecorder");
* dds::topic::topic_type_support<EntityState>::to_cdr_buffer(
* reinterpret_cast<std::vector<char> &>(request.octet_body()),
* EntityState(EntityStateKind::DISABLED));
* // Execute and check result
* CommandReply reply = service.execute_command(request);
* if (reply.retcode().underlying() != CommandReplyRetcode::OK_RETCODE) {
* Logger.instance().error(
* std::string("Command returned: ") + reply.string_body());
* //handle
* ...
* }
*
* \endcode
*
* @param[in] request Representation of the command to be executed
* @return The reply with the result of the command execution.
*
*/
CommandReply execute_command(const CommandRequest& request)
{
return this->delegate()->execute_command(request);
}
/**
* @brief Executes an Administration command on this service.
*
* Similar to execute_command(const CommandRequest& request) except
* the caller provides the CommandReply object.
*
* @param[out] reply Representation of the reply containing the result of
* the operation
* @param[in] request Representation of the command to be executed
*
* @return A reference to the same reply object provided as a parameter
*/
CommandReply& execute_command(
CommandReply& reply,
const CommandRequest& request)
{
return this->delegate()->execute_command(reply, request);
}
/**
* @deprecated Calling this function at the end of the application is no
* longer necessary. It will be removed in future versions.
*/
static void finalize_globals()
{
rti::recording::Logger::instance().warn(
"Calling 'rti::recording::Service::finalize_globals()' is no "
"longer necessary and the function will be removed in future "
"versions");
}
};
typedef Service RecordingService;
}}
#endif // RTI_RECORDING_SERVICE_HPP_
@@ -0,0 +1,579 @@
/*
* $Id$
*
* (c) Copyright, Real-Time Innovations, 2016-.
* All rights reserved.
* No duplications, whole or partial, manual or electronic, may be made
* without express written permission. Any such copies, or
* revisions thereof, must display this notice unaltered.
* This code contains trade secrets of Real-Time Innovations, Inc.
*/
#ifndef HPP_SERVICE_SERVICEPROPERTY_HPP_
#define HPP_SERVICE_SERVICEPROPERTY_HPP_
#include "stdio.h"
#include "stdlib.h"
#include <string>
#include <stdint.h>
#include <map>
#include "osapi/osapi_type.h"
#include "routingservice/routingservice_infrastructure.h"
#include "routingservice/routingservice_service.h"
#include <dds/core/SafeEnumeration.hpp>
#include <rti/recording/PropertySet.hpp>
namespace rti { namespace recording {
/** \ingroup RTI_RecordingServiceLibModule
*
* The definition of the rti::recording::ApplicationRoleKind
*
* It indicates the operation mode of @product.
*/
struct ApplicationRoleKind_def {
/**
* @brief The underlying \p enum type
*/
enum type {
/**
* @brief Record mode
*/
RECORD_APPLICATION,
/**
* @brief Replay mode
*/
REPLAY_APPLICATION,
/**
* @brief Converter mode
*/
CONVERTER_APPLICATION,
/*i
* @brief Internal use only
*/
XML_CONVERTER_APPLICATION,
/*i
* @brief Indexer mode. To be used internally by our command-line tool.
*/
INDEX_APPLICATION,
/*i
*/
count_
};
};
typedef dds::core::safe_enum<ApplicationRoleKind_def> ApplicationRoleKind;
/*i
* @brief Internal use only
*/
struct XmlConverterRoleKind_def {
enum type {
RECORD_CONVERT,
REPLAY_CONVERT,
count_
};
};
typedef dds::core::safe_enum<XmlConverterRoleKind_def> XmlConverterRoleKind;
/*i
* @brief Indexer mode enumeration, used by the index application (offline
* indexing)
*/
struct IndexerModeKind_def {
enum type {
INSTANCE_INDEXING,
SQLITE_INDEXING,
count_
};
};
typedef dds::core::safe_enum<IndexerModeKind_def> IndexerModeKind;
typedef rti::routing::PropertySet PropertySet;
/** \ingroup RTI_RecordingServiceLibModule
*
* @brief Configuration for a @product object.
*
*/
class ServiceProperty {
public:
/**
* @brief Creates a property object with default settings.
*/
ServiceProperty() :
cfg_file_(""),
service_name_(""),
application_name_(""),
domain_id_base_(0),
enable_administration_(false),
administration_domain_id_(0),
enable_monitoring_(false),
monitoring_domain_id_(0),
application_role_(ApplicationRoleKind::RECORD_APPLICATION),
enforce_xsd_validation_(true),
ignore_default_files_(false),
output_cfg_file_(""),
debug_mode_(false),
reverse_mode_(false),
xml_converter_role_(XmlConverterRoleKind::RECORD_CONVERT),
indexer_mode_(IndexerModeKind::INSTANCE_INDEXING),
user_env_()
{
}
/**
* @brief Getter (see setter with the same name)
*/
const std::string& cfg_file() const
{
return cfg_file_;
}
/**
* @brief Path to an @product configuration file
*
* @default empty string.
*/
ServiceProperty& cfg_file(const std::string & cfg_file)
{
cfg_file_ = cfg_file;
return *this;
}
/**
* @brief Getter (see setter with the same name)
*/
const std::string & service_name() const
{
return service_name_;
}
/**
* @brief The name of the @product configuration to run.
*
* This is the name used to find the service XML tag in the configuration
* file; the name that will be used to refer to this execution in remote
* administration and
* monitoring.
*
* @default empty string.
*/
ServiceProperty& service_name(const std::string & service_name)
{
service_name_ = service_name;
return *this;
}
/**
* @brief Getter (see setter with the same name)
*/
const std::string & application_name() const
{
return application_name_;
}
/**
* @brief Assigns a name to the execution of the @product.
*
* Remote commands and status information will refer to the service using
* this name.
*
* In addition, the name of DomainParticipants created by @product will be
* based on this name.
*
* @default empty string.
* If no application name is specified, @product will use
* ServiceProperty::service_name.
*
*/
ServiceProperty& application_name(const std::string & application_name)
{
application_name_ = application_name;
return *this;
}
/**
* @brief Getter (see setter with the same name)
*/
int32_t domain_id_base() const
{
return domain_id_base_;
}
/**
* @brief Getter (see setter with the same name)
*/
bool enforce_xsd_validation() const
{
return enforce_xsd_validation_;
}
/**
* @brief Controls whether the service applies XSD validation to the loaded
* configuration.
*
* @default true
*/
ServiceProperty& enforce_xsd_validation(bool enforce)
{
enforce_xsd_validation_ = enforce;
return *this;
}
/**
* @brief Value that is added to the domain IDs of the
* domain routes in the XML configuration.
*
* By using this, an XML file can use relative domain IDs.
*
* @default 0
*/
ServiceProperty& domain_id_base(int32_t domain_id)
{
domain_id_base_ = domain_id;
return *this;
}
/**
* @brief Getter (see setter with the same name)
*/
bool enable_administration() const
{
return enable_administration_;
}
/**
* @brief Set this to true to enable remote administration
* or false to disable it.
*
* @default false
*/
ServiceProperty& enable_administration(bool enable_administration)
{
enable_administration_ = enable_administration;
return *this;
}
/**
* @brief Getter (see setter with the same name)
*/
int32_t administration_domain_id() const
{
return administration_domain_id_;
}
/**
* @brief If ServiceProperty::enable_administration is true, this is
* the domain ID to use for remote administration.
*
* Takes precedence over the XML configuration.
* If ServiceProperty::enable_administration is false, this value is not used
* even if remote administration is enabled in the XML configuration.
*
* @default 0
*/
ServiceProperty& administration_domain_id(int32_t domain_id)
{
administration_domain_id_ = domain_id;
return *this;
}
/**
* @brief Getter (see setter with the same name)
*/
bool enable_monitoring() const
{
return enable_monitoring_;
}
/**
* @brief Set it to true to enable remote monitoring
* or false to disable it.
*
* @default false
*/
ServiceProperty& enable_monitoring(bool enable_monitoring)
{
enable_monitoring_ = enable_monitoring;
return *this;
}
/**
* @brief Getter (see setter with the same name)
*/
int32_t monitoring_domain_id() const
{
return monitoring_domain_id_;
}
/**
* @brief If ServiceProperty::enable_monitoring is true, this is
* the domain ID to use for remote monitoring.
*
* Takes precedence over the XML configuration.
* If ServiceProperty::enable_monitoring is false, this value is not used,
* even if remote monitoring is enabled in the XML configuration.
*
* @default 0
*/
ServiceProperty& monitoring_domain_id(int32_t domain_id)
{
monitoring_domain_id_ = domain_id;
return *this;
}
/**
* @brief Getter (see setter with the same name)
*/
const ApplicationRoleKind& application_role() const
{
return application_role_;
}
/**
* @brief Selects the operation mode of the service
*
* @see ApplicationRoleKind
*/
ServiceProperty& application_role(ApplicationRoleKind application_role)
{
application_role_ = application_role;
return *this;
}
/**
* @brief Getter (see setter with the same name)
*/
bool ignore_default_files() const
{
return ignore_default_files_;
}
/**
* @brief Set it to true to avoid loading the
* standard files usually loaded by @product.
*
* Only the configuration in ServiceProperty::cfg_file or
* ServiceProperty::cfg_strings will be loaded.
*
* @default false
*/
ServiceProperty& ignore_default_files(bool ignore)
{
ignore_default_files_ = ignore;
return *this;
}
/**
* @brief Getter (see setter with the same name)
*/
const std::string& license_file() const
{
return license_file_;
}
/**
* @brief Path to an RTI Connext license file. This parameter is only used
* if your installation requires a license file.
*
* @default empty string.
*/
ServiceProperty& license_file(const std::string& license_file)
{
license_file_ = license_file;
return *this;
}
/*i
* @brief Internal use only
*/
const std::string output_cfg_file() const
{
return output_cfg_file_;
}
/*i
* @brief Internal use only
*/
ServiceProperty& output_cfg_file(
const std::string & output_cfg_file)
{
output_cfg_file_ = output_cfg_file;
return *this;
}
/**
* @brief Getter (see setter with the same name)
*/
bool debug_mode() const
{
return debug_mode_;
}
/**
* @brief Set this to true to enable debug mode
* or false to disable it.
*
* @default false
*/
ServiceProperty& debug_mode(bool debug_mode)
{
debug_mode_ = debug_mode;
return *this;
}
/**
* @brief Getter (see setter with the same name)
*/
bool reverse_mode() const
{
return reverse_mode_;
}
/**
* @brief Set this to true to enable reverse mode
* or false to disable it.
*
* @default false
*/
ServiceProperty& reverse_mode(bool reverse_mode)
{
reverse_mode_ = reverse_mode;
return *this;
}
/*i
* @brief Internal use only
*/
XmlConverterRoleKind xml_converter_role() const
{
return xml_converter_role_;
}
/*i
* @brief Internal use only
*/
ServiceProperty& xml_converter_role(
const XmlConverterRoleKind & xml_converter_role)
{
xml_converter_role_ = xml_converter_role;
return *this;
}
/*i
* @brief The indexer application mode. Defined by the IndexerModeKind.
* Internal use only
*/
IndexerModeKind indexer_mode() const
{
return indexer_mode_;
}
/*i
* @brief Set the indexer application mode. Defined by the IndexerModeKind.
* Internal use only
*/
ServiceProperty& indexer_mode(const IndexerModeKind& indexer_mode)
{
indexer_mode_ = indexer_mode;
return *this;
}
/*i
* @brief The indexer database directory.
* Internal use only
*/
const std::string& db_directory() const
{
return db_directory_;
}
/*i
* @brief Set the indexer database directory.
* Internal use only
*/
ServiceProperty& db_directory(const std::string& db_directory)
{
db_directory_ = db_directory;
return *this;
}
/**
* @brief Getter (see setter with the same name)
*/
const PropertySet& user_environment() const
{
return user_env_;
}
/**
* @brief Non-const getter for modification that can be used to add
* elements individually. (see setter with the same name)
*/
PropertySet& user_environment()
{
return user_env_;
}
/**
* @brief Dictionary of user variables.
* The dictionary provides a parallel way to expand XML configuration
* variables in the form $(my_var), when they are not defined in the
* environment.
*
* @default empty
*/
ServiceProperty& user_environment(const PropertySet& user_environment)
{
user_env_ = user_environment;
return *this;
}
private:
std::string cfg_file_;
//std::string cfg_strings[] ?
std::string service_name_;
std::string application_name_;
int32_t domain_id_base_;
bool enable_administration_;
int32_t administration_domain_id_;
bool enable_monitoring_;
int32_t monitoring_domain_id_;
ApplicationRoleKind application_role_;
bool enforce_xsd_validation_;
bool ignore_default_files_;
std::string license_file_;
// Specific to XML conversion
std::string output_cfg_file_;
bool debug_mode_;
bool reverse_mode_;
XmlConverterRoleKind xml_converter_role_;
IndexerModeKind indexer_mode_;
std::string db_directory_;
PropertySet user_env_;
};
} } /* namespace rti::recording */
#endif /* HPP_SERVICE_SERVICEPROPERTY_HPP_ */
@@ -0,0 +1,13 @@
#ifndef RTI_RECORDING_STREAM_INFO_HPP_
#define RTI_RECORDING_STREAM_INFO_HPP_
#include <rti/routing/StreamInfo.hpp>
namespace rti { namespace recording {
typedef rti::routing::StreamInfo StreamInfo;
}}
#endif /* RTI_RECORDING_STREAM_INFO_HPP_ */
@@ -0,0 +1,72 @@
/*
* (c) Copyright, Real-Time Innovations, 2017.
* All rights reserved.
*
* No duplications, whole or partial, manual or electronic, may be made
* without express written permission. Any such copies, or
* revisions thereof, must display this notice unaltered.
* This code contains trade secrets of Real-Time Innovations, Inc.
*/
#ifndef RTI_RECORDING_RECORDING_SERVICE_IMPL_HPP_
#define RTI_RECORDING_RECORDING_SERVICE_IMPL_HPP_
#include "recordingservice/recordingservice_dll.h"
#include <dds/core/refmacros.hpp>
#include <rti/core/detail/SelfReference.hpp>
#include <rti/idlgen/ServiceAdmin.hpp>
#include <rti/recording/ServiceProperty.hpp>
#include <rti/routing/detail/ShutdownHookForwarder.hpp>
namespace rti { namespace recording {
namespace service {
class Service;
}
namespace detail {
typedef rti::routing::detail::AbstractShutdownHookForwarder
AbstractShutdownHookForwarder;
}
class Application;
class RECORDERDllExport RecordingServiceImpl
: public rti::core::detail::RetainableType<RecordingServiceImpl> {
public:
typedef RTI::Service::Admin::CommandRequest CommandRequest;
typedef RTI::Service::Admin::CommandReply CommandReply;
explicit RecordingServiceImpl(const ServiceProperty& property);
RecordingServiceImpl(
const ServiceProperty& property,
detail::AbstractShutdownHookForwarder *hook_forwarder);
~RecordingServiceImpl();
void start();
void stop();
CommandReply execute_command(const CommandRequest& request);
CommandReply& execute_command(
CommandReply& reply,
const CommandRequest& request);
private:
friend class rti::recording::Application;
rti::recording::service::Service *impl_;
detail::AbstractShutdownHookForwarder *shutdown_forwarder_fwd_;
};
}}
#endif // RTI_RECORDING_RECORDING_SERVICE_IMPL_HPP_
@@ -0,0 +1,145 @@
/*
* (c) Copyright, Real-Time Innovations, 2016-.
* All rights reserved.
* No duplications, whole or partial, manual or electronic, may be made
* without express written permission. Any such copies, or
* revisions thereof, must display this notice unaltered.
* This code contains trade secrets of Real-Time Innovations, Inc.
*/
#ifndef HPP_RTI_RECORDING_STORAGE_ESTORAGEFORMAT_HPP_
#define HPP_RTI_RECORDING_STORAGE_ESTORAGEFORMAT_HPP_
#include <stdint.h>
#include "reda/reda_string.h"
#include "dds_c/dds_c_infrastructure.h"
#include "dds/core/Exception.hpp"
namespace rti { namespace recording { namespace storage {
class EStorageFormat {
public:
static const DDS_DataRepresentationId_t INVALID_REPRESENTATION =
static_cast<DDS_DataRepresentationId_t>(
RTI_CDR_ENCAPSULATION_ID_INVALID);
static const EStorageFormat XCDR() {
static const EStorageFormat XCDR(
0,
"XCDR",
DDS_XCDR_DATA_REPRESENTATION);
return XCDR;
}
static const EStorageFormat XCDR2() {
static const EStorageFormat XCDR2(
1,
"XCDR2",
DDS_XCDR2_DATA_REPRESENTATION);
return XCDR2;
}
static const EStorageFormat XCDR_AUTO() {
static const EStorageFormat XCDR_AUTO(
2,
"XCDR_AUTO",
DDS_AUTO_DATA_REPRESENTATION);
return XCDR_AUTO;
}
static const EStorageFormat JSON_SQLITE() {
static const EStorageFormat JSON_SQLITE(
3,
"JSON_SQLITE",
INVALID_REPRESENTATION);
return JSON_SQLITE;
}
/**
* This format is only used by the legacy DB plugins, for the moment.
*/
static const EStorageFormat DESERIALIZED() {
static const EStorageFormat DESERIALIZED(
4,
"DESERIALIZED",
INVALID_REPRESENTATION);
return DESERIALIZED;
}
static EStorageFormat from_string_ignore_case(const std::string& value)
{
if (REDAString_iCompare(
value.c_str(),
XCDR().enum_value().c_str()) == 0) {
return XCDR();
} else if (REDAString_iCompare(
value.c_str(),
XCDR2().enum_value().c_str()) == 0) {
return XCDR2();
} else if (REDAString_iCompare(
value.c_str(),
XCDR_AUTO().enum_value().c_str()) == 0) {
return XCDR_AUTO();
} else if (REDAString_iCompare(
value.c_str(),
JSON_SQLITE().enum_value().c_str()) == 0) {
return JSON_SQLITE();
} else {
throw dds::core::UnsupportedError(
"Unrecognized DB Format value, must be one of "
"{XCDR,XCDR2,XCDR_AUTO,JSON_SQLITE}");
}
}
EStorageFormat(const EStorageFormat& other)
: enum_value_(other.enum_value_),
enum_string_(other.enum_string_),
data_rep_id_(other.data_rep_id_){}
void operator =(const EStorageFormat& other)
{
enum_value_ = other.enum_value_;
enum_string_ = other.enum_string_;
data_rep_id_ = other.data_rep_id_;
}
bool operator ==(const EStorageFormat& other) const
{
return enum_value_ == other.enum_value_;
}
bool operator !=(const EStorageFormat& other) const
{
return enum_value_ != other.enum_value_;
}
uint32_t value() const { return enum_value_; }
const std::string& enum_value() const { return enum_string_; }
/**
* This function returns the associated data representation when it applies.
* In the cases it doesn't, it returns the value INVALID_REPRESENTATION
*/
DDS_DataRepresentationId_t data_representation() const
{
return data_rep_id_;
}
private:
uint32_t enum_value_;
std::string enum_string_;
DDS_DataRepresentationId_t data_rep_id_;
EStorageFormat(
const uint32_t value,
const std::string& enum_string,
const DDS_DataRepresentationId_t rep_id) :
enum_value_(value),
enum_string_(enum_string),
data_rep_id_(rep_id) {}
};
} } } /* namespace rti::recording::storage */
#endif /* HPP_RTI_RECORDING_STORAGE_ESTORAGEFORMAT_HPP_ */
@@ -0,0 +1,250 @@
/*
* (c) Copyright, Real-Time Innovations, 2018-.
* All rights reserved.
* No duplications, whole or partial, manual or electronic, may be made
* without express written permission. Any such copies, or
* revisions thereof, must display this notice unaltered.
* This code contains trade secrets of Real-Time Innovations, Inc.
*/
#ifndef HPP_RTI_RECORDING_STORAGE_SAMPLESELECTOR_HPP_
#define HPP_RTI_RECORDING_STORAGE_SAMPLESELECTOR_HPP_
#include "dds/dds.hpp"
#include "rti/core/NativeValueType.hpp"
#include "rti/core/constants.hpp"
#include "rti/apputils/util/Utils.hpp"
#include "recordingservice/recordingservice_storagereader.h"
namespace rti { namespace recording { namespace storage {
class SelectorState;
/**
* Adapter class for the native type RTI_RecordingServiceSelectorState.
*/
class SelectorStateAdapter {
public:
typedef RTI_RecordingServiceSelectorState native_type;
static void initialize(native_type& native_value)
{
RTI_RecordingServiceSelectorState native_state =
RTI_RecordingServiceSelectorState_INITIALIZER;
memcpy(&native_value, &native_state, sizeof(native_state));
}
static void finalize(native_type&)
{
}
static void copy(native_type& destination, const native_type& source)
{
destination.sample_state = source.sample_state;
destination.time_range_start = source.time_range_start;
destination.time_range_end = source.time_range_end;
destination.max_samples = source.max_samples;
destination.instance_history = source.instance_history;
}
static bool equals(const native_type& first, const native_type& second)
{
if (first.sample_state != second.sample_state) {
return false;
}
if (first.max_samples != second.max_samples) {
return false;
}
if (!DDS_Time_t_equals(
first.time_range_start,
second.time_range_start)) {
return false;
}
if (!DDS_Time_t_equals(
first.time_range_end,
second.time_range_end)) {
return false;
}
return first.instance_history.depth == second.instance_history.depth;
}
};
} }
/*
* Type native_type_traits needs to be defined in the rti::core namespace.
*/
namespace core {
template <>
struct native_type_traits<rti::recording::storage::SelectorState> {
typedef rti::recording::storage::SelectorStateAdapter adapter_type;
typedef RTI_RecordingServiceSelectorState native_type;
};
}
namespace recording { namespace storage {
/** \ingroup RTI_RecordingServiceStorageModule
*
* @brief This class is used by \replay_product or \converter_product when
* asking the storage plugin for data. It specifies whether the samples should
* be 'not read' samples, that haven't been returned before, or that 'any'
* sample state is needed. It also allows to specify the time range the samples
* returned have to lay within (upper and lower limit).
*/
class SelectorState : public rti::core::NativeValueType<SelectorState> {
public:
RTI_NATIVE_VALUE_TYPE_DEFINE_DEFAULT_MOVE_OPERATIONS(SelectorState)
typedef rti::core::NativeValueType<SelectorState> Base;
SelectorState()
{
}
SelectorState(const RTI_RecordingServiceSelectorState &native) :
Base(native)
{
}
/**
* @brief Returns the sample state. This is used to represent the state of
* the samples asked for, whether they have been already read or not.
* When this value is set to:
* - Not read: the storage plugin should provide samples that hasn't
* provided before. This implies that the storage plugin has to
* keep track of what samples it has already returned and what
* samples it hasn't.
* - Any: the storage plugin should provide all the samples within
* the specified time range, no matter their read state. This
* implies a stateless read, the storage plugin is not supposed to
* keep track of what samples have been read or not in this case.
* - Read: in the current version, this sample state is not used by
* \replay_product or \converter_product.
*/
inline dds::sub::status::SampleState sample_state() const
{
return dds::sub::status::SampleState(native().sample_state);
}
/**
* @brief Sets the sample state.
*/
SelectorState& sample_state(const dds::sub::status::SampleState& state)
{
native().sample_state =
static_cast<RTI_RecordingServiceSampleStateMask>(
state.to_ulong());
return *this;
}
/**
* @brief Returns the time that represents the lower limit (inclusive) of
* the time range the retrieved data samples should lay within. When
* retrieving stateful samples (not read), this parameter becomes
* irrelevant as the lower limit should be the time-stamp of the
* latest sample returned.
*/
inline dds::core::Time time_range_start() const
{
return dds::core::Time(
native().time_range_start.sec,
native().time_range_start.nanosec);
}
/**
* @brief Like the time_range_start() method, but returns the timestamp in
* long long (int-64) format
*/
inline int64_t timestamp_range_start() const
{
return rti::apputils::util::convert_uint64_into_int64(
rti::apputils::util::to_nanosecs(time_range_start()));
}
/**
* @brief Sets the lower limit of the time range.
*/
SelectorState& time_range_start(const dds::core::Time& time_range_start)
{
native().time_range_start.sec = time_range_start.sec();
native().time_range_start.nanosec =
(DDS_UnsignedLong) time_range_start.nanosec();
return *this;
}
/**
* @brief Returns the time that represents the upper limit (inclusive) of
* the time range the retrieved samples should lay within. This
* parameter is always relevant, as samples should be returned in
* increasing time-stamp order.
*/
inline dds::core::Time time_range_end() const
{
return dds::core::Time(
native().time_range_end.sec,
native().time_range_end.nanosec);
}
/**
* @brief Like the time_range_end() method, but returns the timestamp in
* long long (int-64) format
*/
inline int64_t timestamp_range_end() const
{
return rti::apputils::util::convert_uint64_into_int64(
rti::apputils::util::to_nanosecs(time_range_end()));
}
/**
* @brief Sets the upper limit of the time range.
*/
SelectorState& time_range_end(const dds::core::Time& time_range_end)
{
native().time_range_end.sec = time_range_end.sec();
native().time_range_end.nanosec =
static_cast<DDS_UnsignedLong>(time_range_end.nanosec());
return *this;
}
/**
* @brief Returns the maximum number of samples to be returned by a single
* read() call, when the value is positive.
* A negative value indicates an unlimited number of samples.
*/
inline int32_t max_samples() const
{
return native().max_samples;
}
/**
* @brief Sets the maximum number of samples to be returned by a single call
* to read().
*/
SelectorState& max_samples(const int32_t max_samples)
{
native().max_samples = (int) max_samples;
return *this;
}
inline int32_t instance_history_depth() const
{
return native().instance_history.depth;
}
SelectorState& instance_history_depth(const int32_t depth)
{
native().instance_history.depth = (int) depth;
return *this;
}
};
} } } /* namespace rti::recording::storage */
#endif /* HPP_RTI_RECORDING_STORAGE_SAMPLESELECTOR_HPP_ */
@@ -0,0 +1,251 @@
/*
* (c) Copyright, Real-Time Innovations, 2018-.
* All rights reserved.
* No duplications, whole or partial, manual or electronic, may be made
* without express written permission. Any such copies, or
* revisions thereof, must display this notice unaltered.
* This code contains trade secrets of Real-Time Innovations, Inc.
*/
#ifndef HPP_RTI_RECORDING_STORAGE_STORAGEDEFS_HPP_
#define HPP_RTI_RECORDING_STORAGE_STORAGEDEFS_HPP_
#include <sstream>
#include <memory>
#ifndef dds_c_builtin_h
#include "dds_c/dds_c_builtin.h"
#endif
#include <rti/core/Exception.hpp>
#include "rti/recording/PropertySet.hpp"
#include "recordingservice/recordingservice_storagereader.h"
#include "recordingservice/recordingservice_storagewriter.h"
namespace rti { namespace recording {
// Writer-related defines
typedef std::shared_ptr<RTI_RecordingServiceStorageWriter>
StorageWriterSharedPtr;
typedef std::shared_ptr<RTI_RecordingServiceStorageStreamWriter>
StorageStreamWriterSharedPtr;
typedef std::shared_ptr<RTI_RecordingServiceStorageParticipantWriter>
StorageParticipantWriterSharedPtr;
typedef std::shared_ptr<RTI_RecordingServiceStoragePublicationWriter>
StoragePublicationWriterSharedPtr;
typedef std::shared_ptr<RTI_RecordingServiceStorageSubscriptionWriter>
StorageSubscriptionWriterSharedPtr;
// Reader-related defines
typedef std::shared_ptr<RTI_RecordingServiceStorageReader>
StorageReaderSharedPtr;
typedef std::shared_ptr<RTI_RecordingServiceStorageStreamReader>
StorageStreamReaderSharedPtr;
typedef std::shared_ptr<RTI_RecordingServiceStorageStreamInfoReader>
StorageStreamInfoReaderSharedPtr;
/*
* Helper classes to be used with the pointer definitions above, to create the
* smart pointers and use this class as a deleter (pointing to the () operator)
*/
class NativeStorageStreamWriterDeleter {
public:
NativeStorageStreamWriterDeleter(
RTI_RecordingServiceStorageWriter *storage_writer_parent)
: storage_writer_parent_(storage_writer_parent)
{
RTI_CHECK_PRECONDITION(storage_writer_parent != NULL);
}
void operator ()(RTI_RecordingServiceStorageStreamWriter *instance)
{
if (instance != NULL) {
storage_writer_parent_->delete_stream_writer(
storage_writer_parent_,
instance);
}
}
void operator ()(RTI_RecordingServiceStorageParticipantWriter *instance)
{
// The delete participant writer operation is not required, better be
// safe than sorry
if (instance != NULL
&& storage_writer_parent_->delete_participant_writer != NULL) {
storage_writer_parent_->delete_participant_writer(
storage_writer_parent_,
instance);
}
}
void operator ()(RTI_RecordingServiceStoragePublicationWriter *instance)
{
// The delete publication writer operation is not required, better be
// safe than sorry
if (instance != NULL
&& storage_writer_parent_->delete_publication_writer != NULL) {
storage_writer_parent_->delete_publication_writer(
storage_writer_parent_,
instance);
}
}
void operator ()(RTI_RecordingServiceStorageSubscriptionWriter *instance)
{
// The delete subscription writer operation is not required, better be
// safe than sorry
if (instance != NULL
&& storage_writer_parent_->delete_subscription_writer != NULL) {
storage_writer_parent_->delete_subscription_writer(
storage_writer_parent_,
instance);
}
}
private:
RTI_RecordingServiceStorageWriter *storage_writer_parent_;
};
class NativeStorageStreamInfoReaderDeleter {
public:
NativeStorageStreamInfoReaderDeleter(
RTI_RecordingServiceStorageReader *storage_reader_parent)
: storage_reader_parent_(storage_reader_parent)
{
RTI_CHECK_PRECONDITION(storage_reader_parent != NULL);
}
void operator ()(RTI_RecordingServiceStorageStreamInfoReader *instance)
{
if (instance != NULL) {
storage_reader_parent_->delete_stream_info_reader(
storage_reader_parent_,
instance);
}
}
private:
RTI_RecordingServiceStorageReader *storage_reader_parent_;
};
class NativeStorageStreamReaderDeleter {
public:
NativeStorageStreamReaderDeleter(
RTI_RecordingServiceStorageReader *storage_reader_parent)
: storage_reader_parent_(storage_reader_parent)
{
RTI_CHECK_PRECONDITION(storage_reader_parent != NULL);
}
void operator ()(RTI_RecordingServiceStorageStreamReader *instance)
{
if (instance != NULL) {
storage_reader_parent_->delete_stream_reader(
storage_reader_parent_,
instance);
}
}
private:
RTI_RecordingServiceStorageReader *storage_reader_parent_;
};
inline bool is_discovery_stream(const std::string& stream_name)
{
if (stream_name.compare(DDS_PARTICIPANT_TOPIC_NAME) == 0
|| stream_name.compare(DDS_PUBLICATION_TOPIC_NAME) == 0
|| stream_name.compare(DDS_SUBSCRIPTION_TOPIC_NAME) == 0) {
return true;
}
return false;
}
inline std::string domain_id_property_name()
{
return RTI_RECORDING_SERVICE_DOMAIN_ID_PROPERTY_NAME;
}
inline std::string start_timestamp_property_name()
{
return RTI_RECORDING_SERVICE_START_TIMESTAMP_PROPERTY_NAME;
}
inline std::string end_timestamp_property_name()
{
return RTI_RECORDING_SERVICE_END_TIMESTAMP_PROPERTY_NAME;
}
inline std::string jump_timestamp_property_name()
{
return RTI_RECORDING_SERVICE_JUMP_TIMESTAMP_PROPERTY_NAME;
}
inline std::string sample_order_property_name()
{
return RTI_RECORDING_SERVICE_PLAYBACK_SAMPLE_ORDER_PROPERTY_NAME;
}
inline std::string reverse_mode_property_name()
{
return RTI_RECORDING_SERVICE_PLAYBACK_REVERSE_MODE_PROPERTY_NAME;
}
template <typename T>
inline T get_from_properties(
const rti::recording::PropertySet& properties,
const std::string& property_name)
{
rti::recording::PropertySet::const_iterator found =
properties.find(property_name);
if (found == properties.end()) {
throw dds::core::Error(
"!found property with name=" + property_name);
}
T value;
std::stringstream str_stream(found->second);
str_stream >> value;
if (str_stream.fail()) {
throw dds::core::Error(
"!parse value from property with name=" + property_name);
}
return value;
}
template <typename T>
inline void add_to_properties(
rti::recording::PropertySet& properties,
const std::string& property_name,
const T value)
{
rti::recording::PropertySet::const_iterator found =
properties.find(property_name);
if (found != properties.end()) {
return;
}
std::stringstream str_stream;
str_stream << value;
if (str_stream.fail()) {
throw dds::core::Error(
"!add value for property with name=" + property_name);
}
properties[property_name] = str_stream.str();
}
namespace detail {
#define RecorderPrint_exception(...) \
RTILogMessage_print( \
RTI_LOG_PRINT_FORMAT_MASK_ALL, \
RTI_LOG_BIT_EXCEPTION, \
MODULE_RECORDER, \
__VA_ARGS__)
} /* namespace rti::recording::detail */
} } /* namespace rti::recording */
#endif /* HPP_RTI_RECORDING_STORAGE_STORAGEDEFS_HPP_ */
@@ -0,0 +1,56 @@
/*
* (c) Copyright, Real-Time Innovations, 2018-.
* All rights reserved.
* No duplications, whole or partial, manual or electronic, may be made
* without express written permission. Any such copies, or
* revisions thereof, must display this notice unaltered.
* This code contains trade secrets of Real-Time Innovations, Inc.
*/
#ifndef RTI_RECORDING_STORAGE_STORAGEDISCOVERYSTREAMWRITER_HPP_
#define RTI_RECORDING_STORAGE_STORAGEDISCOVERYSTREAMWRITER_HPP_
#include <vector>
#include "dds/dds.hpp"
#include "rti/recording/storage/StorageStreamWriter.hpp"
#include "rti/routing/detail/ForwarderUtils.hpp"
namespace rti { namespace recording { namespace storage {
/** \ingroup RTI_RecordingServiceStorageModule
*
* @brief Convenience definition of typed StorageStreamWriter that requires
* dds::core::xtypes::DynamicData for data samples and dds::sub::SampleInfo
* for info samples.
*
*/
typedef TStorageStreamWriter<
dds::topic::ParticipantBuiltinTopicData,
dds::sub::SampleInfo> ParticipantStorageWriter;
/** \ingroup RTI_RecordingServiceStorageModule
* @brief Convenience definition of typed StorageStreamWriter that requires
* dds::core::xtypes::DynamicData for data samples and dds::sub::SampleInfo
* for info samples.
*
*/
typedef TStorageStreamWriter<
dds::topic::PublicationBuiltinTopicData,
dds::sub::SampleInfo> PublicationStorageWriter;
/** \ingroup RTI_RecordingServiceStorageModule
* @brief Convenience definition of typed StorageStreamWriter that requires
* dds::core::xtypes::DynamicData for data samples and dds::sub::SampleInfo
* for info samples.
*
*/
typedef TStorageStreamWriter<
dds::topic::SubscriptionBuiltinTopicData,
dds::sub::SampleInfo> SubscriptionStorageWriter;
} } } // namespace rti::recording::storage
#endif /* RTI_RECORDING_STORAGE_STORAGEDISCOVERYSTREAMWRITER_HPP_ */
@@ -0,0 +1,239 @@
/*
* (c) Copyright, Real-Time Innovations, 2018-.
* All rights reserved.
* No duplications, whole or partial, manual or electronic, may be made
* without express written permission. Any such copies, or
* revisions thereof, must display this notice unaltered.
* This code contains trade secrets of Real-Time Innovations, Inc.
*/
#ifndef HPP_RECORDER_DB_REPLAYPLUGIN_HPP_
#define HPP_RECORDER_DB_REPLAYPLUGIN_HPP_
#include "dds/dds.hpp"
#include "rti/recording/PropertySet.hpp"
#include "rti/recording/StreamInfo.hpp"
#include "StorageStreamInfoReader.hpp"
#include "rti/recording/storage/StorageStreamReader.hpp"
/** @file
* @brief \product Pluggable Storage Reader API
*
* These APIs define a plugin that can be used by \replay_product and
* \converter_product to retrieve data from storage.
*/
/**
* @brief The RTI namespace.
*
*/
namespace rti {
/**
* @brief The \product namespace.
*
* The \product namespace includes all public classes of \product
*/
namespace recording {
/**
* @brief The \product storage namespace.
*
* The \product namespace includes all classes needed to plug in custom storage.
*/
namespace storage {
/** \ingroup RTI_RecordingServiceStorageModule
* class rti::recording::storage::StorageReader
* @brief Storage reader
*
* This class creates and deletes:
* - StreamInfoReaders, that will be used to query discovery data from
* storage and provide it to \replay_product and \converter_product
* - StreamReaders, that will be used to query user data from storage and
* provide it to \replay_product and \converter_product
*/
class StorageReader {
public:
typedef void* SampleType;
typedef void* InfoType;
typedef std::vector<SampleType> SampleSeqType;
typedef std::vector<InfoType> InfoSeqType;
/**
* @memberof rti::recording::storage::StorageReader
* @brief Constructor.
*
* Creates a StorageReader object.
*
* @param properties Routing Service PropertySet. Contains name/value
* pairs that can be passed to the plugin in the XML, using the
* following snippet:
\verbatim
<replay_service name="ExampleReplay>
<storage>
<plugin plugin_name="StorageLibrary::ExamplePlugin">
<!-- Storage properties. These are passed to the plugin in the
plugin_library -->
<property>
<value>
<element>
<name>example.filename</name>
<value>PluggableStorage.dat</value>
</element>
</value>
</property>
</plugin>
</storage>
</replay_service>
\endverbatim
*/
StorageReader(const rti::recording::PropertySet& properties)
{
RTI_UNUSED_PARAMETER(properties);
}
/**
* @brief Virtual destructor
*/
virtual ~StorageReader()
{
}
/**
* @brief \replay_product calls this to create a stream in charge of
* discovering information about the available user-data streams in the
* storage, and read them.
*
* @param properties A collection of name-value properties. They include
* some built-in values, like:
* 1) name='rti.recording_service.start_timestamp'
* value=the initial timestamp of the selected time range (64-bit
* integer in text format) for this stream info reader to query
* data
* 2) name='rti.recording_service.end_timestamp'
* value=the final timestamp of the selected time range (64-bit
* integer in text format) for this stream info reader to query
* data
* 3) name='rti.recording_service.playback_settings.sample_order'
* value=the sample order (enum label in text format) for this
* stream info reader to query data.
* The possible values are: RECEPTION_TIMESTAMP, SOURCE_TIMESTAMP.
* 4) name='rti.recording_service.playback_settings.reverse_mode'
* value= the status of the reverse mode (ENABLED or DISABLED)
* for this stream info reader to query data.
* The possible values are: true, false.
*/
virtual StorageStreamInfoReader * create_stream_info_reader(
const rti::recording::PropertySet& properties) = 0;
/**
* @brief \replay_product calls this to delete a stream information reader
*
* @param stream_info_reader Stream information reader to be deleted.
*/
virtual void delete_stream_info_reader(
StorageStreamInfoReader *stream_info_reader) = 0;
/**
* @brief \replay_product calls this to create a user-data stream reader.
*
* @param stream_info Information about the stream (DDS topic) this stream
* reader will query from the database.
* @param properties A collection of name-value properties. They include
* some built-in values, like:
* 1) name='rti.recording_service.domain_id'
* value=the DDS domain ID the stream was found in (32-bit integer
* as text)
* 2) name='rti.recording_service.start_timestamp'
* value=the initial timestamp of the selected time range (64-bit
* integer in text format) for this stream info reader to query
* data
* 3) name='rti.recording_service.end_timestamp'
* value=the final timestamp of the selected time range (64-bit
* integer in text format) for this stream info reader to query
* data
* 4) name='rti.recording_service.playback_settings.sample_order'
* value=the sample order (enum label in text format) for this
* stream info reader to query data.
* The possible values are: RECEPTION_TIMESTAMP, SOURCE_TIMESTAMP.
* 5) name='rti.recording_service.playback_settings.reverse_mode'
* value= the status of the reverse mode (ENABLED or DISABLED)
* for this stream info reader to query data.
* The possible values are: true, false.
*/
virtual StorageStreamReader * create_stream_reader(
const rti::recording::StreamInfo& stream_info,
const rti::recording::PropertySet& properties) = 0;
/**
* @brief \replay_product calls this to delete a stream reader.
*
* @param stream_reader Stream reader to be deleted.
*/
virtual void delete_stream_reader(StorageStreamReader *stream_reader) = 0;
private:
StorageReader() {}
};
} } } /* namespace rti::recording::storage */
#include "rti/recording/storage/detail/StorageReaderForwarder.hpp"
#include "rti/routing/ServiceProperty.hpp"
#include "rti/routing/detail/ForwarderUtils.hpp"
/** \ingroup RTI_RecordingServiceStorageModule
* @def RTI_RECORDING_STORAGE_READER_CREATE_DECL
* @brief Convenience macro to declare the C-style function that will be called
* by \replay_product and \converter_product to create your class
*
* This macro automatically declares a C wrapper function for your class
* creation. \replay_product and \converter_product must be initialized
* with the name of this function. For example if your StorageReader class is
* 'FileStorageReader' this creates wrapper function called
* 'FileStorageReader_get_storage_reader' that you must specify in your XML
* file, such as:
*
* \verbatim
<plugin_library name="StorageLibrary">
<storage_plugin name="ExamplePlugin">
<dll>FileStorageReader</dll>
<create_function>FileStorageReader_get_storage_reader</create_function>
</storage_plugin>
</plugin_library>
\endverbatim
*/
#define RTI_RECORDING_STORAGE_READER_CREATE_DECL(STORAGE_READER_CLASS) \
extern "C" RTI_USER_DLL_EXPORT \
struct RTI_RecordingServiceStorageReader * \
STORAGE_READER_CLASS ## _get_storage_reader( \
const struct RTI_RoutingServiceProperties *);
/** \ingroup RTI_RecordingServiceStorageModule
* @brief Convenience macro to implement the C-style function that will be
* called by \replay_product and \converter_product to create your class
*
* This macro automatically defines a C wrapper function for your class
* creation. \replay_product and \converter_product must be initialized
* with the name of this function.
*/
#define RTI_RECORDING_STORAGE_READER_CREATE_DEF(STORAGE_READER_CLASS) \
struct RTI_RecordingServiceStorageReader * \
STORAGE_READER_CLASS ## _get_storage_reader( \
const struct RTI_RoutingServiceProperties *native_properties) \
{ \
rti::recording::PropertySet properties; \
rti::routing::PropertyAdapter::add_properties_from_native( \
properties, \
native_properties); \
return new rti::recording::storage::detail::StorageReaderForwarder( \
new STORAGE_READER_CLASS(properties)); \
}
#endif /* HPP_RECORDER_DB_REPLAYPLUGIN_HPP_ */
@@ -0,0 +1,110 @@
/******************************************************************************
* (c) Copyright, Real-Time Innovations, 2016-.
* All rights reserved.
* No duplications, whole or partial, manual or electronic, may be made
* without express written permission. Any such copies, or
* revisions thereof, must display this notice unaltered.
* This code contains trade secrets of Real-Time Innovations, Inc.
*****************************************************************************/
#ifndef HPP_RTI_RECORDING_STORAGE_DISCOVERYSTREAMREADER_HPP_
#define HPP_RTI_RECORDING_STORAGE_DISCOVERYSTREAMREADER_HPP_
#include "dds/dds.hpp"
#include "rti/recording/StreamInfo.hpp"
#include "SelectorState.hpp"
namespace rti { namespace recording { namespace storage {
/** \ingroup RTI_RecordingServiceStorageModule
* class rti::recording::storage::StorageStreamInfoReader
* @brief Storage discovery stream reader
*
* This class is used by the \replay_product and \converter_product to query
* the contents of storage to be replayed or converted, including:
* - The names of streams that are stored, and their associated type
* representations, when recorded.
* - The domain IDs associated with those streams.
* - The first and last timestamps in the stored data.
*/
class StorageStreamInfoReader {
public:
/**
* @brief Virtual destructor
*
*/
virtual ~StorageStreamInfoReader() {}
/**
* @brief Retrieve stream information data from storage. This operation
* should behave differently depending on the product's needs, stated in the
* SelectorState object passed as a parameter. The stream info samples have
* to be provided in increasing time-stamp order (reception time-stamp).
*
* \replay_product and \converter_product will call this method to
* retrieve discovery data from the plugins. Discovery data describes which
* streams are available from storage.
*
* @param sample_seq Vector of SampleType data. A SampleType is
* an rti::recording::StreamInfo.
* @param selector Provides the statefulness and constraints of the data
* queried by \replay_product or \converter_product. When the
* selector's sample state is set to 'any', it means its asking for
* stateless information (it doesn't care whether the data has been
* read before or not). When the selector's sample state is set to
* 'not read' then it's a stateful read, and only samples that
* weren't given to the application before have to be provided.
* Note: for the moment, \replay_product or
* \converter_product won't ask for data with sample state equal to
* 'read', so this state can be ignored.
*
* When Replay Service is on reverse mode, it will set the selector's
* start timestamp to 0. In this mode, Replay Service will burst all
* the discovery information at the beginning of the replay.
* After this burst of samples, the discovery stream reader will wait
* until the end of the replay.
*/
virtual void read(
std::vector<rti::recording::StreamInfo *>& sample_seq,
const SelectorState& selector) = 0;
/**
* @brief Notifies plugin it can release the read stream information objects
*
* @param sample_seq A vector of stream info objects that the plugin can
* now release resources for.
*/
virtual void return_loan(
std::vector<rti::recording::StreamInfo *>& sample_seq) = 0;
/**
* @brief The time within the recorded time range that can be considered
* time zero of the recording
*/
virtual int64_t service_start_time() = 0;
/**
* @brief The time relative to the recorded time range that can be
* considered the final recording time of the recording
*/
virtual int64_t service_stop_time() = 0;
/**
* @brief Whether this discovery stream has finished with all discovery data
* or not.
*/
virtual bool finished() = 0;
/**
* @brief Method used by \replay_product when looping, to start over. After
* this method is called, the stream reader should be ready to start reading
* data from the beginning of the stream, again.
*/
virtual void reset() = 0;
};
} } } /* namespace rti::recording::storage */
#endif /* HPP_RTI_RECORDING_STORAGE_DISCOVERYSTREAMREADER_HPP_ */
@@ -0,0 +1,199 @@
/*
* (c) Copyright, Real-Time Innovations, 2017-.
* All rights reserved.
* No duplications, whole or partial, manual or electronic, may be made
* without express written permission. Any such copies, or
* revisions thereof, must display this notice unaltered.
* This code contains trade secrets of Real-Time Innovations, Inc.
*
*/
#ifndef HPP_RTI_RECORDING_STORAGE_STREAMREADER_HPP_
#define HPP_RTI_RECORDING_STORAGE_STREAMREADER_HPP_
#include <vector>
#include "dds/dds.hpp"
#include "rti/routing/detail/ForwarderUtils.hpp"
#include "rti/recording/storage/SelectorState.hpp"
namespace rti { namespace recording { namespace storage {
/** \ingroup RTI_RecordingServiceStorageModule
* class rti::recording::storage::StorageStreamReader
* @brief Storage stream reader
*
* This class retrieves user data from storage.
*/
class StorageStreamReader {
public:
typedef void* SamplePtr;
typedef void* InfoPtr;
/**
* @brief Virtual destructor
*/
virtual ~StorageStreamReader()
{
}
/**
* @brief Method called by \replay_product and \converter_product
* to retrieve samples from storage for a particular stream
* (DDS topic). The data samples retrieved have to be provided in
* increasing time-stamp order (reception time-stamp).
*
* @param sample_seq A vector of data samples that \replay_product or
* \converter_product will replay or convert to a new format.
* A SampleType is a DDS_DynamicData * cast as a void *
* @param info_seq A vector of sample information about the samples,
* such as recorded timestamps of the sample data. An InfoType is
* a DDS_SampleInfo * cast as a void *.
* @param selector Provides the statefulness and constraints of the data
* queried by \replay_product or \converter_product. When the
* selector's sample state is set to 'any', it means its asking for
* stateless information (it doesn't care whether the data has been
* read before or not). When the selector's sample state is set to
* 'not read' then it's a stateful read, and only samples that
* weren't given to the application before have to be provided.
* Note: for the moment, \replay_product or
* \converter_product won't ask for data with sample state equal to
* 'read', so this state can be ignored.
*
* When the selector's start timestamp is set to a value different
* than 0, it means that Replay Service is on a jumping process.
* The StreamReader should then prepare its statement with this
* new start timestamp. Also, if the selector's maximum samples is
* set to 0, it means that Replay Service is on a jumping breakpoint process
* instead of a standard jumping process. In this case, the StreamReader
* should also prepare the statement but it should not read any sample.
*/
virtual void read(
std::vector<SamplePtr>& sample_seq,
std::vector<InfoPtr>& info_seq,
const SelectorState& selector) = 0;
/**
* @brief Method for releasing resources related to the queried data
* samples.
*
* This is called back when the \replay_product or \converter_product has
* finished with the data samples queried in the take() function, and
* wants to notify the plugin that it can free any related resources.
*
* @param sample_seq A vector of sample objects that the plugin can
* now free.
* @param info_seq A vector of sample_info objects that the plugin can
* now free.
*
*/
virtual void return_loan(
std::vector<SamplePtr>& sample_seq,
std::vector<InfoPtr>& info_seq) = 0;
/**
* @brief Method for querying whether there are no more samples for this
* stream.
*
* @return true if there is no more data available for this stream,
* false otherwise.
*
*/
virtual bool finished() = 0;
/**
* @brief Method used by \replay_product when looping, to start over. After
* this method is called, the stream reader should be ready to start reading
* data from the beginning of the stream, again.
*/
virtual void reset() = 0;
};
/** \ingroup RTI_RecordingServiceStorageModule
* class rti::recording::storage::TStorageStreamReader
* @brief A templatized wrapping implementation of StorageStreamReader,
* providing a strongly-typed interface regarding data and info representations.
*
* You can implement this interface as a convenience to manipulate the data
* and info representation without dealing with opaque pointers.
*/
template <typename Data, typename Info>
class TStorageStreamReader : public StorageStreamReader {
public:
/**
* @brief The data type
*/
typedef Data DataRep;
/**
* @brief The info type
*/
typedef Info InfoRep;
using StorageStreamReader::read;
using StorageStreamReader::return_loan;
/**
* @brief Performs the conversion between the vector of data and info
* pointers to strongly-typed pointers.
*/
void read(
std::vector<SamplePtr>& sample_seq,
std::vector<InfoPtr>& info_seq,
const SelectorState& selector) RTI_FINAL
{
read(sample_seq_, info_seq_, selector);
RTI_ROUTING_SAMPLE_VECTOR_COPY_PTRS(sample_seq, sample_seq_);
RTI_ROUTING_SAMPLE_VECTOR_COPY_PTRS(info_seq, info_seq_);
}
/**
* @brief Performs the conversion between the vector of data and info
* pointers to strongly-typed pointers.
*/
void return_loan(
std::vector<SamplePtr>& sample_seq,
std::vector<InfoPtr>& info_seq) RTI_FINAL
{
RTI_ROUTING_SAMPLE_VECTOR_COPY_PTRS(sample_seq_, sample_seq);
RTI_ROUTING_SAMPLE_VECTOR_COPY_PTRS(info_seq_, info_seq);
return_loan(sample_seq_, info_seq_);
sample_seq_.clear();
info_seq_.clear();
}
virtual void read(
std::vector<Data *>& sample_seq,
std::vector<Info *>& info_seq,
const SelectorState& selector) = 0;
virtual void return_loan(
std::vector<Data *>& sample_seq,
std::vector<Info *>& info_seq) = 0;
/*
* @brief Virtual destructor
*/
virtual ~TStorageStreamReader() {}
private:
std::vector<Data*> sample_seq_;
std::vector<Info*> info_seq_;
};
/** \ingroup RTI_RecordingServiceStorageModule
* @brief Convenience definition of typed StorageStreamReader that requires
* dds::core::xtypes::DynamicData for data samples and dds::sub::SampleInfo
* for info samples.
*/
typedef TStorageStreamReader<
dds::core::xtypes::DynamicData,
dds::sub::SampleInfo> DynamicDataStorageStreamReader;
} } } // namespace rti::recording::storage
#endif /* HPP_RTI_RECORDING_STORAGE_STREAMREADER_HPP_ */
@@ -0,0 +1,128 @@
/*
* (c) Copyright, Real-Time Innovations, 2017-.
* All rights reserved.
* No duplications, whole or partial, manual or electronic, may be made
* without express written permission. Any such copies, or
* revisions thereof, must display this notice unaltered.
* This code contains trade secrets of Real-Time Innovations, Inc.
*/
#ifndef RTI_RECORDING_STORAGE_STORAGESTREAMWRITER_HPP_
#define RTI_RECORDING_STORAGE_STORAGESTREAMWRITER_HPP_
#include <vector>
#include "dds/dds.hpp"
#include "rti/routing/detail/ForwarderUtils.hpp"
namespace rti { namespace recording { namespace storage {
/** \ingroup RTI_RecordingServiceStorageModule
* class rti::recording::storage::StorageStreamWriter
* @brief Storage stream writer
*
* Inherit from this class and implement the store method to store data to
* the storage of your choice.
*/
class StorageStreamWriter {
public:
typedef void* SamplePtr;
typedef void* InfoPtr;
/**
* @brief Virtual destructor
*/
virtual ~StorageStreamWriter() {}
/**
* @brief Implement this method to store data in the storage of your choice.
*
* @param sample_seq Vector of SamplePtr objects containing the data to
* store. A SamplePtr is generally a DDS_DynamicData *, unless
* this is a discovery stream, in which case this is the builtin
* discovery type. Check the stream name to determine if this is a
* discovery stream.
* @param info_seq Vector of InfoType objects. An InfoType is a
* DDS_SampleInfo * cast to a void *.
*/
virtual void store(
const std::vector<SamplePtr>& sample_seq,
const std::vector<InfoPtr>& info_seq) = 0;
};
/** \ingroup RTI_RecordingServiceStorageModule
* class rti::recording::storage::TStorageStreamWriter
* @brief A templatized wrapping implementation of StorageStreamWriter,
* providing a strongly-typed interface regarding data and info representations.
*
* You can implement this interface as a convenience to manipulate the data
* and info representation without dealing with opaque pointers.
*/
template <typename Data, typename Info>
class TStorageStreamWriter : public StorageStreamWriter {
public:
/**
* @brief The data type
*/
typedef Data DataRep;
/**
* @brief The info type
*/
typedef Info InfoRep;
using StorageStreamWriter::store;
/**
* @brief Performs the conversion between the vector of data and info
* pointers to strongly-typed pointers.
*/
void store(
const std::vector<SamplePtr>& sample_seq,
const std::vector<InfoPtr>& info_seq)
{
RTI_ROUTING_SAMPLE_VECTOR_COPY_PTRS(sample_seq_, sample_seq);
RTI_ROUTING_SAMPLE_VECTOR_COPY_PTRS(info_seq_, info_seq);
store(sample_seq_, info_seq_);
}
/**
* @brief Interface redefinition
*
* @see StorageStreamWriter::store
*/
virtual void store(
const std::vector<Data *>& sample_seq,
const std::vector<Info *>& info_seq) = 0;
/**
* @brief Virtual destructor
*/
virtual ~TStorageStreamWriter()
{
}
private:
std::vector<Data *> sample_seq_;
std::vector<Info *> info_seq_;
};
/** \ingroup RTI_RecordingServiceStorageModule
* @brief Convenience definition of typed StorageStreamWriter that requires
* dds::core::xtypes::DynamicData for data samples and dds::sub::SampleInfo
* for info samples.
*
*/
typedef TStorageStreamWriter<
dds::core::xtypes::DynamicData,
dds::sub::SampleInfo> DynamicDataStorageStreamWriter;
} } } // namespace rti::recording::storage
#endif /* HPP_RTI_RECORDING_STORAGE_STORAGESTREAMWRITER_HPP_ */
@@ -0,0 +1,201 @@
/*
* (c) Copyright, Real-Time Innovations, 2016-.
* All rights reserved.
* No duplications, whole or partial, manual or electronic, may be made
* without express written permission. Any such copies, or
* revisions thereof, must display this notice unaltered.
* This code contains trade secrets of Real-Time Innovations, Inc.
*/
#include "rti/recording/PropertySet.hpp"
#include "rti/recording/StreamInfo.hpp"
#include "rti/recording/storage/StorageStreamWriter.hpp"
#include "rti/recording/storage/StorageDiscoveryStreamWriter.hpp"
#include "dds/dds.hpp"
#ifndef HPP_RTI_RECORDING_STORAGE_STORAGEWRITER_HPP_
#define HPP_RTI_RECORDING_STORAGE_STORAGEWRITER_HPP_
/** @file
* @brief \product Pluggable Storage Writer API
*
* These APIs define a plugin that can be used by \product
* to store data.
*/
namespace rti { namespace recording { namespace storage {
/** \ingroup RTI_RecordingServiceStorageModule
* class rti::recording::storage::StorageWriter
* @brief Storage writer
*
* This class is responsible for creating StorageStreamWriters when notified
* that a new stream has been discovered. A stream is defined by a Topic/type
* combination
*/
class StorageWriter {
public:
/**
* @brief Constructor.
*
* Creates a StorageWriter object.
*
* @param properties Routing Service PropertySet. Contains name/value
* pairs that can be passed to the plugin in the XML, using the
* following snippet:
\verbatim
<recording_service name="ExampleRecorder">
<storage>
<plugin plugin_name="StorageLibrary::ExamplePlugin">
<!-- Storage properties. These are passed to the plugin in the
plugin_library -->
<property>
<value>
<element>
<name>example.filename</name>
<value>PluggableStorage.dat</value>
</element>
</value>
</property>
</plugin>
</storage>
</recording_service>
\endverbatim
*/
StorageWriter(const rti::recording::PropertySet& properties)
{
RTI_UNUSED_PARAMETER(properties);
}
/**
* @brief Virtual destructor
*/
virtual ~StorageWriter() {}
/**
* @brief \product calls this to create a user-data stream writer.
* The built-in DDS discovery topics can be recorded, however,
* \product will use the create_discovery_stream_writer() call to
* obtain a stream writer for those types.
* @param stream_info Information about the stream to be created, such as
* stream name (DDS topic name).
* @param properties A collection of value-pair properties. They include
* some built-in values, like:
* 1) name='rti.recording_service.domain_id'
* value=the DDS domain ID the stream was found in (32-bit integer
* as text)
*
* @see create_discovery_stream_writer
*/
virtual StorageStreamWriter * create_stream_writer(
const rti::recording::StreamInfo& stream_info,
const rti::recording::PropertySet& properties) = 0;
/**
* @brief \product calls this to create a stream writer for the DDS built-in
* topic DCPSParticipant.
* In order for the stream writer to be created, this function has to
* be implemented. Otherwise, no DCPSParticipant data will be
* recorded.
* @see ParticipantStorageWriter
*/
virtual ParticipantStorageWriter * create_participant_writer()
{
return NULL;
}
/**
* @brief \product calls this to create a stream writer for the DDS built-in
* topic DCPSPublication.
* In order for the stream writer to be created, this function has to
* be implemented. Otherwise, no DCPSPublication data will be
* recorded.
* @see PublicationStorageWriter
*/
virtual PublicationStorageWriter * create_publication_writer()
{
return NULL;
}
/**
* @brief \product calls this to create a stream writer for the DDS built-in
* topic DCPSSubscription.
* In order for the stream writer to be created, this function has to
* be implemented. Otherwise, no DCPSSubscription data will be
* recorded.
* @see SubscriptionStorageWriter
*/
virtual SubscriptionStorageWriter * create_subscription_writer()
{
return NULL;
}
/**
* @brief \product calls this to delete a stream writer. This method should
* be able to work with any stream, user-data or discovery.
*
* @param writer Stream Writer to be deleted.
*/
virtual void delete_stream_writer(StorageStreamWriter *writer) = 0;
private:
StorageWriter() {}
};
} } } /* namespace rti::recording::storage */
#include "rti/recording/storage/detail/StorageWriterForwarder.hpp"
#include "rti/routing/ServiceProperty.hpp"
#include "rti/routing/detail/ForwarderUtils.hpp"
/** \ingroup RTI_RecordingServiceStorageModule
* @def RTI_RECORDING_STORAGE_WRITER_CREATE_DECL
* @brief Convenience macro to declare the C-style function that will be called
* by \product to create your class
*
* This macro automatically declares a C wrapper function for your class
* creation. \product must be initialized
* with the name of this function. For example if your StorageWriter class is
* 'FileStorageWriter' this creates wrapper function called
* 'FileStorageWriter_get_storage_writer' that you must specify in your XML
* file, such as:
*
* \verbatim
<plugin_library name="StorageLibrary">
<storage_plugin name="ExamplePlugin">
<dll>FileStorageWriter</dll>
<create_function>FileStorageWriter_get_storage_writer</create_function>
</storage_plugin>
</plugin_library>
\endverbatim
*/
#define RTI_RECORDING_STORAGE_WRITER_CREATE_DECL(STORAGE_WRITER_CLASS) \
extern "C" RTI_USER_DLL_EXPORT \
struct RTI_RecordingServiceStorageWriter * \
STORAGE_WRITER_CLASS ## _get_storage_writer( \
const struct RTI_RoutingServiceProperties *);
/** \ingroup RTI_RecordingServiceStorageModule
* @brief Convenience macro to implement the C-style function that will be
* called by \product to create your class
*
* This macro automatically defines a C wrapper function for your class
* creation. \product must be initialized
* with the name of this function.
*/
#define RTI_RECORDING_STORAGE_WRITER_CREATE_DEF(STORAGE_WRITER_CLASS) \
struct RTI_RecordingServiceStorageWriter * \
STORAGE_WRITER_CLASS ## _get_storage_writer( \
const struct RTI_RoutingServiceProperties *native_properties) \
{ \
rti::recording::PropertySet properties; \
rti::routing::PropertyAdapter::add_properties_from_native( \
properties, \
native_properties); \
return new rti::recording::storage::detail::StorageWriterForwarder( \
new STORAGE_WRITER_CLASS(properties)); \
}
#endif /* HPP_RTI_RECORDING_STORAGE_STORAGEWRITER_HPP_ */
@@ -0,0 +1,177 @@
/*
* (c) Copyright, Real-Time Innovations, 2017.
* All rights reserved.
*
* No duplications, whole or partial, manual or electronic, may be made
* without express written permission. Any such copies, or
* revisions thereof, must display this notice unaltered.
* This code contains trade secrets of Real-Time Innovations, Inc.
*/
#ifndef RTI_RECORDING_STORAGE_DETAIL_STORAGE_READER_FORWARDER_HPP_
#define RTI_RECORDING_STORAGE_DETAIL_STORAGE_READER_FORWARDER_HPP_
#include "log/log_common.h"
#include "rti/routing/detail/ForwarderUtils.hpp"
#include "rti/routing/ServiceProperty.hpp"
#include "recordingservice/recordingservice_storagereader.h"
#include "rti/recording/storage/detail/StorageStreamReaderForwarder.hpp"
#include "StorageStreamInfoReaderForwarder.hpp"
namespace rti { namespace recording { namespace storage { namespace detail {
class StorageReaderForwarder : public RTI_RecordingServiceStorageReader {
public:
StorageReaderForwarder(StorageReader *storage_reader)
: storage_reader_(storage_reader)
{
create_stream_reader = StorageReaderForwarder::create_stream_reader_fwd;
delete_stream_reader = StorageReaderForwarder::delete_stream_reader_fwd;
create_stream_info_reader =
StorageReaderForwarder::create_stream_info_reader_fwd;
delete_stream_info_reader =
StorageReaderForwarder::delete_stream_info_reader_fwd;
delete_instance = StorageReaderForwarder::delete_instance_fwd;
storage_reader_data = this;
}
~StorageReaderForwarder()
{
}
static void delete_instance_fwd(
struct RTI_RecordingServiceStorageReader *storage_reader)
{
try {
StorageReaderForwarder *forwarder =
static_cast<StorageReaderForwarder *>(storage_reader);
delete forwarder;
} catch (const std::exception& ex) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
ex.what());
} catch (...) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
"unknown exception");
}
}
static RTI_RecordingServiceStorageStreamReader * create_stream_reader_fwd(
void *storage_reader,
const struct RTI_RoutingServiceStreamInfo *native_stream_info,
const struct RTI_RoutingServiceProperties *native_properties)
{
try {
StorageReaderForwarder *forwarder =
static_cast<StorageReaderForwarder *>(storage_reader);
rti::routing::StreamInfo stream_info(*native_stream_info);
rti::routing::PropertySet properties;
rti::routing::PropertyAdapter::add_properties_from_native(
properties,
native_properties);
StorageStreamReaderForwarder *stream_reader_forwarder =
new StorageStreamReaderForwarder(
forwarder->storage_reader_->create_stream_reader(
stream_info,
properties),
forwarder->storage_reader_.get());
return stream_reader_forwarder;
} catch (const std::exception& ex) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
ex.what());
return NULL;
} catch (...) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
"unknown exception");
}
return NULL;
}
static void delete_stream_reader_fwd(
void *,
RTI_RecordingServiceStorageStreamReader *storage_stream_reader)
{
try {
StorageStreamReaderForwarder *stream_reader_forwarder =
static_cast<StorageStreamReaderForwarder *>(
storage_stream_reader);
delete stream_reader_forwarder;
} catch (const std::exception& ex) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
ex.what());
} catch (...) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
"unknown exception");
}
}
static RTI_RecordingServiceStorageStreamInfoReader *
create_stream_info_reader_fwd(
void *storage_reader_data,
const struct RTI_RoutingServiceProperties *native_properties)
{
try {
StorageReaderForwarder *forwarder =
static_cast<StorageReaderForwarder *>(storage_reader_data);
rti::routing::PropertySet properties;
rti::routing::PropertyAdapter::add_properties_from_native(
properties,
native_properties);
StorageStreamInfoReaderForwarder *disc_reader_forwarder =
new StorageStreamInfoReaderForwarder(
forwarder->storage_reader_->create_stream_info_reader(
properties),
forwarder->storage_reader_.get());
return disc_reader_forwarder;
} catch (const std::exception& ex) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
ex.what());
return NULL;
} catch (...) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
"unknown exception");
}
return NULL;
}
static void delete_stream_info_reader_fwd(
void *,
RTI_RecordingServiceStorageStreamInfoReader *stream_info_reader)
{
try {
StorageStreamInfoReaderForwarder *disc_reader_forwarder =
static_cast<StorageStreamInfoReaderForwarder *>(
stream_info_reader);
delete disc_reader_forwarder;
} catch (const std::exception& ex) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
ex.what());
} catch (...) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
"unknown exception");
}
}
private:
std::shared_ptr<StorageReader> storage_reader_;
};
} } } }
#endif // RTI_RECORDING_STORAGE_DETAIL_STORAGE_WRITER_FORWARDER_HPP_
@@ -0,0 +1,239 @@
/*
* (c) Copyright, Real-Time Innovations, 2017.
* All rights reserved.
*
* No duplications, whole or partial, manual or electronic, may be made
* without express written permission. Any such copies, or
* revisions thereof, must display this notice unaltered.
* This code contains trade secrets of Real-Time Innovations, Inc.
*/
#ifndef RTI_RECORDING_STORAGE_DETAIL_STORAGE_DISC_STREAM_READER_FORWARDER_HPP_
#define RTI_RECORDING_STORAGE_DETAIL_STORAGE_DISC_STREAM_READER_FORWARDER_HPP_
#include <map>
#include <string>
#include "rti/recording/storage/StorageStreamInfoReader.hpp"
#include "log/log_common.h"
#include "recordingservice/recordingservice_storagereader.h"
#include <memory>
#include "rti/routing/detail/ForwarderUtils.hpp"
namespace rti { namespace recording { namespace storage { namespace detail {
/**
* The following class is a helper to be able to fully associate the life
* of the StorageStreamInfoReader object to a shared pointer, which will provide
* us with RAII capabilities.
*/
class StorageStreamInfoReaderDeleter {
public:
StorageStreamInfoReaderDeleter(StorageReader *storage_reader_parent)
: storage_reader_parent_(storage_reader_parent)
{
RTI_CHECK_PRECONDITION(storage_reader_parent != NULL);
}
void operator ()(StorageStreamInfoReader *stream_reader_instance)
{
RTI_CHECK_PRECONDITION(stream_reader_instance != NULL);
storage_reader_parent_->delete_stream_info_reader(
stream_reader_instance);
}
private:
StorageReader *storage_reader_parent_;
};
class StorageStreamInfoReaderForwarder :
public RTI_RecordingServiceStorageStreamInfoReader {
public:
StorageStreamInfoReaderForwarder(
StorageStreamInfoReader *stream_reader,
StorageReader *storage_reader_parent)
: storage_stream_reader_(
stream_reader,
StorageStreamInfoReaderDeleter(storage_reader_parent))
{
read = StorageStreamInfoReaderForwarder::read_fwd;
return_loan = StorageStreamInfoReaderForwarder::return_loan_fwd;
get_service_start_time =
StorageStreamInfoReaderForwarder::get_service_start_time_fwd;
get_service_stop_time =
StorageStreamInfoReaderForwarder::get_service_stop_time_fwd;
finished = StorageStreamInfoReaderForwarder::finished_fwd;
reset = StorageStreamInfoReaderForwarder::reset_fwd;
stream_reader_data = this;
}
~StorageStreamInfoReaderForwarder()
{
}
static void read_fwd(
void *stream_reader_data,
RTI_RoutingServiceStreamInfo ***stream_info_array,
int *array_length,
const struct RTI_RecordingServiceSelectorState *native_selector)
{
try {
StorageStreamInfoReaderForwarder *forwarder =
static_cast<StorageStreamInfoReaderForwarder *>(
stream_reader_data);
forwarder->storage_stream_reader_->read(
forwarder->sample_seq_,
SelectorState(*native_selector));
*array_length = static_cast<int>(forwarder->sample_seq_.size());
if (*array_length > 0) {
forwarder->native_sample_seq_.resize(*array_length);
for (size_t i = 0; i < forwarder->sample_seq_.size(); i++) {
forwarder->native_sample_seq_[i] =
&(forwarder->sample_seq_[i]->native());
}
*stream_info_array =
reinterpret_cast<RTI_RoutingServiceStreamInfo **>(
forwarder->native_sample_seq_.data());
}
} catch (const std::exception& ex) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
ex.what());
} catch (...) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
"unknown exception");
}
}
static void return_loan_fwd(
void *stream_reader_data,
struct RTI_RoutingServiceStreamInfo **stream_info_array,
int array_length)
{
RTIOsapiUtility_unusedParameter(stream_info_array);
RTIOsapiUtility_unusedParameter(array_length);
try {
StorageStreamInfoReaderForwarder *forwarder =
static_cast<StorageStreamInfoReaderForwarder *>(
stream_reader_data);
// Deleting what's inside the vectors (dynamic data objects) and any
// related objects is responsability of the implementation
forwarder->storage_stream_reader_->return_loan(
forwarder->sample_seq_);
// Clear our internal containers
forwarder->sample_seq_.clear();
forwarder->native_sample_seq_.clear();
} catch (const std::exception& ex) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
ex.what());
} catch (...) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
"unknown exception");
}
}
static long long get_service_start_time_fwd(void *stream_reader_data)
{
try {
StorageStreamInfoReaderForwarder *forwarder =
static_cast<StorageStreamInfoReaderForwarder *>(
stream_reader_data);
return (long long)
forwarder->storage_stream_reader_->service_start_time();
} catch (const std::exception& ex) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
ex.what());
} catch (...) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
"unknown exception");
}
return 0;
}
static long long get_service_stop_time_fwd(void *stream_reader_data)
{
try {
StorageStreamInfoReaderForwarder *forwarder =
static_cast<StorageStreamInfoReaderForwarder *>(
stream_reader_data);
return (long long)
forwarder->storage_stream_reader_->service_stop_time();
} catch (const std::exception& ex) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
ex.what());
} catch (...) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
"unknown exception");
}
return 0;
}
static int finished_fwd(void *stream_reader_data)
{
try {
StorageStreamInfoReaderForwarder *forwarder =
static_cast<StorageStreamInfoReaderForwarder *>(
stream_reader_data);
return (forwarder->storage_stream_reader_->finished() ?
RTI_TRUE :
RTI_FALSE);
} catch (const std::exception& ex) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
ex.what());
} catch (...) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
"unknown exception");
}
return RTI_FALSE;
}
static void reset_fwd(void *stream_reader_data)
{
try {
StorageStreamInfoReaderForwarder *forwarder =
static_cast<StorageStreamInfoReaderForwarder *>(
stream_reader_data);
forwarder->storage_stream_reader_->reset();
} catch (const std::exception& ex) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
ex.what());
} catch (...) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
"unknown exception");
}
}
StorageStreamInfoReader * stream_reader()
{
return storage_stream_reader_.get();
}
private:
std::shared_ptr<StorageStreamInfoReader> storage_stream_reader_;
std::vector<rti::routing::StreamInfo *> sample_seq_;
std::vector<RTI_RoutingServiceStreamInfo *> native_sample_seq_;
std::vector<int32_t> domain_id_seq_;
};
} } } } // rti::recording::storage::detail
#endif // RTI_RECORDING_STORAGE_DETAIL_STORAGE_DISC_STREAM_READER_FORWARDER_HPP_
@@ -0,0 +1,194 @@
/*
* (c) Copyright, Real-Time Innovations, 2017.
* All rights reserved.
*
* No duplications, whole or partial, manual or electronic, may be made
* without express written permission. Any such copies, or
* revisions thereof, must display this notice unaltered.
* This code contains trade secrets of Real-Time Innovations, Inc.
*/
#ifndef RTI_RECORDING_STORAGE_DETAIL_STORAGE_STREAM_READER_FORWARDER_HPP_
#define RTI_RECORDING_STORAGE_DETAIL_STORAGE_STREAM_READER_FORWARDER_HPP_
#include <map>
#include <string>
#include "log/log_common.h"
#include "recordingservice/recordingservice_storagereader.h"
#include <memory>
#include "rti/routing/detail/ForwarderUtils.hpp"
#include "rti/recording/storage/StorageDefs.hpp"
#include "rti/recording/storage/StorageStreamReader.hpp"
#include "rti/recording/storage/SelectorState.hpp"
namespace rti { namespace recording { namespace storage { namespace detail {
/**
* The following class is a helper to be able to fully associate the life
* of the StorageStreamReader object to a shared pointer, which will provide
* us with RAII capabilities.
*/
class StorageStreamReaderDeleter {
public:
StorageStreamReaderDeleter(StorageReader *storage_reader_parent)
: storage_reader_parent_(storage_reader_parent)
{
RTI_CHECK_PRECONDITION(storage_reader_parent != NULL);
}
void operator ()(StorageStreamReader *stream_reader_instance)
{
RTI_CHECK_PRECONDITION(stream_reader_instance != NULL);
storage_reader_parent_->delete_stream_reader(
stream_reader_instance);
}
private:
StorageReader *storage_reader_parent_;
};
class StorageStreamReaderForwarder :
public RTI_RecordingServiceStorageStreamReader {
public:
StorageStreamReaderForwarder(
StorageStreamReader *stream_reader,
StorageReader *storage_reader_parent)
: storage_stream_reader_(
stream_reader,
StorageStreamReaderDeleter(storage_reader_parent))
{
read = StorageStreamReaderForwarder::read_fwd;
return_loan = StorageStreamReaderForwarder::return_loan_fwd;
finished = StorageStreamReaderForwarder::finished_fwd;
reset = StorageStreamReaderForwarder::reset_fwd;
stream_reader_data = this;
}
~StorageStreamReaderForwarder()
{
}
static void read_fwd(
void *stream_reader_data,
RTI_RoutingServiceSample **sample_array,
RTI_RoutingServiceSampleInfo **sample_info_array,
int *array_length,
const struct RTI_RecordingServiceSelectorState *native_selector)
{
try {
StorageStreamReaderForwarder *forwarder =
static_cast<StorageStreamReaderForwarder *>(
stream_reader_data);
forwarder->storage_stream_reader_->read(
forwarder->sample_seq_,
forwarder->info_seq_,
SelectorState(*native_selector));
*array_length = static_cast<int>(forwarder->sample_seq_.size());
if (*array_length > 0) {
*sample_array = forwarder->sample_seq_.data();
*sample_info_array = forwarder->info_seq_.data();
}
} catch (const std::exception& ex) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
ex.what());
} catch (...) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
"unknown exception");
}
}
static void return_loan_fwd(
void *stream_reader_data,
RTI_RoutingServiceSample *sample_array,
RTI_RoutingServiceSampleInfo *sample_info_array,
int array_length)
{
RTIOsapiUtility_unusedParameter(sample_array);
RTIOsapiUtility_unusedParameter(sample_info_array);
RTIOsapiUtility_unusedParameter(array_length);
try {
StorageStreamReaderForwarder *forwarder =
static_cast<StorageStreamReaderForwarder *>(
stream_reader_data);
// Deleting what's inside the vectors (dynamic data objects) and any
// related objects is responsability of the implementation
forwarder->storage_stream_reader_->return_loan(
forwarder->sample_seq_,
forwarder->info_seq_);
// Clear our internal containers
forwarder->sample_seq_.clear();
forwarder->info_seq_.clear();
} catch (const std::exception& ex) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
ex.what());
} catch (...) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
"unknown exception");
}
}
static int finished_fwd(void *stream_reader_data)
{
try {
StorageStreamReaderForwarder *forwarder =
static_cast<StorageStreamReaderForwarder *>(
stream_reader_data);
return (forwarder->storage_stream_reader_->finished() ?
RTI_TRUE :
RTI_FALSE);
} catch (const std::exception& ex) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
ex.what());
} catch (...) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
"unknown exception");
}
return RTI_FALSE;
}
static void reset_fwd(void *stream_reader_data)
{
try {
StorageStreamReaderForwarder *forwarder =
static_cast<StorageStreamReaderForwarder *>(
stream_reader_data);
forwarder->storage_stream_reader_->reset();
} catch (const std::exception& ex) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
ex.what());
} catch (...) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
"unknown exception");
}
}
StorageStreamReader * stream_reader()
{
return storage_stream_reader_.get();
}
private:
std::shared_ptr<StorageStreamReader> storage_stream_reader_;
std::vector<StorageStreamReader::SamplePtr> sample_seq_;
std::vector<StorageStreamReader::InfoPtr> info_seq_;
};
} } } } // rti::recording::storage::detail
#endif // RTI_RECORDING_STORAGE_DETAIL_STORAGE_STREAM_READER_FORWARDER_HPP_
@@ -0,0 +1,268 @@
/*
* (c) Copyright, Real-Time Innovations, 2017.
* All rights reserved.
*
* No duplications, whole or partial, manual or electronic, may be made
* without express written permission. Any such copies, or
* revisions thereof, must display this notice unaltered.
* This code contains trade secrets of Real-Time Innovations, Inc.
*/
#ifndef RTI_RECORDING_STORAGE_DETAIL_STORAGE_STREAM_WRITER_FORWARDER_HPP_
#define RTI_RECORDING_STORAGE_DETAIL_STORAGE_STREAM_WRITER_FORWARDER_HPP_
#include <map>
#include <string>
#include "log/log_common.h"
#include "recordingservice/recordingservice_storagewriter.h"
#include <memory>
#include "rti/routing/detail/ForwarderUtils.hpp"
#include "rti/recording/storage/StorageStreamWriter.hpp"
namespace rti { namespace recording { namespace storage { namespace detail {
/**
* The following class is a helper to be able to fully associate the life
* of the StorageStreamWriter object to a shared pointer, which will provide
* us with RAII capabilities.
*/
class StorageStreamWriterDeleter {
public:
StorageStreamWriterDeleter(StorageWriter *storage_writer_parent)
: storage_writer_parent_(storage_writer_parent)
{
RTI_CHECK_PRECONDITION(storage_writer_parent != NULL);
}
void operator ()(StorageStreamWriter *stream_writer_instance)
{
if (stream_writer_instance != NULL) {
storage_writer_parent_->delete_stream_writer(
stream_writer_instance);
}
}
private:
StorageWriter *storage_writer_parent_;
};
class StorageStreamWriterForwarder :
public RTI_RecordingServiceStorageStreamWriter {
public:
StorageStreamWriterForwarder(
StorageStreamWriter *stream_writer,
StorageWriter *storage_writer_parent)
: storage_stream_writer_(
stream_writer,
StorageStreamWriterDeleter(storage_writer_parent))
{
store = StorageStreamWriterForwarder::store_fwd;
stream_writer_data = this;
}
~StorageStreamWriterForwarder()
{
}
static void store_fwd(
void *stream_writer_data,
const RTI_RoutingServiceSample *samples,
const RTI_RoutingServiceSampleInfo *sample_infos,
const int count)
{
try {
StorageStreamWriterForwarder *forwarder =
static_cast<StorageStreamWriterForwarder *>(
stream_writer_data);
// Fill in internal vector with incoming samples
forwarder->sample_seq_.assign(samples, samples + count);
// Fill in internal vector with incoming sample infos, the sample
// info array is optional so check for validity before doing
// anything
if (sample_infos != NULL) {
forwarder->info_seq_.assign(sample_infos, sample_infos + count);
}
// Forward the call to the StorageStreamWriter implementation
forwarder->storage_stream_writer_->store(
forwarder->sample_seq_,
forwarder->info_seq_);
} catch (const std::exception& ex) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
ex.what());
} catch (...) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
"unknown exception");
}
}
StorageStreamWriter * stream_writer()
{
return storage_stream_writer_.get();
}
private:
std::shared_ptr<StorageStreamWriter> storage_stream_writer_;
std::vector<StorageStreamWriter::SamplePtr> sample_seq_;
std::vector<StorageStreamWriter::InfoPtr> info_seq_;
};
/**
* This generic forwarding wrapper class defines a store method that forwards a
* call to a native stream writer's store method to a C++ stream writer
* specialisation.
* Two template parameters:
* - NativeStreamWriterType: one of the native stream writer types defined
* in recordingservice_storagewriter.h. These types have to implement a
* store() method to store the samples.
* - NativeStoredType: the type passed in to the store() method.
*/
template<typename NativeStreamWriterType, typename NativeStoredType>
class StorageGenericStreamWriterForwarder : public NativeStreamWriterType {
public:
StorageGenericStreamWriterForwarder(
StorageStreamWriter *stream_writer,
StorageWriter *storage_writer_parent)
: storage_stream_writer_(
stream_writer,
StorageStreamWriterDeleter(storage_writer_parent))
{
}
~StorageGenericStreamWriterForwarder()
{
}
static void store_fwd(
void *stream_writer_data,
const NativeStoredType **samples,
const RTI_RoutingServiceSampleInfo *sample_infos,
const int count)
{
try {
StorageGenericStreamWriterForwarder *forwarder =
static_cast<StorageGenericStreamWriterForwarder *>(
stream_writer_data);
/*
* In the case of the generic stream writer forwarder, used for the
* built-in DDS discovery topics, we are not guaranteed that the
* stream writer will not be null. This can happen if the user
* doesn't override the default implementations, which return null.
* The user may not have interest in recording one or any of the
* topics. We should account for that case.
*/
if (forwarder->storage_stream_writer_.get() == NULL) {
return;
}
// Fill in internal vector with incoming samples
StorageStreamWriter::SamplePtr *untyped_samples =
(StorageStreamWriter::SamplePtr *) samples;
forwarder->sample_seq_.assign(
untyped_samples,
untyped_samples + count);
/*
* Fill in internal vector with incoming sample infos, the sample
* info array is optional so check for validity before doing
* anything
*/
if (sample_infos != NULL) {
forwarder->info_seq_.assign(sample_infos, sample_infos + count);
}
// Forward the call to the StorageStreamWriter implementation
forwarder->storage_stream_writer_->store(
forwarder->sample_seq_,
forwarder->info_seq_);
} catch (const std::exception& ex) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
ex.what());
} catch (...) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
"unknown exception");
}
}
StorageStreamWriter * stream_writer()
{
return storage_stream_writer_.get();
}
private:
std::shared_ptr<StorageStreamWriter> storage_stream_writer_;
std::vector<StorageStreamWriter::SamplePtr> sample_seq_;
std::vector<StorageStreamWriter::InfoPtr> info_seq_;
};
class StorageParticipantWriterForwarder :
public StorageGenericStreamWriterForwarder<
RTI_RecordingServiceStorageParticipantWriter,
DDS_ParticipantBuiltinTopicData> {
public:
StorageParticipantWriterForwarder(
StorageStreamWriter *stream_writer,
StorageWriter *storage_writer_parent) :
StorageGenericStreamWriterForwarder<
RTI_RecordingServiceStorageParticipantWriter,
DDS_ParticipantBuiltinTopicData>(
stream_writer,
storage_writer_parent)
{
store = store_fwd;
stream_writer_data = this;
}
};
class StoragePublicationWriterForwarder :
public StorageGenericStreamWriterForwarder<
RTI_RecordingServiceStoragePublicationWriter,
DDS_PublicationBuiltinTopicData> {
public:
StoragePublicationWriterForwarder(
StorageStreamWriter *stream_writer,
StorageWriter *storage_writer_parent) :
StorageGenericStreamWriterForwarder<
RTI_RecordingServiceStoragePublicationWriter,
DDS_PublicationBuiltinTopicData>(
stream_writer,
storage_writer_parent)
{
store = store_fwd;
stream_writer_data = this;
}
};
class StorageSubscriptionWriterForwarder :
public StorageGenericStreamWriterForwarder<
RTI_RecordingServiceStorageSubscriptionWriter,
DDS_SubscriptionBuiltinTopicData> {
public:
StorageSubscriptionWriterForwarder(
StorageStreamWriter *stream_writer,
StorageWriter *storage_writer_parent) :
StorageGenericStreamWriterForwarder<
RTI_RecordingServiceStorageSubscriptionWriter,
DDS_SubscriptionBuiltinTopicData>(
stream_writer,
storage_writer_parent)
{
store = store_fwd;
stream_writer_data = this;
}
};
} } } } // rti::recording::storage::detail
#endif // RTI_RECORDING_STORAGE_DETAIL_STORAGE_STREAM_WRITER_FORWARDER_HPP_
@@ -0,0 +1,270 @@
/*
* (c) Copyright, Real-Time Innovations, 2017.
* All rights reserved.
*
* No duplications, whole or partial, manual or electronic, may be made
* without express written permission. Any such copies, or
* revisions thereof, must display this notice unaltered.
* This code contains trade secrets of Real-Time Innovations, Inc.
*/
#ifndef RTI_RECORDING_STORAGE_DETAIL_STORAGE_WRITER_FORWARDER_HPP_
#define RTI_RECORDING_STORAGE_DETAIL_STORAGE_WRITER_FORWARDER_HPP_
#include <map>
#include <string>
#include "log/log_common.h"
#include "rti/routing/detail/ForwarderUtils.hpp"
#include "rti/routing/ServiceProperty.hpp"
#include "recordingservice/recordingservice_storagewriter.h"
#include "rti/recording/storage/StorageDefs.hpp"
#include "rti/recording/storage/detail/StorageStreamWriterForwarder.hpp"
namespace rti { namespace recording { namespace storage { namespace detail {
class StorageWriterForwarder : public RTI_RecordingServiceStorageWriter {
public:
StorageWriterForwarder(StorageWriter *storage_writer) :
storage_writer_(storage_writer)
{
// User-data stream creation function
create_stream_writer = StorageWriterForwarder::create_stream_writer_fwd;
// Discovery stream creation functions
create_participant_writer =
StorageWriterForwarder::create_participant_writer_fwd;
create_publication_writer =
StorageWriterForwarder::create_publication_writer_fwd;
create_subscription_writer =
StorageWriterForwarder::create_subscription_writer_fwd;
// User-data stream deletion function
delete_stream_writer = StorageWriterForwarder::delete_stream_writer_fwd;
// Discovery stream deletion functions
delete_participant_writer =
StorageWriterForwarder::delete_participant_writer_fwd;
delete_publication_writer =
StorageWriterForwarder::delete_publication_writer_fwd;
delete_subscription_writer =
StorageWriterForwarder::delete_subscription_writer_fwd;
// Delete storage writer instance method
delete_instance = StorageWriterForwarder::delete_instance_fwd;
storage_writer_data = this;
}
~StorageWriterForwarder()
{
}
static void delete_instance_fwd(
struct RTI_RecordingServiceStorageWriter *storage_writer)
{
try {
StorageWriterForwarder *forwarder =
static_cast<StorageWriterForwarder *>(storage_writer);
delete forwarder;
} catch (const std::exception& ex) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
ex.what());
} catch (...) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
"unknown exception");
}
}
static RTI_RecordingServiceStorageStreamWriter * create_stream_writer_fwd(
void *storage_writer,
const RTI_RoutingServiceStreamInfo *native_stream_info,
const RTI_RoutingServiceProperties *native_properties)
{
RTI_CHECK_PRECONDITION(!rti::recording::is_discovery_stream(
std::string(native_stream_info->stream_name)));
try {
StorageWriterForwarder *forwarder =
static_cast<StorageWriterForwarder *>(storage_writer);
rti::routing::StreamInfo stream_info(*native_stream_info);
rti::routing::PropertySet properties;
rti::routing::PropertyAdapter::add_properties_from_native(
properties,
native_properties);
StorageStreamWriterForwarder *stream_writer_forwarder =
new StorageStreamWriterForwarder(
forwarder->storage_writer_->create_stream_writer(
stream_info,
properties),
forwarder->storage_writer_.get());
return stream_writer_forwarder;
} catch (const std::exception& ex) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
ex.what());
} catch (...) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
"unknown exception");
}
return NULL;
}
static RTI_RecordingServiceStorageParticipantWriter *
create_participant_writer_fwd(void *storage_writer)
{
try {
StorageWriterForwarder *forwarder =
static_cast<StorageWriterForwarder *>(storage_writer);
StorageParticipantWriterForwarder *stream_writer_forwarder =
new StorageParticipantWriterForwarder(
forwarder->storage_writer_->create_participant_writer(),
forwarder->storage_writer_.get());
return stream_writer_forwarder;
} catch (const std::exception& ex) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
ex.what());
} catch (...) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
"unknown exception");
}
return NULL;
}
static RTI_RecordingServiceStoragePublicationWriter *
create_publication_writer_fwd(void *storage_writer)
{
try {
StorageWriterForwarder *forwarder =
static_cast<StorageWriterForwarder *>(storage_writer);
StoragePublicationWriterForwarder *stream_writer_forwarder =
new StoragePublicationWriterForwarder(
forwarder->storage_writer_->create_publication_writer(),
forwarder->storage_writer_.get());
return stream_writer_forwarder;
} catch (const std::exception& ex) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
ex.what());
} catch (...) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
"unknown exception");
}
return NULL;
}
static RTI_RecordingServiceStorageSubscriptionWriter *
create_subscription_writer_fwd(void *storage_writer)
{
try {
StorageWriterForwarder *forwarder =
static_cast<StorageWriterForwarder *>(storage_writer);
StorageSubscriptionWriterForwarder *stream_writer_forwarder =
new StorageSubscriptionWriterForwarder(
forwarder->storage_writer_->create_subscription_writer(),
forwarder->storage_writer_.get());
return stream_writer_forwarder;
} catch (const std::exception& ex) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
ex.what());
} catch (...) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
"unknown exception");
}
return NULL;
}
static void delete_stream_writer_fwd(
void *,
RTI_RecordingServiceStorageStreamWriter *storage_stream_writer)
{
try {
StorageStreamWriterForwarder *stream_writer_forwarder =
static_cast<StorageStreamWriterForwarder *>(
storage_stream_writer);
delete stream_writer_forwarder;
} catch (const std::exception& ex) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
ex.what());
} catch (...) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
"unknown exception");
}
}
static void delete_participant_writer_fwd(
void *,
RTI_RecordingServiceStorageParticipantWriter *stream_writer)
{
try {
StorageParticipantWriterForwarder *forwarder =
static_cast<StorageParticipantWriterForwarder *>(
stream_writer);
delete forwarder;
} catch (const std::exception& ex) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
ex.what());
} catch (...) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
"unknown exception");
}
}
static void delete_publication_writer_fwd(
void *,
RTI_RecordingServiceStoragePublicationWriter *stream_writer)
{
try {
StoragePublicationWriterForwarder *forwarder =
static_cast<StoragePublicationWriterForwarder *>(
stream_writer);
delete forwarder;
} catch (const std::exception& ex) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
ex.what());
} catch (...) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
"unknown exception");
}
}
static void delete_subscription_writer_fwd(
void *,
RTI_RecordingServiceStorageSubscriptionWriter *stream_writer)
{
try {
StorageSubscriptionWriterForwarder *forwarder =
static_cast<StorageSubscriptionWriterForwarder *>(
stream_writer);
delete forwarder;
} catch (const std::exception& ex) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
ex.what());
} catch (...) {
RecorderPrint_exception(
&RTI_LOG_ANY_s,
"unknown exception");
}
}
private:
std::shared_ptr<StorageWriter> storage_writer_;
};
} } } } // rti::recording::storage::namespace
#endif // RTI_RECORDING_STORAGE_DETAIL_STORAGE_WRITER_FORWARDER_HPP_