Adds immediate migration results
This commit is contained in:
2395 files changed
+357322
-2524
No files matched your search
@@ -0,0 +1,223 @@
|
||||
/*
|
||||
* (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_ROUTING_TRANSF_TRANSFORMATION_HPP_
|
||||
#define RTI_ROUTING_TRANSF_TRANSFORMATION_HPP_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <dds/core/xtypes/DynamicData.hpp>
|
||||
#include <dds/sub/SampleInfo.hpp>
|
||||
#include <rti/routing/UpdatableEntity.hpp>
|
||||
#include <rti/routing/detail/ForwarderUtils.hpp>
|
||||
|
||||
namespace rti { namespace routing { namespace transf {
|
||||
|
||||
/** @ingroup RTI_RoutingServiceTransformationModule
|
||||
*
|
||||
* @class rti::routing::transf::Transformation
|
||||
* @brief Provides a way to transform input samples into output samples of a
|
||||
* different format and/or content.
|
||||
*
|
||||
* @mtsafety Partially Safe
|
||||
* All operations on a concrete Transformation object are safe and
|
||||
* always serialized on a given Output. Operations on different
|
||||
* Transformations objects may be called concurrently if they
|
||||
* belong to different Outputs from different Routes.
|
||||
*/
|
||||
class Transformation : public UpdatableEntity{
|
||||
public:
|
||||
|
||||
typedef void* SamplePtr;
|
||||
typedef void* InfoPtr;
|
||||
|
||||
/**
|
||||
* @brief Transforms a vector of input samples into a vector of output
|
||||
* samples.
|
||||
*
|
||||
* When @product is done using the output samples, it will 'return the loan'
|
||||
* to the transformation by calling Transformation::return_loan. It is
|
||||
* guaranteed @product takes one outstanding loan at time.
|
||||
*
|
||||
* The number of output samples can be different than the number of input
|
||||
* samples.
|
||||
*
|
||||
* The format associated with the input and output data samples and info
|
||||
* samples depends on the format provided and consumed by the input's
|
||||
* rti::routing::adapter::StreamReader and the output's
|
||||
* rti::routing::adapter::StreamWriter.
|
||||
*
|
||||
* For the built-in DDS adapter, the format of the samples is
|
||||
* dds::core::xtypes::DynamicData and the format of the sample info is
|
||||
* dds::sub::SampleInfo.
|
||||
*
|
||||
* @param output_sample_seq
|
||||
* @rs_st_inout Vector that will hold the output data samples. @product
|
||||
* provides this vector to the Transformation to fill. For each call,
|
||||
* the size of the vector is zero.
|
||||
* @param output_info_seq
|
||||
* @rs_st_inout Vector that will hold the input info samples. @product
|
||||
* provides this vector to the Transformation to fill. For each call,
|
||||
* the size of the vector is zero.
|
||||
* @param input_sample_seq
|
||||
* @rs_st_in Vector of input data samples. This vector contains the list
|
||||
* of samples that need to be transformed before calling
|
||||
* rti::routing::adapter::StreamWriter::write.
|
||||
* @param input_info_seq
|
||||
* @rs_st_in Vector of input info sample. This vector contains the list
|
||||
* of samples that need to be transformed before calling
|
||||
* rti::routing::adapter::StreamWriter::write.
|
||||
*
|
||||
* @throw std::exception
|
||||
*/
|
||||
virtual void transform(
|
||||
std::vector<SamplePtr>& output_sample_seq,
|
||||
std::vector<InfoPtr>& output_info_seq,
|
||||
const std::vector<SamplePtr>& input_sample_seq,
|
||||
const std::vector<InfoPtr>& input_info_seq) = 0;
|
||||
|
||||
/**
|
||||
* @brief Returns a loan on the transformed data samples and info samples.
|
||||
*
|
||||
* @product calls this method to indicate that it is done accessing
|
||||
* the collection of data samples and info samples obtained by an earlier
|
||||
* invocation of Transformation::transform.
|
||||
*
|
||||
* @param sample_seq
|
||||
* @rs_st_in Vector of loaned data samples.
|
||||
* @param info_seq
|
||||
* @rs_st_in Vector of loaned info samples.
|
||||
*
|
||||
* @throw std::exception
|
||||
*
|
||||
*/
|
||||
virtual void return_loan(
|
||||
std::vector<SamplePtr>& sample_seq,
|
||||
std::vector<InfoPtr>& info_seq) = 0;
|
||||
|
||||
|
||||
virtual ~Transformation() {}
|
||||
};
|
||||
|
||||
|
||||
/** @ingroup RTI_RoutingServiceTransformationModule
|
||||
*
|
||||
* @class rti::routing::transf::TypedTransformation
|
||||
*
|
||||
* @brief A wrapper implementation of a Transformation that provides a
|
||||
* strongly-typed interface through template parameters for data and info
|
||||
* representation.
|
||||
*
|
||||
* 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 TypedTransformation : public Transformation {
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief The data type
|
||||
*/
|
||||
typedef Data DataRep;
|
||||
/**
|
||||
* @brief The info type
|
||||
*/
|
||||
typedef Info InfoRep;
|
||||
|
||||
using Transformation::transform;
|
||||
using Transformation::return_loan;
|
||||
|
||||
/**
|
||||
* @brief Performs the conversion between the vector of data and info
|
||||
* pointers to strongly-type pointers.
|
||||
*/
|
||||
void transform(
|
||||
std::vector<SamplePtr>& output_sample_seq,
|
||||
std::vector<InfoPtr>& output_info_seq,
|
||||
const std::vector<SamplePtr>& input_sample_seq,
|
||||
const std::vector<InfoPtr>& input_info_seq) RTI_FINAL
|
||||
{
|
||||
RTI_ROUTING_SAMPLE_VECTOR_COPY_PTRS(in_sample_seq_, input_sample_seq);
|
||||
RTI_ROUTING_SAMPLE_VECTOR_COPY_PTRS(in_info_seq_, input_info_seq);
|
||||
transform(
|
||||
out_sample_seq_,
|
||||
out_info_seq_,
|
||||
in_sample_seq_,
|
||||
in_info_seq_);
|
||||
RTI_ROUTING_SAMPLE_VECTOR_COPY_PTRS(output_sample_seq, out_sample_seq_);
|
||||
RTI_ROUTING_SAMPLE_VECTOR_COPY_PTRS(output_info_seq, out_info_seq_);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Performs the conversion between the vector of data and info
|
||||
* pointers to strongly-type pointers.
|
||||
*/
|
||||
void return_loan(
|
||||
std::vector<SamplePtr>& sample_seq,
|
||||
std::vector<InfoPtr>& info_seq) RTI_FINAL
|
||||
{
|
||||
RTI_ROUTING_SAMPLE_VECTOR_COPY_PTRS(out_sample_seq_, sample_seq);
|
||||
RTI_ROUTING_SAMPLE_VECTOR_COPY_PTRS(out_info_seq_, info_seq);
|
||||
return_loan(out_sample_seq_, out_info_seq_);
|
||||
out_sample_seq_.clear();
|
||||
out_info_seq_.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Interface redefinition
|
||||
*
|
||||
* @see Transformation::transform
|
||||
*/
|
||||
virtual void transform(
|
||||
std::vector<Data*>& output_sample_seq,
|
||||
std::vector<Info*>& output_info_seq,
|
||||
const std::vector<Data*>& input_sample_seq,
|
||||
const std::vector<Info*>& input_info_seq) = 0;
|
||||
|
||||
/**
|
||||
* @brief Interface redefinition
|
||||
*
|
||||
* @see Transformation::return_loan
|
||||
*/
|
||||
virtual void return_loan(
|
||||
std::vector<Data*>& sample_seq,
|
||||
std::vector<Info*>& info_seq) = 0;
|
||||
|
||||
/**
|
||||
* @brief Virtual destructor
|
||||
*/
|
||||
virtual ~TypedTransformation()
|
||||
{
|
||||
|
||||
}
|
||||
private:
|
||||
std::vector<Data*> in_sample_seq_;
|
||||
std::vector<Info*> in_info_seq_;
|
||||
std::vector<Data*> out_sample_seq_;
|
||||
std::vector<Info*> out_info_seq_;
|
||||
|
||||
};
|
||||
|
||||
/** @ingroup RTI_RoutingServiceTransformationModule
|
||||
*
|
||||
* @brief Convenient definition of TypedTransformation that requires
|
||||
* dds::core::xtypes::DynamicData for data samples and dds::sub::SampleInfo
|
||||
* for info samples.
|
||||
*
|
||||
*/
|
||||
typedef TypedTransformation<dds::core::xtypes::DynamicData, dds::sub::SampleInfo>
|
||||
DynamicDataTransformation;
|
||||
|
||||
|
||||
}}}
|
||||
|
||||
|
||||
#endif // RTI_ROUTING_TRANSF_TRANSFORMATION_HPP_
|
||||
@@ -0,0 +1,221 @@
|
||||
/*
|
||||
* (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_ROUTING_TRANSF_TRANSFORMATION_PLUGIN_HPP_
|
||||
#define RTI_ROUTING_TRANSF_TRANSFORMATION_PLUGIN_HPP_
|
||||
|
||||
#include "routingservice/routingservice_log.h"
|
||||
|
||||
#include <rti/config/Version.hpp>
|
||||
#include <rti/routing/TypeInfo.hpp>
|
||||
#include <rti/routing/PropertySet.hpp>
|
||||
#include <rti/routing/transf/Transformation.hpp>
|
||||
#include <rti/routing/detail/ForwarderUtils.hpp>
|
||||
|
||||
/*e \file
|
||||
@brief RTI Routing Service Transformation API
|
||||
*/
|
||||
/** @defgroup RTI_RoutingServiceTransformationModule RTI Routing Service Transformation API
|
||||
* @ingroup ROUTER
|
||||
* @brief This module describes the Transformation API.
|
||||
*
|
||||
* An @product Output transforms the incoming data using a @em transformation,
|
||||
* which is an object created by a transformation plugin.<br>
|
||||
*
|
||||
*/
|
||||
|
||||
namespace rti { namespace routing { namespace transf {
|
||||
|
||||
/** @ingroup RTI_RoutingServiceTransformationModule
|
||||
*
|
||||
* @class rti::routing::transf::TransformationPlugin
|
||||
*
|
||||
* @brief The top-level plug-in class.
|
||||
*
|
||||
* Represents a factory of Transformation.
|
||||
*/
|
||||
class TransformationPlugin {
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief Creates an Output Transformation.
|
||||
*
|
||||
* This function is called when the Output containing the transformation
|
||||
* is enabled.
|
||||
*
|
||||
* The format associated with the input and output types depends on
|
||||
* the format provided by the input and output adapters.
|
||||
*
|
||||
* For the built-in DDS adapter, the format of the types is DDS_TypeCode.
|
||||
* <b>Required:</b> yes
|
||||
*
|
||||
* @param input_type_info
|
||||
* @rs_st_in Type information associated with the input samples.
|
||||
* @param output_type_info
|
||||
* @rs_st_in Type information associated with the output samples.
|
||||
* @param properties
|
||||
* @rs_st_in Configuration properties for the Transformation.
|
||||
* These properties corresponds to the properties specified within
|
||||
* the tag <transformation>.
|
||||
*
|
||||
* @return New Transformation if successful. Cannot return @null_value.
|
||||
* @throw std::exception
|
||||
* @mtsafety Safe
|
||||
*/
|
||||
virtual Transformation * create_transformation(
|
||||
const rti::routing::TypeInfo& input_type_info,
|
||||
const rti::routing::TypeInfo& output_type_info,
|
||||
const rti::routing::PropertySet& properties) = 0;
|
||||
|
||||
/**
|
||||
* @brief Deletes a Transformation.
|
||||
*
|
||||
* This function is called when the Output containing the transformation is
|
||||
* disabled.
|
||||
*
|
||||
* @param transformation
|
||||
* @rs_st_in Transformation to be deleted.
|
||||
*
|
||||
* @throw std::exception
|
||||
* @mtsafety Safe
|
||||
*/
|
||||
virtual void delete_transformation(Transformation *transformation) = 0;
|
||||
|
||||
/**
|
||||
* @return The version of this TransformationPlugin.
|
||||
*
|
||||
* Version is used for logging purposes and allows you to track which
|
||||
* version of the TransformationPlugin @product is using.
|
||||
*
|
||||
* Default implementation of this operation returns the version of the
|
||||
* required Connext libraries.
|
||||
*/
|
||||
virtual rti::config::LibraryVersion get_version() const
|
||||
{
|
||||
return rti::config::LibraryVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Virtual destructor
|
||||
*/
|
||||
virtual ~TransformationPlugin() {}
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
#include <rti/routing/transf/detail/TransformationPluginForwarder.hpp>
|
||||
|
||||
/** @ingroup RTI_RoutingServiceTransformationModule
|
||||
*
|
||||
* @brief Utility macro that declares a native extern function that can
|
||||
* be used to load a TransformationPlugin through a shared library.
|
||||
*
|
||||
* The prototype of the function is given by
|
||||
* RTI_RoutingServiceTransformationPlugin_CreateFcn.
|
||||
*
|
||||
* To register a transformation plugin with @product, you must use the tag
|
||||
* <transformation_plugin> within <plugin_library>. For example:
|
||||
*
|
||||
* \code
|
||||
* <dds>
|
||||
* ...
|
||||
* <plugin_library name="MyPluginLib">
|
||||
* <transformation_plugin name="MyTransfPlugin">
|
||||
* <dll>mytransformation</dll>
|
||||
* <create_function>
|
||||
* MyTransfPlugin_create
|
||||
* </create_function>
|
||||
* </transformation_plugin>
|
||||
* ...
|
||||
* </plugin_library>
|
||||
* ...
|
||||
* <routing_service>
|
||||
* ...
|
||||
* </routing_service>
|
||||
* ...
|
||||
* </dds>
|
||||
* \endcode
|
||||
*
|
||||
* Once a transformation plugin is registered, an Output can use it to create a
|
||||
* data transformation.
|
||||
*
|
||||
* For example:
|
||||
*
|
||||
* \code
|
||||
* <topic_route name="SquareSwitchCoord">
|
||||
* <input participant="1">
|
||||
* <topic_name>Square</topic_name>
|
||||
* <registered_type_name>ShapeType</registered_type_name>
|
||||
* </input>
|
||||
* <output>
|
||||
* <topic_name>Square</topic_name>
|
||||
* <registered_type_name>ShapeType</registered_type_name>
|
||||
* <transformation plugin_name="MyPluginLib::MyTransPlugin">
|
||||
* <property>
|
||||
* <value>
|
||||
* <element>
|
||||
* <name>X</name>
|
||||
* <value>Y</value>
|
||||
* </element>
|
||||
* <element>
|
||||
* <name>Y</name>
|
||||
* <value>X</value>
|
||||
* </element>
|
||||
* </value>
|
||||
* </property>
|
||||
* </transformation>
|
||||
* </output>
|
||||
* </topic_route>
|
||||
* \endcode
|
||||
*
|
||||
* For additional information on configuring transformations, see the
|
||||
* \ref_url_routing_service_users_manual.
|
||||
*
|
||||
* @param TRANSFORMATION_PLUGIN_CLASS
|
||||
* Class name of a TransformationPlugin implementation
|
||||
*/
|
||||
#define RTI_TRANSFORMATION_PLUGIN_CREATE_FUNCTION_DECL(TRANSFORMATION_PLUGIN_CLASS) \
|
||||
extern "C" RTI_USER_DLL_EXPORT struct RTI_RoutingServiceTransformationPlugin * \
|
||||
TRANSFORMATION_PLUGIN_CLASS ## _create_transformation_plugin(\
|
||||
const struct RTI_RoutingServiceProperties *, \
|
||||
RTI_RoutingServiceEnvironment *); \
|
||||
|
||||
/** @ingroup RTI_RoutingServiceTransformationModule
|
||||
*
|
||||
* @brief Utility macro that implements the TransformationPlugin entry point
|
||||
* declared with RTI_TRANSFORMATION_PLUGIN_CREATE_FUNCTION_DECL.
|
||||
*/
|
||||
#define RTI_TRANSFORMATION_PLUGIN_CREATE_FUNCTION_DEF(TRANSFORMATION_PLUGIN_CLASS) \
|
||||
struct RTI_RoutingServiceTransformationPlugin * \
|
||||
TRANSFORMATION_PLUGIN_CLASS ## _create_transformation_plugin( \
|
||||
const struct RTI_RoutingServiceProperties * native_properties, \
|
||||
RTI_RoutingServiceEnvironment *environment) \
|
||||
{ \
|
||||
rti::routing::PropertySet properties; \
|
||||
rti::routing::PropertyAdapter::add_properties_from_native(\
|
||||
properties,\
|
||||
native_properties); \
|
||||
try { \
|
||||
return rti::routing::transf::detail::TransformationPluginForwarder::create_plugin(\
|
||||
new TRANSFORMATION_PLUGIN_CLASS(properties)); \
|
||||
} catch (const std::exception& ex) {\
|
||||
RTI_RoutingServiceEnvironment_set_error(\
|
||||
environment,\
|
||||
"%s",\
|
||||
ex.what());\
|
||||
} catch (...) {}\
|
||||
\
|
||||
return NULL; \
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // RTI_ROUTING_TRANSF_TRANSFORMATION_PLUGIN_HPP_
|
||||
+257
@@ -0,0 +1,257 @@
|
||||
/*
|
||||
* (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_ROUTING_TRANSF_DETAIL_TRANSFORMATION_FORWARDER_HPP_
|
||||
#define RTI_ROUTING_TRANSF_DETAIL_TRANSFORMATION_FORWARDER_HPP_
|
||||
|
||||
#include <rti/core/Exception.hpp>
|
||||
|
||||
#include <dds/core/xtypes/DynamicData.hpp>
|
||||
#include <dds/sub/SampleInfo.hpp>
|
||||
|
||||
#include <rti/routing/transf/Transformation.hpp>
|
||||
#include <rti/routing/TypeInfo.hpp>
|
||||
#include <rti/routing/detail/UpdatableEntityForwarder.hpp>
|
||||
#include <rti/routing/detail/ForwarderUtils.hpp>
|
||||
|
||||
#include "rti/apputils/ServiceException.hpp"
|
||||
|
||||
|
||||
namespace rti { namespace routing { namespace transf { namespace detail {
|
||||
|
||||
|
||||
class TransformationForwarder{
|
||||
public:
|
||||
static RTI_RoutingServiceTransformation create_native(
|
||||
TransformationPlugin *plugin,
|
||||
const struct RTI_RoutingServiceTypeInfo *native_input_type_info,
|
||||
const struct RTI_RoutingServiceTypeInfo *native_output_type_info,
|
||||
const struct RTI_RoutingServiceProperties *native_properties,
|
||||
RTI_RoutingServiceEnvironment *environment)
|
||||
{
|
||||
try {
|
||||
using rti::routing::detail::ScopedForwarder;
|
||||
|
||||
TypeInfo input_type_info(*native_input_type_info);
|
||||
TypeInfo output_type_info(*native_output_type_info);
|
||||
|
||||
std::map<std::string, std::string> properties;
|
||||
rti::routing::PropertyAdapter::add_properties_from_native(
|
||||
properties,
|
||||
native_properties);
|
||||
|
||||
TransformationForwarder *forwarder = new TransformationForwarder();
|
||||
ScopedForwarder<TransformationPlugin, TransformationForwarder> scoped(
|
||||
plugin,
|
||||
forwarder,
|
||||
environment);
|
||||
forwarder->transformation_ = plugin->create_transformation(
|
||||
input_type_info,
|
||||
output_type_info,
|
||||
properties);
|
||||
RTI_ROUTING_THROW_ON_NULL(forwarder->transformation_);
|
||||
|
||||
scoped.release();
|
||||
return forwarder->native();
|
||||
} catch(const rti::apputils::FatalServiceException& ex) {
|
||||
RTI_RoutingServiceEnvironment_fatal_error(
|
||||
environment,
|
||||
ex.what());
|
||||
return NULL;
|
||||
} catch(const std::exception& ex) {
|
||||
RTI_RoutingServiceEnvironment_set_error(
|
||||
environment,
|
||||
ex.what());
|
||||
return NULL;
|
||||
} catch (...) {
|
||||
RTI_RoutingServiceEnvironment_set_error(
|
||||
environment,
|
||||
"unexpected exception");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void delete_native(
|
||||
TransformationPlugin *plugin,
|
||||
RTI_RoutingServiceTransformation native_transformation,
|
||||
RTI_RoutingServiceEnvironment *environment)
|
||||
{
|
||||
TransformationForwarder *forwarder =
|
||||
static_cast<TransformationForwarder*>(native_transformation);
|
||||
try {
|
||||
if (forwarder->transformation_ != NULL) {
|
||||
plugin->delete_transformation(
|
||||
forwarder->transformation_);
|
||||
forwarder->transformation_ = NULL;
|
||||
}
|
||||
} catch(const rti::apputils::FatalServiceException& ex) {
|
||||
RTI_RoutingServiceEnvironment_fatal_error(
|
||||
environment,
|
||||
ex.what());
|
||||
} catch(const std::exception& ex) {
|
||||
RTI_RoutingServiceEnvironment_set_error(
|
||||
environment,
|
||||
ex.what());
|
||||
} catch (...) {
|
||||
RTI_RoutingServiceEnvironment_set_error(
|
||||
environment,
|
||||
"unexpected exception");
|
||||
}
|
||||
|
||||
delete forwarder;
|
||||
}
|
||||
|
||||
static void transform(
|
||||
RTI_RoutingServiceTransformation native_transformation,
|
||||
RTI_RoutingServiceSample **out_sample_lst,
|
||||
RTI_RoutingServiceSampleInfo **out_info_lst,
|
||||
int *out_count,
|
||||
RTI_RoutingServiceSample *in_sample_lst,
|
||||
RTI_RoutingServiceSampleInfo *in_info_lst,
|
||||
int in_count,
|
||||
RTI_RoutingServiceEnvironment *environment)
|
||||
{
|
||||
TransformationForwarder *forwarder =
|
||||
static_cast<TransformationForwarder*> (native_transformation);
|
||||
if (forwarder->transformation_ == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
*out_count = 0;
|
||||
try {
|
||||
// get native samples
|
||||
forwarder->in_sample_seq_.resize(in_count);
|
||||
forwarder->in_info_seq_.resize(in_count);
|
||||
for (int i = 0; i < in_count; i++) {
|
||||
forwarder->in_sample_seq_[i] = in_sample_lst[i];
|
||||
if (in_info_lst != NULL) {
|
||||
forwarder->in_info_seq_[i] = in_info_lst[i];
|
||||
}
|
||||
}
|
||||
|
||||
forwarder->transformation_->transform(
|
||||
forwarder->out_sample_seq_,
|
||||
forwarder->out_info_seq_,
|
||||
forwarder->in_sample_seq_,
|
||||
forwarder->in_info_seq_);
|
||||
if (!forwarder->out_info_seq_.empty()
|
||||
&& (forwarder->out_info_seq_.size()
|
||||
!= forwarder->out_sample_seq_.size())) {
|
||||
throw dds::core::PreconditionNotMetError(
|
||||
"sample and info sequences length mismatch");
|
||||
}
|
||||
} catch (const rti::apputils::FatalServiceException& ex) {
|
||||
RTI_RoutingServiceEnvironment_fatal_error(
|
||||
environment,
|
||||
ex.what());
|
||||
return;
|
||||
} catch (const std::exception& ex) {
|
||||
RTI_RoutingServiceEnvironment_set_error(
|
||||
environment,
|
||||
ex.what());
|
||||
return;
|
||||
} catch (...) {
|
||||
RTI_RoutingServiceEnvironment_set_error(
|
||||
environment,
|
||||
"unexpected exception");
|
||||
return;
|
||||
}
|
||||
|
||||
// direct mapping
|
||||
*out_count = static_cast<int>(forwarder->out_sample_seq_.size());
|
||||
if (*out_count > 0) {
|
||||
*out_sample_lst = &forwarder->out_sample_seq_[0];
|
||||
*out_info_lst = &forwarder->out_info_seq_[0];
|
||||
}
|
||||
}
|
||||
|
||||
static void return_loan(
|
||||
RTI_RoutingServiceTransformation native_transformation,
|
||||
RTI_RoutingServiceSample *,
|
||||
RTI_RoutingServiceSampleInfo *,
|
||||
int,
|
||||
RTI_RoutingServiceEnvironment *environment)
|
||||
{
|
||||
TransformationForwarder *forwarder =
|
||||
static_cast<TransformationForwarder*>(native_transformation);
|
||||
if (forwarder->transformation_ == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
forwarder->transformation_->return_loan(
|
||||
forwarder->out_sample_seq_,
|
||||
forwarder->out_info_seq_);
|
||||
} catch (const rti::apputils::FatalServiceException& ex) {
|
||||
RTI_RoutingServiceEnvironment_fatal_error(
|
||||
environment,
|
||||
ex.what());
|
||||
} catch (const std::exception& ex) {
|
||||
RTI_RoutingServiceEnvironment_set_error(
|
||||
environment,
|
||||
ex.what());
|
||||
} catch (...) {
|
||||
RTI_RoutingServiceEnvironment_set_error(
|
||||
environment,
|
||||
"unexpected exception");
|
||||
}
|
||||
|
||||
forwarder->out_sample_seq_.clear();
|
||||
forwarder->out_info_seq_.clear();
|
||||
|
||||
}
|
||||
|
||||
static void update(
|
||||
RTI_RoutingServiceTransformation native_stream_reader,
|
||||
const struct RTI_RoutingServiceProperties *native_properties,
|
||||
RTI_RoutingServiceEnvironment *environment)
|
||||
{
|
||||
|
||||
TransformationForwarder *stream_reader_forwarder =
|
||||
static_cast<TransformationForwarder*> (native_stream_reader);
|
||||
|
||||
rti::routing::detail::UpdatableEntityForwarder::update(
|
||||
stream_reader_forwarder->transformation_,
|
||||
native_properties,
|
||||
environment);
|
||||
}
|
||||
|
||||
RTI_RoutingServiceTransformation native()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
TransformationForwarder()
|
||||
: transformation_(NULL)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
~TransformationForwarder()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
Transformation *transformation_;
|
||||
std::vector<Transformation::SamplePtr> out_sample_seq_;
|
||||
std::vector<Transformation::InfoPtr> out_info_seq_;
|
||||
std::vector<Transformation::SamplePtr> in_sample_seq_;
|
||||
std::vector<Transformation::InfoPtr> in_info_seq_;
|
||||
};
|
||||
|
||||
}}}}
|
||||
|
||||
#endif // RTI_ROUTING_TRANSF_DETAIL_TRANSFORMATION_FORWARDER_HPP_
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* (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_ROUTING_TRANSF_DETAIL_TRANSFORMATION_PLUGIN_FORWARDER_HPP_
|
||||
#define RTI_ROUTING_TRANSF_DETAIL_TRANSFORMATION_PLUGIN_FORWARDER_HPP_
|
||||
|
||||
#include <rti/core/Exception.hpp>
|
||||
|
||||
#include <routingservice/routingservice_transformation.h>
|
||||
|
||||
#include <rti/routing/transf/detail/TransformationForwarder.hpp>
|
||||
|
||||
namespace rti { namespace routing { namespace transf { namespace detail {
|
||||
|
||||
|
||||
class TransformationPluginForwarder {
|
||||
public:
|
||||
static RTI_RoutingServiceTransformationPlugin * create_plugin(
|
||||
TransformationPlugin *transformation_plugin)
|
||||
{
|
||||
RTI_RoutingServiceTransformationPlugin *native_plugin = NULL;
|
||||
RTIOsapiHeap_allocateStructure(
|
||||
&native_plugin,
|
||||
struct RTI_RoutingServiceTransformationPlugin);
|
||||
rti::core::check_create_entity(
|
||||
native_plugin,
|
||||
"RTI_RoutingServiceTransformationPlugin");
|
||||
RTI_RoutingServiceTransformationPlugin_initialize(native_plugin);
|
||||
|
||||
// Set adapter version
|
||||
rti::config::LibraryVersion version = transformation_plugin->get_version();
|
||||
native_plugin->plugin_version.major = version.major_version();
|
||||
native_plugin->plugin_version.minor = version.minor_version();
|
||||
native_plugin->plugin_version.release = version.release_version();
|
||||
|
||||
// Initiallize adapter methods
|
||||
native_plugin->user_object = static_cast<void *>(transformation_plugin);
|
||||
native_plugin->transformation_plugin_delete =
|
||||
TransformationPluginForwarder::delete_plugin;
|
||||
native_plugin->transformation_plugin_create_transformation =
|
||||
TransformationPluginForwarder::create_transformation;
|
||||
native_plugin->transformation_plugin_delete_transformation =
|
||||
TransformationPluginForwarder::delete_transformation;
|
||||
native_plugin->transformation_transform =
|
||||
TransformationForwarder::transform;
|
||||
native_plugin->transformation_return_loan =
|
||||
TransformationForwarder::return_loan;
|
||||
native_plugin->transformation_update =
|
||||
TransformationForwarder::update;
|
||||
|
||||
return native_plugin;
|
||||
}
|
||||
|
||||
static void delete_plugin(
|
||||
RTI_RoutingServiceTransformationPlugin *native_plugin,
|
||||
RTI_RoutingServiceEnvironment *)
|
||||
{
|
||||
TransformationPlugin *plugin = static_cast<TransformationPlugin *>(
|
||||
native_plugin->user_object);
|
||||
// Plug-in is destructor not allowed to throw
|
||||
delete plugin;
|
||||
RTIOsapiHeap_freeStructure(native_plugin);
|
||||
}
|
||||
|
||||
static RTI_RoutingServiceTransformation create_transformation(
|
||||
struct RTI_RoutingServiceTransformationPlugin *native_plugin,
|
||||
const struct RTI_RoutingServiceTypeInfo *input_type_info,
|
||||
const struct RTI_RoutingServiceTypeInfo *output_type_info,
|
||||
const struct RTI_RoutingServiceProperties *native_properties,
|
||||
RTI_RoutingServiceEnvironment *environment)
|
||||
{
|
||||
return TransformationForwarder::create_native(
|
||||
static_cast<TransformationPlugin *>(native_plugin->user_object),
|
||||
input_type_info,
|
||||
output_type_info,
|
||||
native_properties,
|
||||
environment);
|
||||
|
||||
}
|
||||
|
||||
static void delete_transformation(
|
||||
struct RTI_RoutingServiceTransformationPlugin *native_plugin,
|
||||
RTI_RoutingServiceTransformation native_transformation,
|
||||
RTI_RoutingServiceEnvironment *environment)
|
||||
{
|
||||
TransformationForwarder::delete_native(
|
||||
static_cast<TransformationPlugin *>(native_plugin->user_object),
|
||||
native_transformation,
|
||||
environment);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
}}}}
|
||||
|
||||
#endif // RTI_ROUTING_TRANSF_DETAIL_TRANSFORMATION_PLUGIN_FORWARDER_HPP_
|
||||
Reference in new issue
Block a user