This commit is contained in:
2025-09-24 10:53:28 +08:00
commit f8e4df77fb
856 changed files with 140098 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
#ifndef OMG_DDS_SUB_ANY_DATA_READER_HPP_
#define OMG_DDS_SUB_ANY_DATA_READER_HPP_
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <dds/sub/detail/AnyDataReader.hpp>
namespace dds
{
namespace sub
{
typedef ::dds::sub::detail::AnyDataReader AnyDataReader;
}
}
#endif /* OMG_DDS_SUB_ANY_DATA_READER_HPP_ */

View File

@@ -0,0 +1,150 @@
#ifndef OMG_DDS_SUB_ANY_DATA_READER_LISTENER_HPP_
#define OMG_DDS_SUB_ANY_DATA_READER_LISTENER_HPP_
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <dds/core/refmacros.hpp>
#include <dds/core/status/Status.hpp>
#include <dds/sub/AnyDataReader.hpp>
namespace dds
{
namespace sub
{
/**
* @brief
* AnyDataReader events Listener
*
* Because Subscriber and DomainParticipant do not have knowledge of data types,
* they have to use non-data-type-listeners. In other words Any* listeners.
*
* <b><i>
* All operations for this interface must be implemented in the user-defined class, it is
* up to the application whether an operation is empty or contains some functionality.
*
* This class is used as a base for other listeners and is not used on its own.
* </i></b>
*
* @see dds::sub::SubscriberListener
* @see dds::domain::DomainParticipantListener
*/
class OMG_DDS_API AnyDataReaderListener
{
public:
/** @cond */
typedef ::dds::core::smart_ptr_traits<AnyDataReaderListener>::ref_type ref_type;
/** @endcond */
public:
/** @cond */
virtual ~AnyDataReaderListener() { }
/** @endcond */
public:
/** @copydoc dds::sub::DataReaderListener::on_requested_deadline_missed() */
virtual void on_requested_deadline_missed(
AnyDataReader& reader,
const dds::core::status::RequestedDeadlineMissedStatus& status) = 0;
/** @copydoc dds::sub::DataReaderListener::on_requested_incompatible_qos() */
virtual void on_requested_incompatible_qos(
AnyDataReader& reader,
const dds::core::status::RequestedIncompatibleQosStatus& status) = 0;
/** @copydoc dds::sub::DataReaderListener::on_sample_rejected() */
virtual void on_sample_rejected(
AnyDataReader& reader,
const dds::core::status::SampleRejectedStatus& status) = 0;
/** @copydoc dds::sub::DataReaderListener::on_liveliness_changed() */
virtual void on_liveliness_changed(
AnyDataReader& reader,
const dds::core::status::LivelinessChangedStatus& status) = 0;
/** @copydoc dds::sub::DataReaderListener::on_data_available() */
virtual void on_data_available(AnyDataReader& reader) = 0;
/** @copydoc dds::sub::DataReaderListener::on_subscription_matched() */
virtual void on_subscription_matched(
AnyDataReader& reader,
const dds::core::status::SubscriptionMatchedStatus& status) = 0;
/** @copydoc dds::sub::DataReaderListener::on_sample_lost() */
virtual void on_sample_lost(
AnyDataReader& reader,
const dds::core::status::SampleLostStatus& status) = 0;
};
/**
* @brief
* AnyDataReader events Listener
*
* This listener is just like AnyDataReaderListener, except
* that the application doesn't have to implement all operations.
*
* This class is used as a base for other listeners and is not used on its own.
*
* @see dds::sub::AnyDataReaderListener
* @see dds::sub::NoOpSubscriberListener
* @see dds::domain::NoOpDomainParticipantListener
*/
class OMG_DDS_API NoOpAnyDataReaderListener : public virtual AnyDataReaderListener
{
/** @cond
* All these functions have already been documented in the non-NoOp listener.
* Ignore these functions for the doxygen API documentation for clarity.
*/
public:
virtual ~NoOpAnyDataReaderListener() { }
public:
virtual void on_requested_deadline_missed(
AnyDataReader&,
const dds::core::status::RequestedDeadlineMissedStatus&) { }
virtual void on_requested_incompatible_qos(
AnyDataReader&,
const dds::core::status::RequestedIncompatibleQosStatus&) { }
virtual void on_sample_rejected(
AnyDataReader&,
const dds::core::status::SampleRejectedStatus&) { }
virtual void on_liveliness_changed(
AnyDataReader&,
const dds::core::status::LivelinessChangedStatus&) { }
virtual void on_data_available(AnyDataReader&) { }
virtual void on_subscription_matched(
AnyDataReader&,
const dds::core::status::SubscriptionMatchedStatus&) { }
virtual void on_sample_lost(
AnyDataReader&,
const dds::core::status::SampleLostStatus&) { }
/** @endcond */
};
}
}
#endif /* OMG_DDS_SUB_ANY_DATA_READER_LISTENER_HPP_ */

View File

@@ -0,0 +1,33 @@
#ifndef OMG_DDS_SUB_COHERENT_ACCESS_HPP_
#define OMG_DDS_SUB_COHERENT_ACCESS_HPP_
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <dds/sub/detail/CoherentAccess.hpp>
namespace dds
{
namespace sub
{
typedef dds::sub::detail::CoherentAccess CoherentAccess;
}
}
#endif /* OMG_DDS_SUB_COHERENT_ACCESS_HPP_ */

View File

@@ -0,0 +1,81 @@
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OMG_DDS_SUB_DATA_READER_HPP_
#define OMG_DDS_SUB_DATA_READER_HPP_
#include <dds/sub/detail/DataReader.hpp>
namespace dds {
namespace sub {
template < typename T,
template <typename Q> class DELEGATE = dds::sub::detail::DataReader >
class DataReader;
}
}
#include <dds/sub/TDataReader.hpp>
// = Manipulators
namespace dds
{
namespace sub
{
namespace functors
{
typedef dds::sub::functors::detail::MaxSamplesManipulatorFunctor MaxSamplesManipulatorFunctor;
typedef dds::sub::functors::detail::ContentFilterManipulatorFunctor ContentFilterManipulatorFunctor;
typedef dds::sub::functors::detail::StateFilterManipulatorFunctor StateFilterManipulatorFunctor;
typedef dds::sub::functors::detail::InstanceManipulatorFunctor InstanceManipulatorFunctor;
typedef dds::sub::functors::detail::NextInstanceManipulatorFunctor NextInstanceManipulatorFunctor;
}
}
}
namespace dds
{
namespace sub
{
template <typename SELECTOR>
SELECTOR& read(SELECTOR& selector);
template <typename SELECTOR>
SELECTOR& take(SELECTOR& selector);
inline dds::sub::functors::MaxSamplesManipulatorFunctor
max_samples(uint32_t n);
inline dds::sub::functors::ContentFilterManipulatorFunctor
content(const dds::sub::Query& query);
inline dds::sub::functors::StateFilterManipulatorFunctor
state(const dds::sub::status::DataState& s);
inline dds::sub::functors::InstanceManipulatorFunctor
instance(const dds::core::InstanceHandle& h);
inline dds::sub::functors::NextInstanceManipulatorFunctor
next_instance(const dds::core::InstanceHandle& h);
}
}
#endif /* OMG_DDS_SUB_DATA_READER_HPP_ */

View File

@@ -0,0 +1,370 @@
#ifndef OMG_DDS_SUB_DATA_READER_LISTENER_HPP_
#define OMG_DDS_SUB_DATA_READER_LISTENER_HPP_
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <dds/core/status/Status.hpp>
namespace dds
{
namespace sub
{
template <typename T>
class DataReaderListener;
template <typename T>
class NoOpDataReaderListener;
}
}
/**
* @brief
* DataReader events Listener
*
* Since a DataReader is an Entity, it has the ability to have a Listener
* associated with it. In this case, the associated Listener should be of type
* DataReaderListener. This interface must be implemented by the
* application. A user-defined class must be provided by the application which must
* extend from the DataReaderListener class.
*
* <b><i>
* All operations for this interface must be implemented in the user-defined class, it is
* up to the application whether an operation is empty or contains some functionality.
* </i></b>
*
* The DataReaderListener provides a generic mechanism (actually a
* callback function) for the Data Distribution Service to notify the application of
* relevant asynchronous status change events, such as a missed deadline, violation of
* a QosPolicy setting, etc. The DataReaderListener is related to
* changes in communication status StatusConditions.
*
* @code{.cpp}
* // Application example listener
* class ExampleListener :
* public virtual dds::sub::DataReaderListener<Foo::Bar>
* {
* public:
* virtual void on_requested_deadline_missed (
* dds::sub::DataReader<Foo::Bar>& reader,
* const dds::core::status::RequestedDeadlineMissedStatus & status)
* {
* std::cout << "on_requested_deadline_missed" << std::endl;
* }
*
* virtual void on_requested_incompatible_qos (
* dds::sub::DataReader<Foo::Bar>& reader,
* const dds::core::status::RequestedIncompatibleQosStatus & status)
* {
* std::cout << "on_requested_incompatible_qos" << std::endl;
* }
*
* virtual void on_sample_rejected (
* dds::sub::DataReader<Foo::Bar>& reader,
* const dds::core::status::SampleRejectedStatus & status)
* {
* std::cout << "on_sample_rejected" << std::endl;
* }
*
* virtual void on_liveliness_changed (
* dds::sub::DataReader<Foo::Bar>& reader,
* const dds::core::status::LivelinessChangedStatus & status)
* {
* std::cout << "on_liveliness_changed" << std::endl;
* }
*
* virtual void on_data_available (
* dds::sub::DataReader<Foo::Bar>& reader)
* {
* std::cout << "on_data_available" << std::endl;
* }
*
* virtual void on_subscription_matched (
* dds::sub::DataReader<Foo::Bar>& reader,
* const dds::core::status::SubscriptionMatchedStatus & status)
* {
* std::cout << "on_subscription_matched" << std::endl;
* }
*
* virtual void on_sample_lost (
* dds::sub::DataReader<Foo::Bar>& reader,
* const dds::core::status::SampleLostStatus & status)
* {
* std::cout << "on_sample_lost" << std::endl;
* }
* };
*
* // Create DataReader with the listener
* dds::domain::DomainParticipant participant(org::eclipse::cyclonedds::domain::default_id());
* dds::topic::Topic<Foo::Bar> topic(participant, "TopicName");
* dds::sub::Subscriber subscriber(participant);
* dds::sub::DataReader<Foo::Bar> reader(subscriber,
* topic,
* subscriber.default_datareader_qos(),
* new ExampleListener(),
* dds::core::status::StatusMask::all());
*
* @endcode
*
* @see for more information: @ref DCPS_Modules_Subscription_DataReader "Data Reader"
* @see for more information: @ref DCPS_Modules_Infrastructure_Listener "Listener information"
*/
template <typename T>
class dds::sub::DataReaderListener
{
public:
/** @cond */
typedef typename ::dds::core::smart_ptr_traits<DataReaderListener>::ref_type ref_type;
/** @endcond */
public:
/** @cond */
virtual ~DataReaderListener() { }
/** @endcond */
public:
/**
* This operation called by the Data Distribution Service when the deadline
* that the DataReader was expecting through its DeadlineQosPolicy was not
* respected for a specific instance.
*
* The implementation may be left empty when this
* functionality is not needed. This operation will only be called when the relevant
* DataReaderListener is installed and enabled for the
* StatusMask::requested_deadline_missed().
*
* @param reader contain a pointer to the DataReader for which
* the deadline was missed (this is an input to the application provided by the Data
* Distribution Service).
* @param status contain the
* RequestedDeadlineMissedStatus object (this is an input to the application
* provided by the Data Distribution Service).
*/
virtual void on_requested_deadline_missed(
DataReader<T>& reader,
const dds::core::status::RequestedDeadlineMissedStatus& status) = 0;
/**
* This operation is called by the Data Distribution Service when the
* RequestedIncompatibleQosStatus changes.
*
* The implementation may be
* left empty when this functionality is not needed. This operation will only be called
* when the relevant DataReaderListener is installed and enabled for the
* StatusMask::requested_incompatible_qos().
*
* The Data Distribution Service will provide a reference to the DataReader in the
* parameter reader and the RequestedIncompatibleQosStatus object in the
* parameter status, for use by the application.
*
* When the DataReaderListener on the
* DataReader is not enabled with the StatusMask::requested_incompatible_qos(),
* the RequestedIncompatibleQosStatus change will propagate to the SubscriberListener
* of the Subscriber (if enabled) or to the DomainParticipantListener of the
* DomainParticipant (if enabled).
*
* @param reader the DataReader provided by the Data Distribution Service.
* @param status the RequestedIncompatibleQosStatus object provided by the
* Data Distribution Service.
*/
virtual void on_requested_incompatible_qos(
DataReader<T>& reader,
const dds::core::status::RequestedIncompatibleQosStatus& status) = 0;
/**
* This operation called by the Data Distribution Service when a (received)
* sample has been rejected.
*
* Samples may be rejected by the DataReader when it
* runs out of resource_limits to store incoming samples. Usually this means that
* old samples need to be consumed (for example by taking them instead of
* reading them) to make room for newly incoming samples.
*
* The implementation may be left empty when this functionality is not needed. This
* operation will only be called when the relevant DataReaderListener is installed
* and enabled with the StatusMask::sample_lost().
*
* @param reader contains a pointer to the DataReader for which
* a sample has been rejected (this is an input to the application provided by the
* Data Distribution Service).
* @param status contains the
* SampleRejectedStatus object (this is an input to the application provided by
* the Data Distribution Service).
*/
virtual void on_sample_rejected(
DataReader<T>& reader,
const dds::core::status::SampleRejectedStatus& status) = 0;
/**
* This operation is called by the Data Distribution Service when the liveliness of
* one or more DataWriter objects that were writing instances read through this
* DataReader has changed.
*
* In other words, some DataWriter have become
* “alive” or “not alive”. The implementation may be left empty when this
* functionality is not needed. This operation will only be called when the relevant
* DataReaderListener is installed and enabled for the
* StatusMask::liveliness_changed().
*
* @param reader contain a pointer to the DataReader for which
* the liveliness of one or more DataWriter objects has changed (this is an input
* to the application provided by the Data Distribution Service).
* @param status contain the
* LivelinessChangedStatus object (this is an input to the application
* provided by the Data Distribution Service).
*/
virtual void on_liveliness_changed(
DataReader<T>& reader,
const dds::core::status::LivelinessChangedStatus& status) = 0;
/**
* This operation is called by the Data Distribution Service when new data is
* available for this DataReader.
*
* The implementation may be left empty when this
* functionality is not needed. This operation will only be called when the relevant
* DataReaderListener is installed and enabled for the
* StatusMask::data_available().
*
* The Data Distribution Service will provide a reference to the DataReader in the
* parameter reader for use by the application.
*
* The statuses StatusMask::data_on_readers() and StatusMask::data_available() will
* occur together. In case these status changes occur, the Data Distribution Service will
* look for an attached and activated SubscriberListener or
* DomainParticipantListener (in that order) for the enabled
* StatusMask::data_on_readers(). In case the StatusMask::data_on_readers() can not be
* handled, the Data Distribution Service will look for an attached and activated
* DataReaderListener, SubscriberListener or DomainParticipantListener for the enabled
* StatusMask::data_available() (in that order).
*
* Note that if on_data_on_readers is called, then the Data Distribution Service
* will not try to call on_data_available, however, the application can force a call
* to the DataReader objects that have data by means of the Subscriber::notify_datareaders()
* operation.
*
* @param reader contain a pointer to the DataReader for which
* data is available (this is an input to the application provided by the Data
* Distribution Service).
*/
virtual void on_data_available(DataReader<T>& reader) = 0;
/**
* This operation is called by the Data
* Distribution Service when a new match has been discovered for the current
* subscription, or when an existing match has ceased to exist.
*
* Usually this means that
* a new DataWriter that matches the Topic and that has compatible Qos as the current
* DataReader has either been discovered, or that a previously discovered DataWriter
* has ceased to be matched to the current DataReader. A DataWriter may cease to
* match when it gets deleted, when it changes its Qos to a value that is incompatible
* with the current DataReader or when either the DataReader or the DataWriter
* has chosen to put its matching counterpart on its ignore-list using the
* dds::sub::ignore or dds::pub::ignore operations.
*
* The implementation of this Listener operation may be left empty when this
* functionality is not needed: it will only be called when the relevant
* DataReaderListener is installed and enabled for the
* StatusMask::subscription_matched().
*
* @param reader contains a pointer to the DataReader for which
* a match has been discovered (this is an input to the application provided by the
* Data Distribution Service).
* @param status contains the
* SubscriptionMatchedStatus object (this is an input to the application
* provided by the Data Distribution Service).
*/
virtual void on_subscription_matched(
DataReader<T>& reader,
const dds::core::status::SubscriptionMatchedStatus& status) = 0;
/**
* <b><i>
* NOTE: This operation is not yet implemented. It is scheduled for a future release.
* </i></b>
*
* @param reader the DataReader the Listener is applied to
* @param status the SampleLostStatus status
*/
virtual void on_sample_lost(
DataReader<T>& reader,
const dds::core::status::SampleLostStatus& status) = 0;
};
/**
* @brief
* DataReader events Listener
*
* This listener is just like DataReaderListener, except
* that the application doesn't have to implement all operations.
*
* @code{.cpp}
* class ExampleListener : public virtual dds::sub::NoOpDataReaderListener<Foo::Bar>
* {
* // Not necessary to implement any Listener operations.
* };
* @endcode
*
* @see dds::sub::DataReaderListener
*/
template <typename T>
class dds::sub::NoOpDataReaderListener : public virtual DataReaderListener<T>
{
/** @cond
* All these functions have already been documented in the non-NoOp listener.
* Ignore these functions for the doxygen API documentation for clarity.
*/
public:
typedef typename ::dds::core::smart_ptr_traits<NoOpDataReaderListener>::ref_type ref_type;
public:
virtual ~NoOpDataReaderListener() { }
public:
virtual void on_requested_deadline_missed(
DataReader<T>&,
const dds::core::status::RequestedDeadlineMissedStatus&) { }
virtual void on_requested_incompatible_qos(
DataReader<T>&,
const dds::core::status::RequestedIncompatibleQosStatus&) { }
virtual void on_sample_rejected(
DataReader<T>&,
const dds::core::status::SampleRejectedStatus&) { }
virtual void on_liveliness_changed(
DataReader<T>&,
const dds::core::status::LivelinessChangedStatus&) { }
virtual void on_data_available(
DataReader<T>&) { }
virtual void on_subscription_matched(
DataReader<T>&,
const dds::core::status::SubscriptionMatchedStatus&) { }
virtual void on_sample_lost(
DataReader<T>&,
const dds::core::status::SampleLostStatus&) { }
/** @endcond */
};
#endif /* OMG_DDS_SUB_DATA_READER_LISTENER_HPP_ */

View File

@@ -0,0 +1,31 @@
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OMG_DDS_SUB_GENERATION_COUNT_HPP_
#define OMG_DDS_SUB_GENERATION_COUNT_HPP_
#include <dds/sub/detail/GenerationCount.hpp>
namespace dds
{
namespace sub
{
typedef detail::GenerationCount GenerationCount;
}
}
#endif /* OMG_DDS_SUB_GENERATION_COUNT_HPP_ */

View File

@@ -0,0 +1,215 @@
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OMG_DDS_SUB_TLOANED_SAMPLES_HPP_
#define OMG_DDS_SUB_TLOANED_SAMPLES_HPP_
#include <dds/core/ref_traits.hpp>
#include <dds/sub/SampleRef.hpp>
#include <dds/sub/detail/LoanedSamples.hpp>
/** @cond */
namespace dds
{
namespace sub
{
template <typename T,
template <typename Q> class DELEGATE = dds::sub::detail::LoanedSamples>
class LoanedSamples;
// Used by C++11 compilers to allow for using LoanedSamples
// and SharedSamples in a range-based for-loop.
template <typename T> typename T::const_iterator cbegin(const T& t);
template <typename T> typename T::const_iterator cend(const T& t);
}
}
/** @endcond */
/**
* @brief
* This class encapsulates and automates the management of loaned samples.
*
* It is a container which is used to hold samples which have been read
* or taken by the DataReader. Samples are effectively "loaned" from the
* DataReader to avoid the need to copy the data. When the LoanedSamples
* container goes out of scope the loan is automatically returned.
*
* LoanedSamples maintains a ref count so that the loan will only be
* returned once all copies of the same LoanedSamples have been destroyed.
*
* @anchor anchor_dds_sub_loanedsamples_example
* @code{.cpp}
* dds::domain::DomainParticipant participant(org::eclipse::cyclonedds::domain::default_id());
* dds::topic::Topic<Foo::Bar> topic(participant, "TopicName");
* dds::sub::Subscriber subscriber(participant);
* dds::sub::DataReader<Foo::Bar> reader(subscriber, topic);
*
* // Assume there is data to read
* {
* dds::sub::LoanedSamples<Foo::Bar> samples = reader.read();
* dds::sub::LoanedSamples<Foo::Bar>::const_iterator it;
* for (it = samples.begin(); it != samples.end(); ++it) {
* const dds::sub::Sample<Foo::Bar>& sample = *it;
* const Foo::Bar& data = sample.data();
* const dds::sub::SampleInfo& info = sample.info();
* // Use sample data and meta information.
* }
*
* function(samples);
* }
* // LoanedSamples out of scope. Whether the loan is returned, depends what the reference
* // count of the LoanedSamples is. That again, depends on what the function() did with it.
* // Maybe function() stored the LoanedSamples, maybe not. Whatever the case, LoanedSamples
* // takes care of the loan and resource handling.
* @endcode
*
* @see for more information: @ref DCPS_Modules_Subscription_DataSample "DataSample"
* @see for more information: @ref DCPS_Modules_Subscription_SampleInfo "SampleInfo"
* @see for more information: @ref DCPS_Modules_Subscription "Subscription"
*/
template <typename T, template <typename Q> class DELEGATE>
class dds::sub::LoanedSamples
{
public:
/**
* Convenience typedef for the type of the data sample.
*/
typedef T DataType;
/**
* Convenience typedef for the iterator over the loaned samples.
*/
typedef typename DELEGATE<T>::const_iterator const_iterator;
/** @cond */
typedef typename dds::core::smart_ptr_traits< DELEGATE<T> >::ref_type DELEGATE_REF_T;
/** @endcond */
public:
/**
* Constructs a LoanedSamples instance.
*/
LoanedSamples();
/**
* Implicitly return the loan if this is the last object with a reference to the
* contained loan.
*/
~LoanedSamples();
/**
* Copies a LoanedSamples instance.
*
* No actual data samples are copied.<br>
* Just references and reference counts are updated.
*/
LoanedSamples(const LoanedSamples& other);
/**
* Move-constructs a LoanedSamples instance.
*
* No actual data samples are copied.<br>
* Just references and reference counts are updated.
*/
LoanedSamples(LoanedSamples&& other);
/**
* Copy-assigns a LoanedSamples instance to another.
*
* No actual data samples are copied.<br>
* Just references and reference counts are updated.
*/
LoanedSamples& operator=(const LoanedSamples& other) = default;
/**
* Move-assigns a LoanedSamples instance to another.
*
* No actual data samples are copied.<br>
* Just references and reference counts are updated.
*/
LoanedSamples& operator=(LoanedSamples&& other) = default;
public:
/**
* Gets an iterator pointing to the first sample in the LoanedSamples container.
*
* See @ref anchor_dds_sub_loanedsamples_example "example".
*
* @return an iterator pointing to the first sample
*/
const_iterator begin() const;
/**
* Gets an iterator pointing to the end of the LoanedSamples container.
*
* See @ref anchor_dds_sub_loanedsamples_example "example".
*
* @return an iterator pointing to the end of the container
*/
const_iterator end() const;
/**
* @cond
* The delegate part of the LoanedSamples should not be part of the API.
*/
/**
* Gets the delegate.
*
* @return the delegate
*/
const DELEGATE_REF_T& delegate() const;
/**
* Gets the delegate.
*
* @return the delegate
*/
DELEGATE_REF_T& delegate();
/** @endcond */
/**
* Gets the number of samples within the LoanedSamples container.
*
* @return the number of samples
*/
uint32_t length() const;
private:
DELEGATE_REF_T delegate_;
};
namespace dds
{
namespace sub
{
/**
* Move loan and its ownership to a new LoanedSamples object.
*
* @return LoanedSampless
*/
template <typename T, template <typename Q> class D>
LoanedSamples<T, D >
move(LoanedSamples<T, D >& a);
}
}
#include <dds/sub/detail/LoanedSamplesImpl.hpp>
#endif /* OMG_DDS_SUB_TLOANED_SAMPLES_HPP_ */

View File

@@ -0,0 +1,32 @@
#ifndef OMG_DDS_SUB_QUERY_HPP_
#define OMG_DDS_SUB_QUERY_HPP_
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <dds/sub/detail/Query.hpp>
namespace dds
{
namespace sub
{
typedef dds::sub::detail::Query Query;
}
}
#endif /* OMG_DDS_SUB_QUERY_HPP_ */

View File

@@ -0,0 +1,31 @@
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OMG_DDS_SUB_RANK_HPP_
#define OMG_DDS_SUB_RANK_HPP_
#include <dds/sub/detail/Rank.hpp>
namespace dds
{
namespace sub
{
typedef detail::Rank Rank;
}
}
#endif /* OMG_DDS_SUB_RANK_HPP_ */

View File

@@ -0,0 +1,40 @@
#ifndef OMG_DDS_SUB_SAMPLE_HPP_
#define OMG_DDS_SUB_SAMPLE_HPP_
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <dds/sub/detail/Sample.hpp>
namespace dds
{
namespace sub
{
template <typename T, template <typename Q> class DELEGATE = dds::sub::detail::Sample >
class Sample;
}
}
/**
* @todo RTF Issue - added include here
* @note This include needs to be here to enable MSVC compilation,
* or TSample.hpp must set the above default DELEGATE instead of it being here.
*/
#include <dds/sub/TSample.hpp>
#endif /* OMG_DDS_SUB_SAMPLE_HPP_ */

View File

@@ -0,0 +1,32 @@
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OMG_DDS_SUB_SAMPLE_INFO_HPP_
#define OMG_DDS_SUB_SAMPLE_INFO_HPP_
#include <dds/sub/detail/SampleInfo.hpp>
namespace dds
{
namespace sub
{
typedef detail::SampleInfo SampleInfo;
}
}
#endif /* OMG_DDS_SUB_SAMPLE_INFO_HPP_ */

View File

@@ -0,0 +1,40 @@
#ifndef OMG_DDS_SUB_SAMPLEREF_HPP_
#define OMG_DDS_SUB_SAMPLEREF_HPP_
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <dds/sub/detail/SampleRef.hpp>
namespace dds
{
namespace sub
{
template <typename T, template <typename Q> class DELEGATE = dds::sub::detail::SampleRef >
class SampleRef;
}
}
/**
* @todo RTF Issue - added include here
* @note This include needs to be here to enable MSVC compilation,
* or TSample.hpp must set the above default DELEGATE instead of it being here.
*/
#include <dds/sub/TSampleRef.hpp>
#endif /* OMG_DDS_SUB_SAMPLEREF_HPP_ */

View File

@@ -0,0 +1,126 @@
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OMG_DDS_SUB_SHARED_SAMPLES_HPP_
#define OMG_DDS_SUB_SHARED_SAMPLES_HPP_
#include <dds/core/Reference.hpp>
#include <dds/sub/Sample.hpp>
#include <dds/sub/LoanedSamples.hpp>
#include <dds/sub/detail/SharedSamples.hpp>
/** @cond */
namespace dds
{
namespace sub
{
template <typename T,
template <typename Q> class DELEGATE = detail::SharedSamples>
class SharedSamples;
}
}
/** @endcond */
/**
* @brief
* This class encapsulates and automates the management of loaned samples.
*
* @note The specification of this class is not yet finished. It will possibly
* change in the future. Anyway, this class is basically a copy of LoanedSamples
* when considering its functionality. So, anything you would want to do with this
* class can also be done by the LoanedSamples.
*/
template <typename T, template <typename Q> class DELEGATE>
class dds::sub::SharedSamples
{
public:
typedef T DataType;
typedef typename DELEGATE<T>::const_iterator const_iterator;
typedef typename dds::core::smart_ptr_traits< DELEGATE<T> >::ref_type DELEGATE_REF_T;
public:
/**
* Constructs a SharedSamples instance.
*/
SharedSamples();
/**
* Constructs an instance of SharedSamples and
* removes the ownership of the loan from the LoanedSamples.
* As a result the destruction of the LoanedSamples object
* will have no effect on loaned data. Loaned data will be returned
* automatically once the delegate of this reference type will have a
* zero reference count.
*
* @param ls the loaned samples
*
*/
SharedSamples(dds::sub::LoanedSamples<T> ls);
/**
* Copies a SharedSamples instance.
*/
SharedSamples(const SharedSamples& other);
~SharedSamples();
public:
/**
* Gets an iterator pointing to the beginning of the samples.
*
* @return an iterator pointing to the beginning of the samples
*/
const_iterator begin() const;
/**
* Gets an iterator pointing to the beginning of the samples.
*
* @return an iterator pointing to the beginning of the samples
*/
const_iterator end() const;
/**
* Gets the delegate.
*
* @return the delegate
*/
const DELEGATE_REF_T& delegate() const;
/**
* Gets the delegate.
*
* @return the delegate
*/
DELEGATE_REF_T& delegate();
/**
* Returns the number of samples.
*
* @return the number of samples
*/
uint32_t length() const;
private:
DELEGATE_REF_T delegate_;
};
#include <dds/sub/detail/SharedSamplesImpl.hpp>
#endif /* OMG_DDS_SUB_SHARED_SAMPLES_HPP_ */

View File

@@ -0,0 +1,32 @@
#ifndef OMG_DDS_SUB_SUBSCRIBER_HPP_
#define OMG_DDS_SUB_SUBSCRIBER_HPP_
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <dds/sub/detail/Subscriber.hpp>
namespace dds
{
namespace sub
{
typedef ::dds::sub::detail::Subscriber Subscriber;
}
}
#endif /* OMG_DDS_SUB_SUBSCRIBER_HPP_ */

View File

@@ -0,0 +1,207 @@
#ifndef OMG_DDS_SUB_SUBSCRIBER_LISTENER_HPP_
#define OMG_DDS_SUB_SUBSCRIBER_LISTENER_HPP_
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <dds/sub/AnyDataReaderListener.hpp>
#include <dds/sub/Subscriber.hpp>
namespace dds
{
namespace sub
{
DDSCXX_WARNING_MSVC_OFF(4250)
/**
* @brief
* Subscriber events Listener
*
* Since a Subscriber is an Entity, it has the ability to have a Listener
* associated with it. In this case, the associated Listener should be of type
* SubscriberListener. This interface must be implemented by the
* application. A user-defined class must be provided by the application which must
* extend from the SubscriberListener class.
*
* <b><i>
* All operations for this interface must be implemented in the user-defined class, it is
* up to the application whether an operation is empty or contains some functionality.
* </i></b>
*
* The SubscriberListener provides a generic mechanism (actually a
* callback function) for the Data Distribution Service to notify the application of
* relevant asynchronous status change events, such as a missed deadline, violation of
* a QosPolicy setting, etc. The SubscriberListener is related to
* changes in communication status StatusConditions.
*
* @code{.cpp}
* // Application example listener
* class ExampleListener :
* public virtual dds::sub::SubscriberListener
* {
* public:
* virtual void on_requested_deadline_missed (
* dds::sub::AnyDataReader& reader,
* const dds::core::status::RequestedDeadlineMissedStatus & status)
* {
* std::cout << "on_requested_deadline_missed" << std::endl;
* }
*
* virtual void on_requested_incompatible_qos (
* dds::sub::AnyDataReader& reader,
* const dds::core::status::RequestedIncompatibleQosStatus & status)
* {
* std::cout << "on_requested_incompatible_qos" << std::endl;
* }
*
* virtual void on_sample_rejected (
* dds::sub::AnyDataReader& reader,
* const dds::core::status::SampleRejectedStatus & status)
* {
* std::cout << "on_sample_rejected" << std::endl;
* }
*
* virtual void on_liveliness_changed (
* dds::sub::AnyDataReader& reader,
* const dds::core::status::LivelinessChangedStatus & status)
* {
* std::cout << "on_liveliness_changed" << std::endl;
* }
*
* virtual void on_data_available (
* dds::sub::AnyDataReader& reader)
* {
* std::cout << "on_data_available" << std::endl;
* }
*
* virtual void on_subscription_matched (
* dds::sub::AnyDataReader& reader,
* const dds::core::status::SubscriptionMatchedStatus & status)
* {
* std::cout << "on_subscription_matched" << std::endl;
* }
*
* virtual void on_sample_lost (
* dds::sub::AnyDataReader& reader,
* const dds::core::status::SampleLostStatus & status)
* {
* std::cout << "on_sample_lost" << std::endl;
* }
*
* virtual void on_data_on_readers (
* dds::sub::Subscriber& subs)
* {
* std::cout << "on_data_on_readers" << std::endl;
* }
* };
*
* // Create Subscriber with the listener
* dds::domain::DomainParticipant participant(org::eclipse::cyclonedds::domain::default_id());
* dds::sub::Subscriber subscriber(participant,
* participant.default_subscriber_qos(),
* new ExampleListener(),
* dds::core::status::StatusMask::all());
*
* @endcode
*
* @see for more information: @ref DCPS_Modules_Subscriber "Subscriber"
* @see for more information: @ref DCPS_Modules_Infrastructure_Listener "Listener information"
*/
class OMG_DDS_API SubscriberListener : public virtual AnyDataReaderListener
{
public:
/** @cond */
typedef ::dds::core::smart_ptr_traits<SubscriberListener>::ref_type ref_type;
/** @endcond */
public:
/** @cond */
virtual ~SubscriberListener() { }
/** @endcond */
public:
/**
* This operation called by the Data Distribution Service when new data is
* available for this Subscriber.
*
* The implementation may be left empty when this
* functionality is not needed. This operation will only be called when the relevant
* SubscriberListener is installed and enabled with the
* StatusMask::data_on_readers().
*
* The statuses on_data_on_readers() and on_data_available() will
* occur together. In case these status changes occur, the Data Distribution Service will
* look for an attached and activated SubscriberListener or
* DomainParticipantListener (in that order) for the enabled
* StatusMask::data_on_readers(). In case the StatusMask::data_on_readers() can not be
* handled, the Data Distribution Service will look for an attached and activated
* DataReaderListener, SubscriberListener or
* DomainParticipantListener for the enabled StatusMask::data_available() (in that
* order).
*
* Note that if on_data_on_readers() is called, then the Data Distribution Service
* will not try to call on_data_available(), however, the application can force a call
* to the callback function on_data_available of DataReaderListener objects
* that have data by means of the Subscriber::notify_datareaders() operation.
*
* @param sub contain a pointer to the Subscriber for which data is available (this is
* an input to the application provided by the Data Distribution Service).
*/
virtual void on_data_on_readers(Subscriber& sub) = 0;
};
/**
* @brief
* Subscriber events Listener
*
* This listener is just like SubscriberListener, except
* that the application doesn't have to implement all operations.
*
* @code{.cpp}
* class ExampleListener : public virtual dds::sub::NoOpSubscriberListener
* {
* // Not necessary to implement any Listener operations.
* };
* @endcode
*
* @see dds::sub::SubscriberListener
*/
class OMG_DDS_API NoOpSubscriberListener :
public virtual SubscriberListener,
public virtual NoOpAnyDataReaderListener
{
/** @cond
* All these functions have already been documented in the non-NoOp listener.
* Ignore these functions for the doxygen API documentation for clarity.
*/
public:
virtual ~NoOpSubscriberListener() { }
public:
virtual void on_data_on_readers(Subscriber&) { }
/** @endcond */
};
DDSCXX_WARNING_MSVC_ON(4250)
}
}
#endif /* OMG_DDS_SUB_SUBSCRIBER_LISTENER_HPP_ */

View File

@@ -0,0 +1,414 @@
#ifndef OMG_TDDS_SUB_ANY_DATA_READER_HPP_
#define OMG_TDDS_SUB_ANY_DATA_READER_HPP_
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <dds/core/TEntity.hpp>
#include <dds/sub/Subscriber.hpp>
#include <dds/sub/qos/DataReaderQos.hpp>
#include <dds/topic/TopicDescription.hpp>
#include <dds/core/macros.hpp>
namespace dds
{
namespace sub
{
template <typename DELEGATE>
class TAnyDataReader;
}
}
/**
* @brief
* Typeless base class for the typed DataReader.
*
* DataReaders are created type specific (fi DataReader<Foo::Bar> reader). However, there
* are many places in the API (and possibly application) where the type can not be known
* while still some DataReader has to be passed around, stored or even typeless functionality
* called.<br>
* Main examples in the API that need typeless DataReader are: Subscriber, SubscriberListener
* and DomainParticipantListener.
*
* @see dds::sub::DataReader
*/
template <typename DELEGATE>
class dds::sub::TAnyDataReader : public dds::core::TEntity<DELEGATE>
{
public:
OMG_DDS_REF_TYPE_PROTECTED_DC(TAnyDataReader, dds::core::TEntity, DELEGATE)
#if 0
OMG_DDS_IMPLICIT_REF_BASE(TAnyDataReader)
#else
public:
template <typename H__>
TAnyDataReader(const H__& h)
{
if (h.is_nil()) {
/* We got a null object and are not really able to do a typecheck here. */
/* So, just set a null object. */
*this = dds::core::null;
} else {
this->::dds::core::Reference< DELEGATE_T >::impl_ = ::std::dynamic_pointer_cast< DELEGATE_T >(h.delegate());
if (h.delegate() != this->::dds::core::Reference< DELEGATE_T >::impl_) {
throw dds::core::IllegalOperationError(std::string("Attempted invalid cast: ") + typeid(h).name() + " to " + typeid(*this).name());
}
}
}
template <typename T__>
TAnyDataReader&
operator=(const T__& rhs) {
const TAnyDataReader &t = rhs;
if (this != &t) {
if (rhs.is_nil()) {
/* We got a null object and are not really able to do a typecheck here. */
/* So, just set a null object. */
*this = dds::core::null;
} else {
TAnyDataReader other(rhs);
/* Dont have to copy when the delegate impl is the same. */
if (other.delegate() != this->::dds::core::Reference< DELEGATE_T >::impl_) {
*this = other;
}
}
}
return *this;
}
#endif
OMG_DDS_COMPLETE_RULE_OF_FIVE_VIRTUAL_DEFAULT(TAnyDataReader)
//==========================================================================
// -- Entity Navigation API
/**
* Get the Subscriber that owns this DataReader.
*
* @return the Subscriber
* @throws dds::core::Error
* An internal error has occurred.
* @throws dds::core::NullReferenceError
* The entity was not properly created and references to dds::core::null.
* @throws dds::core::AlreadyClosedError
* The entity has already been closed.
*/
const dds::sub::Subscriber& subscriber() const;
/**
* Get the TopicDescription associated with this DataReader.
*
* @return the TopicDescription
* @throws dds::core::Error
* An internal error has occurred.
* @throws dds::core::NullReferenceError
* The entity was not properly created and references to dds::core::null.
* @throws dds::core::AlreadyClosedError
* The entity has already been closed.
*/
const dds::topic::TopicDescription& topic_description() const;
/**
* This operation will block the application thread until all "historical" data is
* received.
*
* This operation behaves differently for DataReader objects which have a
* non-VOLATILE dds::core::policy::Durability QosPolicy and for DataReader
* objects which have a VOLATILE dds::core::policy::Durability QosPolicy.
*
* As soon as an application enables a non-VOLATILE
* DataReader it will start receiving both "historical" data, i.e. the data that was
* written prior to the time the DataReader joined the domain, as well as any new
* data written by the DataWriter objects. There are situations where the application
* logic may require the application to wait until all "historical" data is received. This
* is the purpose of the wait_for_historical_data operation.
*
* As soon as an application enables a VOLATILE DataReader it
* will not start receiving "historical" data but only new data written by the
* DataWriter objects. By calling wait_for_historical_data the DataReader
* explicitly requests the Data Distribution Service to start receiving also the
* "historical" data and to wait until either all "historical" data is received, or the
* duration specified by the max_wait parameter has elapsed, whichever happens
* first.
*
* <i>Thread Blocking</i><br>
* The operation wait_for_historical_data blocks the calling thread until either
* all "historical" data is received, or the duration specified by the max_wait
* parameter elapses, whichever happens first. When the function returns normally,
* indicates that all the "historical" data was received. If the function throws
* TimeoutError, it indicates that max_wait elapsed before all the data was
* received.
*
* @param timeout the time to wait for historical data (can be dds::core::Duration::infinite())
* @throws dds::core::Error
* An internal error has occurred.
* @throws dds::core::NullReferenceError
* The entity was not properly created and references to dds::core::null.
* @throws dds::core::AlreadyClosedError
* The entity has already been closed.
* @throws dds::core::NotEnabledError
* The entity has not yet been enabled.
* @throws dds::core::TimeoutError
* Not all data is received before timeout elapsed.
* @throws dds::core::OutOfResourcesError
* The Data Distribution Service ran out of resources to
* complete this operation.
*/
void wait_for_historical_data(const dds::core::Duration& timeout);
//==========================================================================
// -- QoS Management
/**
* Gets the DataReaderQos setting for this instance.
*
* @return the qos
* @throws dds::core::Error
* An internal error has occurred.
* @throws dds::core::NullReferenceError
* The entity was not properly created and references to dds::core::null.
* @throws dds::core::AlreadyClosedError
* The entity has already been closed.
* @throws dds::core::OutOfResourcesError
* The Data Distribution Service ran out of resources to
* complete this operation.
*/
dds::sub::qos::DataReaderQos
qos() const;
/**
* This operation replaces the existing set of QosPolicy settings for a DataReader.
*
* The parameter qos contains the object with the QosPolicy settings which is
* checked for self-consistency and mutability.
*
* When the application tries to change a
* QosPolicy setting for an enabled DataReader, which can only be set before the
* DataReader is enabled, the operation will fail and a
* ImmutablePolicyError is thrown. In other words, the application must
* provide the presently set QosPolicy settings in case of the immutable QosPolicy
* settings. Only the mutable QosPolicy settings can be changed.
*
* When the qos contains conflicting QosPolicy settings (not self-consistent),
* the operation will fail and an InconsistentPolicyError is thrown.
*
* @param qos the qos
* @throws dds::core::Error
* An internal error has occurred.
* @throws dds::core::NullReferenceError
* The entity was not properly created and references to dds::core::null.
* @throws dds::core::AlreadyClosedError
* The entity has already been closed.
* @throws dds::core::OutOfResourcesError
* The Data Distribution Service ran out of resources to
* complete this operation.
* @throws dds::core::ImmutablePolicyError
* The parameter qos contains an immutable QosPolicy setting with a
* different value than set during enabling of the DataReader.
* @throws dds::core::InconsistentPolicyError
* The parameter qos contains conflicting QosPolicy settings,
*/
void qos(const dds::sub::qos::DataReaderQos& qos);
/** @copydoc dds::sub::TAnyDataReader::qos(const dds::sub::qos::DataReaderQos& qos) */
TAnyDataReader& operator << (const dds::sub::qos::DataReaderQos& qos);
/** @copydoc dds::sub::TAnyDataReader::qos() */
const TAnyDataReader& operator >> (dds::sub::qos::DataReaderQos& qos) const;
//========================================================================
// -- Status API
/**
* This operation obtains the LivelinessChangedStatus object of the DataReader.
*
* This object contains the information whether the liveliness of one or more
* DataWriter objects that were writing instances read by the DataReader has
* changed. In other words, some DataWriter have become "alive" or "not alive".
*
* The LivelinessChangedStatus can also be monitored using a
* DataReaderListener or by using the associated StatusCondition.
*
* @return the LivelinessChangedStatus
* @throws dds::core::Error
* An internal error has occurred.
* @throws dds::core::NullReferenceError
* The entity was not properly created and references to dds::core::null.
* @throws dds::core::AlreadyClosedError
* The entity has already been closed.
* @throws dds::core::OutOfResourcesError
* The Data Distribution Service ran out of resources to
* complete this operation.
*/
dds::core::status::LivelinessChangedStatus
liveliness_changed_status();
/**
* This operation obtains the SampleRejectedStatus object of the DataReader.
*
* This object contains the information whether a received sample has been rejected.
* Samples may be rejected by the DataReader when it runs out of
* resource_limits to store incoming samples. Usually this means that old
* samples need to be "onsumed" (for example by "taking" them instead of "reading"
* them) to make room for newly incoming samples.
*
* The SampleRejectedStatus can also be monitored using a
* DataReaderListener or by using the associated StatusCondition.
*
* @return the SampleRejectedStatus
* @throws dds::core::Error
* An internal error has occurred.
* @throws dds::core::NullReferenceError
* The entity was not properly created and references to dds::core::null.
* @throws dds::core::AlreadyClosedError
* The entity has already been closed.
* @throws dds::core::OutOfResourcesError
* The Data Distribution Service ran out of resources to
* complete this operation.
*/
dds::core::status::SampleRejectedStatus
sample_rejected_status();
/**
* This operation obtains the SampleLostStatus object of the DataReader.
*
* This object contains information whether samples have been lost. This
* only applies when the dds::core::policy::Reliability QosPolicy is set
* to RELIABLE. If the ReliabilityQos Policy is set to BEST_EFFORT, the
* Data Distribution Service will not report the loss of samples.
*
* The SampleLostStatus can also be monitored using a
* DataReaderListener or by using the associated StatusCondition.
*
* @return the SampleLostStatus
* @throws dds::core::Error
* An internal error has occurred.
* @throws dds::core::NullReferenceError
* The entity was not properly created and references to dds::core::null.
* @throws dds::core::AlreadyClosedError
* The entity has already been closed.
* @throws dds::core::OutOfResourcesError
* The Data Distribution Service ran out of resources to
* complete this operation.
*/
dds::core::status::SampleLostStatus
sample_lost_status();
/**
* This operation obtains the RequestedDeadlineMissedStatus object of the DataReader.
*
* This object contains the information whether the deadline that the DataReader
* was expecting through its dds::core::policy::Deadline QosPolicy was not respected
* for a specific instance.
*
* The RequestedDeadlineMissedStatus can also be monitored using a
* DataReaderListener or by using the associated StatusCondition.
*
* @return the RequestedDeadlineMissedStatus
* @throws dds::core::Error
* An internal error has occurred.
* @throws dds::core::NullReferenceError
* The entity was not properly created and references to dds::core::null.
* @throws dds::core::AlreadyClosedError
* The entity has already been closed.
* @throws dds::core::OutOfResourcesError
* The Data Distribution Service ran out of resources to
* complete this operation.
*/
dds::core::status::RequestedDeadlineMissedStatus
requested_deadline_missed_status();
/**
* This operation obtains the RequestedIncompatibleQosStatus object of the DataReader.
*
* This object contains the information whether a QosPolicy setting
* was incompatible with the offered QosPolicy setting.
*
* The Request/Offering mechanism is applicable between the DataWriter and the
* DataReader. If the QosPolicy settings between DataWriter and DataReader
* are inconsistent, no communication between them is established. In addition the
* DataWriter will be informed via a REQUESTED_INCOMPATIBLE_QOS status
* change and the DataReader will be informed via an
* OFFERED_INCOMPATIBLE_QOS status change.
*
* The RequestedIncompatibleQosStatus can also be monitored using a
* DataReaderListener or by using the associated StatusCondition.
*
* @return the RequestedIncompatibleQosStatus
* @throws dds::core::Error
* An internal error has occurred.
* @throws dds::core::NullReferenceError
* The entity was not properly created and references to dds::core::null.
* @throws dds::core::AlreadyClosedError
* The entity has already been closed.
* @throws dds::core::OutOfResourcesError
* The Data Distribution Service ran out of resources to
* complete this operation.
*/
dds::core::status::RequestedIncompatibleQosStatus
requested_incompatible_qos_status();
/**
* This operation obtains the SubscriptionMatchedStatus object of the DataReader.
*
* This object contains the information whether a new match has been
* discovered for the current subscription, or whether an existing match has ceased to
* exist.
*
* This means that the status represents that either a DataWriter object has been
* discovered by the DataReader with the same Topic and a compatible Qos, or that a
* previously discovered DataWriter has ceased to be matched to the current
* DataReader. A DataWriter may cease to match when it gets deleted, when it
* changes its Qos to a value that is incompatible with the current DataReader or
* when either the DataReader or the DataWriter has chosen to put its matching
* counterpart on its ignore-list using the dds::sub::ignore or dds::pub::ignore
* operations on the DomainParticipant.
*
* The operation may fail if the infrastructure does not hold the information necessary
* to fill in the SubscriptionMatchedStatus. This is the case when OpenSplice is
* configured not to maintain discovery information in the Networking Service. (See
* the description for the NetworkingService/Discovery/enabled property in
* the Deployment Manual for more information about this subject.) In this case the
* operation will throw UnsupportedError.
*
* The SubscriptionMatchedStatus can also be monitored using a
* DataReaderListener or by using the associated StatusCondition.
*
* @return the SubscriptionMatchedStatus
* @throws dds::core::Error
* An internal error has occurred.
* @throws dds::core::NullReferenceError
* The entity was not properly created and references to dds::core::null.
* @throws dds::core::AlreadyClosedError
* The entity has already been closed.
* @throws dds::core::OutOfResourcesError
* The Data Distribution Service ran out of resources to
* complete this operation.
* @throws dds::core::UnsupportedError
* OpenSplice is configured not to maintain the information
* about "associated" publications.
*/
dds::core::status::SubscriptionMatchedStatus
subscription_matched_status();
};
#endif /* OMG_TDDS_SUB_ANY_DATA_READER_HPP_ */

View File

@@ -0,0 +1,150 @@
#ifndef OMG_DDS_SUB_TCOHERENT_ACCESS_HPP_
#define OMG_DDS_SUB_TCOHERENT_ACCESS_HPP_
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <dds/core/Value.hpp>
namespace dds
{
namespace sub
{
template <typename DELEGATE>
class TCoherentAccess;
}
}
/**
* @brief
* Class for RAII way of beginning/ending coherent access.
*
* Coherent access indicates that the application is about to access
* the data samples in any of the DataReader objects attached to the
* Subscriber.
*
* The application is required to use this operation
* only if Presentation QosPolicy of the Subscriber to which the
* DataReader belongs has the access_scope set to "GROUP". In the
* aforementioned case, the operation must be called
* prior to calling any of the sample-accessing operations, i.e.
* read and take on DataReader. Otherwise the sample-accessing
* operations will throw a PreconditionNotMetError exception.
*
* Once the application has finished accessing the data samples
* it must end the coherent access. It is not required for the
* application to begin or end access if the Presentation QosPolicy
* has the access_scope set to something other than GROUP. Beginning
* or ending access in this case is not considered an error and has
* no effect. Beginning and ending access may be nested. In that
* case, the application end access as many times as it began
* access.
*
* @code{.cpp}
* dds::domain::DomainParticipant participant(org::eclipse::cyclonedds::domain::default_id());
* dds::topic::Topic<Foo::Bar> topic(participant, "TopicName");
*
* dds::sub::qos::SubscriberQos sQos sQos = participant.default_subscriber_qos()
* << dds::core::policy::Presentation::TopicAccessScope(false, true);
* dds::sub::Subscriber subscriber(participant, sQos);
*
* {
* std::vector< dds::sub::DataReader<Foo::Bar> > readers;
* // Start coherent access.
* dds::sub::TCoherentAccess coherentAccess(subscriber);
* // Find (previously created with the subscriber) datareaders that now got data.
* dds::sub::find< dds::sub::DataReader<Foo::Bar> >(subscriber,
* dds::sub::status::DataState::any(),
* back_inserter(readers));
* // Get data from the readers
* for (size_type i = 0; i < rv.size(); i++) {
* dds::sub::LoanedSamples<Foo::Bar> samples = readers[i].read()
* dds::sub::LoanedSamples<Type1>::const_iterator it;
* for (it = samples.begin(); it != samples.end(); iterator++) {
* const dds::sub::Sample<Foo::Bar>& sample = *it;
* const Foo::Bar& data = sample.data();
* const dds::sub::SampleInfo& info = sample.info();
* // Use sample data and meta information.
* }
* }
* }
* // CoherentAccess went out of scope: it is ended implicitly
* @endcode
*
* @see for more information: @ref DCPS_Modules_Subscription "Subscription"
* @see dds::sub::Subscriber
*/
template <typename DELEGATE>
class dds::sub::TCoherentAccess : public dds::core::Value<DELEGATE>
{
public:
/**
* Creating a CoherentAccess object, which will begin coherent access of
* received samples using DataReader objects attached to this Subscriber.
*
* @param sub The Subscriber to begin the coherent access on.
* @throws dds::core::Error
* An internal error has occurred.
* @throws dds::core::AlreadyClosedError
* The Subscriber has already been closed.
* @throws dds::core::NotEnabledError
* The Subscriber has not yet been enabled.
* @throws dds::core::OutOfResourcesError
* The Data Distribution Service ran out of resources to
* complete this operation.
* @throws dds::core::NullReferenceError
* The Subscriber was not properly created and references to dds::core::null.
*/
explicit TCoherentAccess(const dds::sub::Subscriber& sub);
public:
/**
* This operation will explicitly end the coherent access.
*
* If the Subscriber already ended its coherent access (by a call to this very
* operation), then a call to this operation will have no effect.
*
* @throws dds::core::Error
* An internal error has occurred.
* @throws dds::core::AlreadyClosedError
* The Subscriber has already been closed.
* @throws dds::core::NotEnabledError
* The Subscriber has not yet been enabled.
* @throws dds::core::NullReferenceError
* The Subscriber was not properly created and references to dds::core::null.
*/
void end();
public:
/**
* The destruction of the CoherentAccess will implicitly end the coherent
* access if not already ended by a call to end().
*
* When there is a problem with which end() would normally throw an exception,
* then that exception is swallowed. Errors can be found in the logs.
*/
~TCoherentAccess();
private:
TCoherentAccess(const TCoherentAccess&);
TCoherentAccess& operator=(const TCoherentAccess&);
};
#endif /* OMG_TDDS_SUB_TCOHERENT_ACCESS_HPP_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,107 @@
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OMG_DDS_SUB_T_GENERATION_COUNT_HPP_
#define OMG_DDS_SUB_T_GENERATION_COUNT_HPP_
#include <dds/core/Value.hpp>
namespace dds
{
namespace sub
{
template <typename DELEGATE>
class TGenerationCount;
}
}
/**
* @brief
* Class to hold sample GenerationCount information and is part of dds::sub::SampleInfo.
*
* Generations
* A generation is defined as: the number of times an instance has become alive (with
* instance_state==ALIVE) at the time the sample was
* received. Note that the generation counters are initialized to zero when a
* DataReader first detects a never-seen-before instance.
*
* For each instance the middleware internally maintains two counts: the
* disposed_generation_count and no_writers_generation_count, relative to
* each DataReader:
*
* Two types of generations are distinguished: disposed_generation_count and
* no_writers_generation_count.<br>
* - The disposed_generation_count and no_writers_generation_count are
* initialized to zero when the DataReader first detects the presence of
* a never-seen-before instance.
* - The disposed_generation_count is incremented each time the instance_state
* of the corresponding instance changes from not_alive_disposed to alive.
* - The no_writers_generation_count is incremented each time the instance_state
* of the corresponding instance changes from not_alive_no_writers to alive.
*
* The disposed_generation_count and no_writers_generation_count associated with
* the SampleInfo capture a snapshot of the corresponding counters at the time
* the sample was received.
*
* @see for more information: @ref DCPS_Modules_Subscription_SampleInfo "SampleInfo"
*/
template <typename DELEGATE>
class dds::sub::TGenerationCount : public dds::core::Value<DELEGATE>
{
public:
/** @cond
* Create an empty GenerationCount.
* This constructor is required for containers.
* An application would normally not create a GenerationCount itself.
* So, do not put the creation in the API documentation for clarity.
*/
TGenerationCount();
/**
* Create a GenerationCount instance.
* An application would normally not create a GenerationCount itself.
* So, do not put the creation in the API documentation for clarity.
*/
TGenerationCount(int32_t disposed_generation_count, int32_t no_writers_generation_count);
/** @endcond */
public:
/**
* Gets the disposed_generation_count.
*
* The disposed_generation_count is initialized at zero and is incremented
* each time the instance_state, of the corresponding instance, changes from
* not_alive_disposed to alive.
*
* @return the disposed_generation_count
*/
int32_t disposed() const;
/**
* Gets the no_writers_generation_count.
*
* The no_writers_generation_count is initialized at zero and is incremented
* each time the instance_state, of the corresponding instance, changes from
* not_alive_no_writers to alive.
*
* @return the no_writers_generation_count
*/
inline int32_t no_writers() const;
};
#endif /* OMG_DDS_SUB_T_GENERATION_COUNT_HPP_ */

View File

@@ -0,0 +1,215 @@
#ifndef DDS_CORE_TQUERY_HPP_
#define DDS_CORE_TQUERY_HPP_
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <dds/core/types.hpp>
#include <dds/core/Reference.hpp>
#include <dds/sub/AnyDataReader.hpp>
namespace dds
{
namespace sub
{
template <typename DELEGATE>
class TQuery;
}
}
/**
* @brief
* Query objects contain expressions that allow the application to specify
* a filter on the locally available data.
*
* A Query is used in a QueryCondition or DataReader::Selector and is
* associated with one DataReader.
*
* @anchor anchor_dds_sub_query_expression
* \par SQL Expression
* The SQL query string is set by expression which must be a subset of the
* SQL query language. In this query expression, parameters may be used, which must
* be set in the sequence of strings defined by the parameter query_parameters. A
* parameter is a string which can define an integer, float, string or enumeration. The
* number of values in query_parameters must be equal or greater than the highest
* referenced %n token in the query_expression (e.g. if %1 and %8 are used as
* parameters in the query_expression, the query_parameters should at least
* contain n+1 = 9 values).<br>
* Look @ref DCPS_Queries_and_Filters "here" for the specific query expression syntax.
*
* @see dds::sub::cond::QueryCondition
* @see dds::sub::DataReader::Selector
* @see dds::sub::DataReader::ManipulatorSelector
* @see for more information: @ref DCPS_Modules_Infrastructure_Waitset "Subscription concept"
*/
template <typename DELEGATE>
class dds::sub::TQuery: public virtual dds::core::Reference<DELEGATE> {
public:
OMG_DDS_REF_TYPE_PROTECTED_DC(TQuery, dds::core::Reference, DELEGATE)
OMG_DDS_IMPLICIT_REF_BASE(TQuery)
OMG_DDS_COMPLETE_RULE_OF_FIVE_VIRTUAL_EXPLICIT(TQuery)
public:
/**
* Iterator for the query expression parameters.
*/
typedef typename DELEGATE::iterator iterator;
/**
* Iterator for the query expression parameters.
*/
typedef typename DELEGATE::const_iterator const_iterator;
public:
/**
* Create a dds::sub::Query associated with an dds::sub::AnyDataReader.
*
* @param dr The AnyDataReader to associate with the Query.
* @param expression an @ref anchor_dds_sub_query_expression "SQL expression"
* @throw dds::core::Exception
*/
TQuery(const dds::sub::AnyDataReader& dr, const std::string& expression);
/**
* Create a dds::sub::Query associated with an dds::sub::AnyDataReader.
*
* @param dr The AnyDataReader to associate with the Query.
* @param expression an @ref anchor_dds_sub_query_expression "SQL expression"
* @param params_begin Iterator pointing to the beginning of the parameters to set
* @param params_end Iterator pointing to the end of the parameters to set
* @throw dds::core::Exception
*/
template<typename FWIterator>
TQuery(const dds::sub::AnyDataReader& dr, const std::string& expression,
const FWIterator& params_begin, const FWIterator& params_end);
/**
* Create a dds::sub::Query associated with an dds::sub::AnyDataReader.
*
* @param dr The AnyDataReader to associate with the Query.
* @param expression an @ref anchor_dds_sub_query_expression "SQL expression"
* @param params Vector containing SQL expression parameters
* @throw dds::core::Exception
*/
TQuery(const dds::sub::AnyDataReader& dr, const std::string& expression,
const std::vector<std::string>& params);
/**
* Get expression.
*
* @return std::string The @ref anchor_dds_sub_query_expression "SQL expression".
* @throw dds::core::Exception
*/
const std::string& expression() const;
/**
* Set new expression.
*
* @param expr an ref anchor_dds_sub_query_expression "SQL expression"
* @throw dds::core::Exception
*/
void expression(const std::string& expr);
/**
* Provides the begin iterator to the SQL expression parameter list.
*
* See @ref anchor_dds_sub_query_expression "SQL expression info"
*
* @return dds::sub::Query::const_iterator
* The begin iterator
* @throw dds::core::Exception
*/
const_iterator begin() const;
/**
* The end iterator to the SQL expression parameter list.
*
* See @ref anchor_dds_sub_query_expression "SQL expression info"
*
* @return dds::sub::Query::const_iterator
* The end iterator
* @throw dds::core::Exception
*/
const_iterator end() const;
/**
* Provides the begin iterator to the SQL expression parameter list.
*
* See @ref anchor_dds_sub_query_expression "SQL expression info"
*
* @return dds::sub::Query::iterator
* The begin iterator
* @throw dds::core::Exception
*/
iterator begin();
/**
* The end iterator to the SQL expression parameter list.
*
* See @ref anchor_dds_sub_query_expression "SQL expression info"
*
* @return dds::sub::TQuery::iterator
* The end iterator
* @throw dds::core::Exception
*/
iterator end();
/**
* Sets the query parameters.
*
* See @ref anchor_dds_sub_query_expression "SQL expression info"
*
* @param begin Iterator pointing to the beginning of the parameters to set
* @param end Iterator pointing to the end of the parameters to set
* @throw dds::core::Exception
*/
template<typename FWIterator>
void parameters(const FWIterator& begin, const FWIterator end);
/**
* Adds a parameter to the query.
*
* See @ref anchor_dds_sub_query_expression "SQL expression info"
*
* @param param The parameter to add
* @throw dds::core::Exception
*/
void add_parameter(const std::string& param);
/**
* Gets the number of parameters in the query.
*
* See @ref anchor_dds_sub_query_expression "SQL expression info"
*
* @return uint32_t The number of parameters in the query
* @throw dds::core::Exception
*/
uint32_t parameters_length() const;
/**
* This operation returns the DataReader associated with the Query.
*
* Note that there is exactly one DataReader associated with each Query.
*
* @return dds::sub::AnyDataReader The associated DataReader
* @throw dds::core::Exception
*/
const AnyDataReader& data_reader() const;
};
#endif /* DDS_CORE_TQUERY_HPP_ */

View File

@@ -0,0 +1,134 @@
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OMG_DDS_SUB_TRANK_HPP_
#define OMG_DDS_SUB_TRANK_HPP_
#include <dds/core/Value.hpp>
namespace dds
{
namespace sub
{
template <typename DELEGATE>
class TRank;
}
}
/**
* @brief
* Class to hold sample Rank information and is part of dds::sub::SampleInfo.
*
* The sample_rank and generation_rank available in dds::sub::Rank are
* computed based solely on the actual samples in the ordered collection
* returned by read or take.
* - The sample_rank indicates the number of samples of the same instance
* that follow the current one in the collection.
* - The generation_rank indicates the difference
* in 'generations' between the sample (S) and the Most Recent Sample of the
* same instance that appears In the returned Collection (MRSIC). That is, it
* counts the number of times the instance transitioned from not-alive to
* alive in the time from the reception of the S to the reception of MRSIC.
*
* The generation_rank is computed using the formula:<br>
* generation_rank =
* (MRSIC.disposed_generation_count + MRSIC.no_writers_generation_count) -
* (S.disposed_generation_count + S.no_writers_generation_count)
*
* The absolute_generation_rank indicates the
* difference in 'generations' between the sample (S) and the Most Recent
* Sample of the same instance that the middleware has received (MRS). That is,
* it counts the number of times the instance transitioned from not-alive to
* alive in the time from the reception of the S to the time when the read or
* take was called.
*
* The absolute_generation_rank is computed using the formula:<br>
* absolute_generation_rank =
* (MRS.disposed_generation_count + MRS.no_writers_generation_count) -
* (S.disposed_generation_count + S.no_writers_generation_count)
*
* @see for more information: @ref DCPS_Modules_Subscription_SampleInfo "SampleInfo"
*/
template <typename DELEGATE>
class dds::sub::TRank : public dds::core::Value<DELEGATE>
{
public:
/** @cond
* Create an empty Rank.
* This constructor is required for containers.
* An application would normally not create a Rank itself.
* So, do not put the creation in the API documentation for clarity.
*/
TRank();
/**
* Create a Rank instance.
* An application would normally not create a Rank itself.
* So, do not put the creation in the API documentation for clarity.
*/
TRank(int32_t sample_rank, int32_t generation_rank, int32_t absolute_generation_rank);
/** @endcond */
/**
* Gets the absolute_generation_rank.
*
* The absolute_generation_rank indicates the
* difference in 'generations' between the sample (S) and the Most Recent
* Sample of the same instance that the middleware has received (MRS). That is,
* it counts the number of times the instance transitioned from not-alive to
* alive in the time from the reception of the S to the time when the read or
* take was called.
*
* The absolute_generation_rank is computed using the formula:<br>
* absolute_generation_rank =
* (MRS.disposed_generation_count + MRS.no_writers_generation_count) -
* (S.disposed_generation_count + S.no_writers_generation_count)
*
* @return the absolute_generation_rank
*/
int32_t absolute_generation() const;
/**
* Gets the generation_rank.
*
* The generation_rank indicates the difference
* in 'generations' between the sample (S) and the Most Recent Sample of the
* same instance that appears In the returned Collection (MRSIC). That is, it
* counts the number of times the instance transitioned from not-alive to
* alive in the time from the reception of the S to the reception of MRSIC.
*
* The generation_rank is computed using the formula:<br>
* generation_rank =
* (MRSIC.disposed_generation_count + MRSIC.no_writers_generation_count) -
* (S.disposed_generation_count + S.no_writers_generation_count)
*
* @return the generation_rank
*/
inline int32_t generation() const;
/**
* Gets the sample_rank.
*
* The sample_rank indicates the number of samples of the same instance
* that follow the current one in the collection.
*
* @return the sample_rank
*/
inline int32_t sample() const;
};
#endif /* OMG_DDS_SUB_TRANK_HPP_ */

View File

@@ -0,0 +1,124 @@
#ifndef OMG_DDS_SUB_TSAMPLE_HPP_
#define OMG_DDS_SUB_TSAMPLE_HPP_
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <dds/core/Value.hpp>
#include <dds/sub/SampleInfo.hpp>
namespace dds
{
namespace sub
{
template <typename T, template <typename Q> class DELEGATE>
class Sample;
}
}
/**
* @brief
* This class encapsulates the data and info meta-data associated with
* DDS samples.
*
* It is normally used with dds::sub::LoanedSamples:
* @code{.cpp}
* dds::sub::LoanedSamples<Foo::Bar> samples = reader.read();
* dds::sub::LoanedSamples<Foo::Bar>::const_iterator it;
* for (it = samples.begin(); it != samples.end(); ++it) {
* const dds::sub::Sample<Foo::Bar>& sample = *it;
* const Foo::Bar& data = sample.data();
* const dds::sub::SampleInfo& info = sample.info();
* // Use sample data and meta information.
* }
* @endcode
* Or more implicitly:
* @code{.cpp}
* dds::sub::LoanedSamples<Foo::Bar> samples = reader.read();
* dds::sub::LoanedSamples<Foo::Bar>::const_iterator it;
* for (it = samples.begin(); it != samples.end(); ++it) {
* const Foo::Bar& data = it->data();
* const dds::sub::SampleInfo& info = it->info();
* // Use sample data and meta information.
* }
* @endcode
*
* @see for more information: @ref DCPS_Modules_Subscription_DataSample "DataSample"
* @see for more information: @ref DCPS_Modules_Subscription_SampleInfo "SampleInfo"
* @see for more information: @ref DCPS_Modules_Subscription "Subscription"
*/
template <typename T, template <typename Q> class DELEGATE>
class dds::sub::Sample : public dds::core::Value< DELEGATE<T> >
{
public:
/**
* Convenience typedef for the type of the data sample.
*/
typedef T DataType;
public:
/**
* Create a sample with invalid data.
*/
Sample();
/**
* Creates a Sample instance.
*
* @param data the data
* @param info the sample info
*/
Sample(const T& data, const SampleInfo& info);
/**
* Copies a sample instance.
*
* @param other the sample instance to copy
*/
Sample(const Sample& other);
/**
* Gets the data.
*
* @return the data
*/
const DataType& data() const;
/**
* Sets the data.
*
* @param data the data
*/
void data(const DataType& data);
/**
* Gets the info.
*
* @return the info
*/
const SampleInfo& info() const;
/**
* Sets the info.
*
* @param info the info
*/
void info(const SampleInfo& info);
};
#endif /* OMG_DDS_SUB_TSAMPLE_HPP_ */

View File

@@ -0,0 +1,146 @@
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OMG_DDS_SUB_TSAMPLE_INFO_HPP_
#define OMG_DDS_SUB_TSAMPLE_INFO_HPP_
#include <dds/core/Time.hpp>
#include <dds/core/Value.hpp>
#include <dds/core/InstanceHandle.hpp>
#include <dds/sub/GenerationCount.hpp>
#include <dds/sub/Rank.hpp>
#include <dds/sub/status/DataState.hpp>
namespace dds
{
namespace sub
{
template <typename DELEGATE>
class TSampleInfo;
}
}
/**
* @brief
* The SampleInfo contains information pertaining to the associated Data value.
*
* The SampleInfo contains information pertaining to the associated Data value:
* - The data state (dds::sub::status::DataState).
* - The sample_state of the Data value (i.e., if the sample has already been READ or NOT_READ by that same DataReader).
* - The view_state of the related instance (i.e., if the instance is NEW, or NOT_NEW for that DataReader).
* - The instance_state of the related instance (i.e., if the instance is ALIVE, NOT_ALIVE_DISPOSED, or NOT_ALIVE_NO_WRITERS).
* - The valid data flag. This flag indicates whether there is data associated with the sample. Some samples do not contain data indicating only a change on the instance_state of the corresponding instance.
* - The generation counts (dds::sub::GenerationCount) for the related instance at the time the sample was received. These counters indicate the number of times the instance had become ALIVE.
* - The disposed generation count
* - The no_writer generation count
* - The rank information (dds::sub::Rank).
* - The sample rank. This rank provides a preview of the samples that follow within the sequence returned by the read or take operations.
* - The generation rank. This rank provides a preview of the samples that follow within the sequence returned by the read or take operations.
* - The absolute_generation rank. This is the timestamp provided by the DataWriter at the time the sample was produced.
* - The source timestamp of the sample. This is the timestamp provided by the DataWriter at the time the sample was produced.
* - The InstanceHandle of the associated data Sample.
* - The InstanceHandle of the associated publication.
*
* @see for more information: @ref DCPS_Modules_Subscription_SampleInfo "SampleInfo"
*/
template <typename DELEGATE>
class dds::sub::TSampleInfo : public dds::core::Value<DELEGATE>
{
public:
/** @cond
* Create an empty SampleInfo.
* This constructor is required for containers.
* An application would normally not create a SampleInfo itself.
* So, do not put the creation in the API documentation for clarity.
*/
TSampleInfo();
/** @endcond */
public:
/**
* Gets the timestamp of the sample.
*
* This is the timestamp provided by the DataWriter at the time the sample was produced.
*
* @return the timestamp
*/
const dds::core::Time timestamp() const;
/**
* Gets the DataState of the sample.
*
* The data state (dds::sub::status::DataState).
* - The sample_state of the Data value (i.e., if the sample has already been READ or NOT_READ by that same DataReader).
* - The view_state of the related instance (i.e., if the instance is NEW, or NOT_NEW for that DataReader).
* - The instance_state of the related instance (i.e., if the instance is ALIVE, NOT_ALIVE_DISPOSED, or NOT_ALIVE_NO_WRITERS).
*
* @return the DataState
*/
const dds::sub::status::DataState state() const;
/**
* Gets the GenerationCount of the sample.
*
* The generation counts (dds::sub::GenerationCount) for the related instance at the time the sample was received.
* These counters indicate the number of times the instance had become ALIVE.
* - The disposed generation count
* - The no_writer generation count
*
* @return the GenerationCount
*/
dds::sub::GenerationCount generation_count() const;
/**
* Gets the Rank of the sample.
*
* The rank information (dds::sub::Rank).
* - The sample rank. This rank provides a preview of the samples that follow within the sequence returned by the read or take operations.
* - The generation rank. This rank provides a preview of the samples that follow within the sequence returned by the read or take operations.
* - The absolute_generation rank. This is the timestamp provided by the DataWriter at the time the sample was produced.
*
* @return the Rank
*/
dds::sub::Rank rank() const;
/**
* Gets the valid_data flag.
*
* This flag indicates whether there is data
* associated with the sample. Some samples do not contain data, indicating
* only a change on the instance_state of the corresponding instance.
*
* @return the valid_data flag
*/
bool valid() const;
/**
* Gets the InstanceHandle of the associated data Sample.
*
* @return the InstanceHandle of the sample
*/
dds::core::InstanceHandle instance_handle() const;
/**
* Gets the InstanceHandle of the associated publication.
*
* @return the publication_handle
*/
dds::core::InstanceHandle publication_handle() const;
};
#endif /* OMG_DDS_SUB_TSAMPLE_INFO_HPP_ */

View File

@@ -0,0 +1,110 @@
#ifndef OMG_DDS_SUB_TSAMPLEREF_HPP_
#define OMG_DDS_SUB_TSAMPLEREF_HPP_
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <dds/core/Value.hpp>
#include <dds/sub/SampleInfo.hpp>
namespace dds
{
namespace sub
{
template <typename T, template <typename Q> class DELEGATE>
class SampleRef;
}
}
/**
* @brief
* This class encapsulates a reference to the data and info meta-data
* associated with DDS samples.
*
* It is normally used with dds::sub::LoanedSamples:
* @code{.cpp}
* dds::sub::LoanedSamples<Foo::Bar> samples = reader.read();
* dds::sub::LoanedSamples<Foo::Bar>::const_iterator it;
* for (it = samples.begin(); it != samples.end(); ++it) {
* const dds::sub::Sample<Foo::Bar>& sample = *it;
* const Foo::Bar& data = sample.data();
* const dds::sub::SampleInfo& info = sample.info();
* // Use sample data and meta information.
* }
* @endcode
* Or more implicitly:
* @code{.cpp}
* dds::sub::LoanedSamples<Foo::Bar> samples = reader.read();
* dds::sub::LoanedSamples<Foo::Bar>::const_iterator it;
* for (it = samples.begin(); it != samples.end(); ++it) {
* const Foo::Bar& data = it->data();
* const dds::sub::SampleInfo& info = it->info();
* // Use sample data and meta information.
* }
* @endcode
*
* @see for more information: @ref DCPS_Modules_Subscription_DataSample "DataSample"
* @see for more information: @ref DCPS_Modules_Subscription_SampleInfo "SampleInfo"
* @see for more information: @ref DCPS_Modules_Subscription "Subscription"
*/
template <typename T, template <typename Q> class DELEGATE>
class dds::sub::SampleRef : public dds::core::Value< DELEGATE<T> >
{
public:
/**
* Convenience typedef for the type of the data sample.
*/
typedef T DataType;
public:
/**
* Create a sample with invalid data.
*/
SampleRef();
/**
* Creates a Sample instance.
*
* @param data the data
* @param info the sample info
*/
SampleRef(const T& data, const SampleInfo& info);
/**
* Copies a sample instance.
*
* @param other the sample instance to copy
*/
SampleRef(const SampleRef& other);
/**
* Gets the data.
*
* @return the data
*/
const DataType& data() const;
/**
* Gets the info.
*
* @return the info
*/
const SampleInfo& info() const;
};
#endif /* OMG_DDS_SUB_TSAMPLEREF_HPP_ */

View File

@@ -0,0 +1,290 @@
#ifndef OMG_TDDS_SUB_SUBSCRIBER_HPP_
#define OMG_TDDS_SUB_SUBSCRIBER_HPP_
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <dds/core/TEntity.hpp>
#include <dds/domain/DomainParticipant.hpp>
#include <dds/sub/qos/DataReaderQos.hpp>
namespace dds
{
namespace sub
{
template <typename DELEGATE>
class TSubscriber;
class SubscriberListener;
}
}
/**
* @brief
* A Subscriber is the object responsible for the actual reception of the
* data resulting from its subscriptions.
*
* A Subscriber acts on the behalf of one or several DataReader objects
* that are related to it. When it receives data (from the other parts of
* the system), it builds the list of concerned DataReader objects, and then
* indicates to the application that data is available, through its listener
* or by enabling related conditions. The application can access the list of
* concerned DataReader objects through the operation get_datareaders and
* then access the data available through operations on the DataReader.
*
* @see for more information: @ref DCPS_Modules_Subscriber "Subscriber"
*/
template <typename DELEGATE>
class dds::sub::TSubscriber : public dds::core::TEntity<DELEGATE>
{
public:
OMG_DDS_REF_TYPE_PROTECTED_DC(TSubscriber, dds::core::TEntity, DELEGATE)
OMG_DDS_IMPLICIT_REF_BASE(TSubscriber)
public:
/**
* Local convenience typedef for dds::sub::SubscriberListener.
*/
typedef dds::sub::SubscriberListener Listener;
public:
/**
* Create a new Subscriber.
*
* The Subscriber will be created with the QoS values specified on the last
* successful call to @link dds::domain::DomainParticipant::default_subscriber_qos(const ::dds::sub::qos::SubscriberQos& qos)
* dp.default_subscriber_qos(qos) @endlink or, if the call was never made, the
* @ref anchor_dds_sub_subscriber_qos_defaults "default" values.
*
* @param dp the domain participant
* @throws dds::core::Error
* An internal error has occurred.
* @throws dds::core::OutOfResourcesError
* The Data Distribution Service ran out of resources to
* complete this operation.
*/
TSubscriber(const ::dds::domain::DomainParticipant& dp);
/**
* Create a new Subscriber.
*
* The Subscriber will be created with the given QosPolicy settings and if
* applicable, attaches the optionally specified SubscriberListener to it.
*
* See @ref DCPS_Modules_Infrastructure_Listener "listener" for more information
* about listeners and possible status propagation to other entities.
*
* @param dp the domain participant to create the Subscriber with.
* @param qos a collection of QosPolicy settings for the new Subscriber. In case
* these settings are not self consistent, no Subscriber is created.
* @param listener the subscriber listener
* @param mask the mask of events notified to the listener
* @throws dds::core::Error
* An internal error has occurred.
* @throws dds::core::OutOfResourcesError
* The Data Distribution Service ran out of resources to
* complete this operation.
* @throws dds::core::InconsistentPolicyError
* The parameter qos contains conflicting QosPolicy settings.
*/
TSubscriber(const ::dds::domain::DomainParticipant& dp,
const dds::sub::qos::SubscriberQos& qos,
dds::sub::SubscriberListener* listener = NULL,
const dds::core::status::StatusMask& mask = dds::core::status::StatusMask::none());
public:
/**
* This operation invokes the on_data_available operation on
* DataReaderListener objects which are attached to the contained DataReader
* entities having new, available data.
*
* The notify_datareaders operation ignores the bit mask value of individual
* DataReaderListener objects, even when the dds::core::status::StatusMask::data_available()
* has not been set on a DataReader that has new, available data. The
* on_data_available operation will still be invoked, when the
* dds::core::status::StatusMask::data_available() bit has not been set on a DataReader,
* but will not propagate to the DomainParticipantListener.
*
* When the DataReader has attached a NULL listener, the event will be consumed
* and will not propagate to the DomainParticipantListener. (Remember that a
* NULL listener is regarded as a listener that handles all its events as a NOOP).
*
* Look @ref DCPS_Modules_Infrastructure_Status "here" for Status change information.<br>
* Look @ref DCPS_Modules_Infrastructure_Listener "here" for Listener information.<br>
*
* @throws dds::core::Error
* An internal error has occurred.
* @throws dds::core::NullReferenceError
* The entity was not properly created and references to dds::core::null.
* @throws dds::core::AlreadyClosedError
* The entity has already been closed.
* @throws dds::core::OutOfResourcesError
* The Data Distribution Service ran out of resources to
* complete this operation.
*/
void notify_datareaders();
/**
* Register a listener with the Subscriber.
*
* The notifications received by the listener depend on the
* status mask with which it was registered.
*
* Listener un-registration is performed by setting the listener to NULL.
*
* See also @ref DCPS_Modules_Infrastructure_Listener "listener information".
*
* @param listener the listener
* @param event_mask the mask defining the events for which the listener
* will be notified.
* @throws dds::core::Error
* An internal error has occurred.
* @throws dds::core::NullReferenceError
* The entity was not properly created and references to dds::core::null.
* @throws dds::core::AlreadyClosedError
* The entity has already been closed.
* @throws dds::core::UnsupportedError
* A status was selected that cannot be supported because
* the infrastructure does not maintain the required connectivity information.
* @throws dds::core::OutOfResourcesError
* The Data Distribution Service ran out of resources to
* complete this operation.
*/
void listener(Listener* listener,
const dds::core::status::StatusMask& event_mask);
/**
* Get the listener of this Subscriber.
*
* See also @ref DCPS_Modules_Infrastructure_Listener "listener information".
*
* @return the listener
* @throws dds::core::NullReferenceError
* The entity was not properly created and references to dds::core::null.
*/
Listener* listener() const;
/**
* Gets the SubscriberQos setting for this instance.
*
* @return the qos
* @throws dds::core::Error
* An internal error has occurred.
* @throws dds::core::NullReferenceError
* The entity was not properly created and references to dds::core::null.
* @throws dds::core::AlreadyClosedError
* The entity has already been closed.
* @throws dds::core::OutOfResourcesError
* The Data Distribution Service ran out of resources to
* complete this operation.
*/
const dds::sub::qos::SubscriberQos& qos() const;
/**
* Sets the SubscriberQos setting for this instance.
*
* @param sqos the qos
* @throws dds::core::Error
* An internal error has occurred.
* @throws dds::core::NullReferenceError
* The entity was not properly created and references to dds::core::null.
* @throws dds::core::AlreadyClosedError
* The entity has already been closed.
* @throws dds::core::OutOfResourcesError
* The Data Distribution Service ran out of resources to
* complete this operation.
*/
void qos(const dds::sub::qos::SubscriberQos& sqos);
/**
* Gets the default DataReaderQos of the Subscriber.
*
* This operation gets an object with the default DataReader QosPolicy settings of
* the Subscriber (that is the DataReaderQos) which is used for newly
* created DataReader objects, in case no QoS was provided during the creation.
*
* The values retrieved by this operation match the set of values specified on the last
* successful call to
* dds::sub::Subscriber::default_datareader_qos(const dds::sub::qos::DataReaderQos& qos),
* or, if the call was never made, the @ref anchor_dds_sub_datareader_qos_defaults "default" values.
*
* @return the default DataReaderQos
* @throws dds::core::Error
* An internal error has occurred.
* @throws dds::core::NullReferenceError
* The entity was not properly created and references to dds::core::null.
* @throws dds::core::AlreadyClosedError
* The entity has already been closed.
* @throws dds::core::OutOfResourcesError
* The Data Distribution Service ran out of resources to
* complete this operation.
*/
dds::sub::qos::DataReaderQos default_datareader_qos() const;
/**
* Sets the default DataReaderQos of the Subscriber.
*
* This operation sets the default SubscriberQos of the Subscriber which
* is used for newly created Subscriber objects, when no QoS is provided.
*
* This operation checks if the DataReaderQos is self consistent. If it is not, the
* operation has no effect and throws dds::core::InconsistentPolicyError.
*
* The values set by this operation are returned by dds::sub::Subscriber::default_datareader_qos().
*
* @param qos the default DataReaderQos
* @throws dds::core::Error
* An internal error has occurred.
* @throws dds::core::NullReferenceError
* The entity was not properly created and references to dds::core::null.
* @throws dds::core::AlreadyClosedError
* The entity has already been closed.
* @throws dds::core::UnsupportedError
* One or more of the selected QosPolicy values are
* currently not supported by OpenSplice.
* @throws dds::core::InconsistentPolicyError
* The parameter qos contains conflicting QosPolicy settings,
* e.g. a history depth that is higher than the specified resource limits.
* @throws dds::core::OutOfResourcesError
* The Data Distribution Service ran out of resources to
* complete this operation.
*/
TSubscriber& default_datareader_qos(const dds::sub::qos::DataReaderQos& qos);
/**
* Return the DomainParticipant that owns this Subscriber.
*
* @return the DomainParticipant
* @throws dds::core::Error
* An internal error has occurred.
* @throws dds::core::NullReferenceError
* The entity was not properly created and references to dds::core::null.
* @throws dds::core::AlreadyClosedError
* The entity has already been closed.
*/
const dds::domain::DomainParticipant& participant() const;
/** @copydoc dds::sub::Subscriber::qos(const dds::sub::qos::SubscriberQos& qos) */
TSubscriber& operator << (const dds::sub::qos::SubscriberQos& qos);
/** @copydoc dds::sub::Subscriber::qos() */
const TSubscriber& operator >> (dds::sub::qos::SubscriberQos& qos) const;
};
#endif /* OMG_TDDS_SUB_SUBSCRIBER_HPP_ */

View File

@@ -0,0 +1,42 @@
#ifndef OMG_DDS_SUB_COND_QUERY_CONDITION_HPP_
#define OMG_DDS_SUB_COND_QUERY_CONDITION_HPP_
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <dds/sub/cond/detail/QueryCondition.hpp>
#include <dds/sub/Query.hpp>
#include <dds/sub/cond/detail/TQueryConditionImpl.hpp>
#ifdef OMG_DDS_CONTENT_SUBSCRIPTION_SUPPORT
namespace dds
{
namespace sub
{
namespace cond
{
typedef dds::sub::cond::detail::QueryCondition QueryCondition;
}
}
}
#endif // OMG_DDS_CONTENT_SUBSCRIPTION_SUPPORT
#endif /* OMG_DDS_SUB_COND_QUERY_CONDITION_HPP_ */

View File

@@ -0,0 +1,37 @@
#ifndef OMG_DDS_SUB_COND_READ_CONDITION_HPP_
#define OMG_DDS_SUB_COND_READ_CONDITION_HPP_
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <dds/sub/cond/detail/ReadCondition.hpp>
#include <dds/sub/cond/detail/TReadConditionImpl.hpp>
namespace dds
{
namespace sub
{
namespace cond
{
typedef dds::sub::cond::detail::ReadCondition ReadCondition;
}
}
}
#endif /* OMG_DDS_SUB_COND_READ_CONDITION_HPP_ */

View File

@@ -0,0 +1,301 @@
#ifndef OMG_DDS_SUB_TQUERY_CONDITION_HPP_
#define OMG_DDS_SUB_TQUERY_CONDITION_HPP_
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <dds/core/detail/conformance.hpp>
#include <dds/sub/cond/detail/QueryCondition.hpp>
#include <dds/sub/cond/TReadCondition.hpp>
#ifdef OMG_DDS_CONTENT_SUBSCRIPTION_SUPPORT
namespace dds
{
namespace sub
{
namespace cond
{
template <typename DELEGATE>
class TQueryCondition;
}
}
}
/**
* @brief
* QueryCondition objects are specialized ReadCondition objects that allow
* the application to also specify a filter on the locally available data.
*
* The query (query_expression) is similar to an SQL WHERE clause can be
* parameterized by arguments. See dds::sub::Query for more query information.
*
* See the @ref anchor_dds_core_cond_waitset_examples "WaitSet examples" for some examples.<br>
* Although the WaitSet examples use the StatusCondition, the basic usage of this Condition
* with a WaitSet is the same.
*
* @see dds::sub::Query
* @see dds::core::cond::Condition
* @see dds::sub::cond::ReadCondition
* @see for more information: @ref DCPS_Modules_Infrastructure_Waitset "WaitSet concept"
* @see for more information: @ref DCPS_Modules_Infrastructure_Waitset "Subscription concept"
* @see for more information: @ref anchor_dds_sub_query_expression "SQL expression info"
* @see for more information: @ref anchor_dds_core_cond_waitset_examples "WaitSet examples"
*/
template <typename DELEGATE>
class dds::sub::cond::TQueryCondition :
public dds::sub::cond::TReadCondition<DELEGATE>,
public dds::sub::TQuery<DELEGATE>
{
public:
OMG_DDS_REF_TYPE_PROTECTED_DC(TQueryCondition, dds::sub::cond::TReadCondition, DELEGATE)
OMG_DDS_IMPLICIT_REF_BASE(TQueryCondition)
public:
// Random access iterators
/**
* Iterator for the query expression parameters.
*/
typedef typename DELEGATE::iterator iterator;
/**
* Iterator for the query expression parameters.
*/
typedef typename DELEGATE::const_iterator const_iterator;
public:
/**
* Creates a QueryCondition instance.
*
* This will create an QueryCondition that is associated with a dds::sub::Query,
* which is again associated with a dds::sub::DataReader.
*
*
* @param query The query to filter on the locally available data.
* @param status A mask, which selects only those samples with the desired
* sample/view/instance states.
* @throw dds::core::Exception
*/
TQueryCondition(const dds::sub::Query& query,
const dds::sub::status::DataState& status);
/**
* Creates a QueryCondition instance.
*
* This will create an QueryCondition that is associated with a dds::sub::Query,
* which is again associated with a dds::sub::DataReader.
*
* The supplied functor will be called when this QueryCondition is triggered
* and either the inherited dds::core::cond::Condition::dispatch() is called or the
* dds::core::cond::WaitSet::dispatch() on the WaitSet to which this QueryCondition is
* attached to.
*
* See @ref anchor_dds_sub_query_expression "SQL expression info" <br>
* See @ref anchor_dds_sub_cond_readcondition_state_mask "State mask info" in ReadCondition.
*
* @param query The query to filter on the locally available data.
* @param status A mask, which selects only those samples with the desired
* sample/view/instance states.
* @param functor The functor to be called when the QueryCondition triggers.
* @throw dds::core::Exception
*/
template <typename FUN>
TQueryCondition(const dds::sub::Query& query,
const dds::sub::status::DataState& status, FUN functor);
/**
* Creates a QueryCondition instance.
*
* This will create an QueryCondition that is associated with an dds::sub::AnyDataReader,
* with parameters that essentially represent a query.
*
* See @ref anchor_dds_sub_query_expression "SQL expression info" <br>
* See @ref anchor_dds_sub_cond_readcondition_state_mask "State mask info" in ReadCondition.
*
* @param dr Query associated DataReader.
* @param expression for more information: @ref anchor_dds_sub_query_expression "Query expression"
* @param params for more information: @ref anchor_dds_sub_query_expression "Query expression parameters"
* @param status A mask, which selects only those samples with the desired
* sample/view/instance states.
* @throw dds::core::Exception
*/
TQueryCondition(const dds::sub::AnyDataReader& dr,
const std::string& expression,
const std::vector<std::string>& params,
const dds::sub::status::DataState& status);
/**
* Creates a QueryCondition instance.
*
* This will create an QueryCondition that is associated with an dds::sub::AnyDataReader,
* with parameters that essentially represent a query.
*
* See @ref anchor_dds_sub_query_expression "SQL expression info" <br>
* See @ref anchor_dds_sub_cond_readcondition_state_mask "State mask info" in ReadCondition.
*
* @param dr Query associated DataReader.
* @param status A mask, which selects only those samples with the desired
* sample/view/instance states.
* @throw dds::core::Exception
*/
TQueryCondition(const dds::sub::AnyDataReader& dr,
const dds::sub::status::DataState& status);
/**
* Creates a QueryCondition instance.
*
* This will create an QueryCondition that is associated with an dds::sub::AnyDataReader,
* with parameters that essentially represent a query.
*
* The supplied functor will be called when this QueryCondition is triggered
* and either the inherited dds::core::cond::Condition::dispatch() is called or the
* dds::core::cond::WaitSet::dispatch() on the WaitSet to which this QueryCondition is
* attached to.
*
* See @ref anchor_dds_sub_query_expression "SQL expression info" <br>
* See @ref anchor_dds_sub_cond_readcondition_state_mask "State mask info" in ReadCondition.
*
* @param dr Query associated DataReader.
* @param expression for more information: @ref anchor_dds_sub_query_expression "Query expression"
* @param params for more information: @ref anchor_dds_sub_query_expression "Query expression parameters"
* @param status A mask, which selects only those samples with the desired
* sample/view/instance states.
* @throw dds::core::Exception
*/
template <typename FUN>
TQueryCondition(const dds::sub::AnyDataReader& dr,
const std::string& expression,
const std::vector<std::string>& params,
const dds::sub::status::DataState& status,
FUN functor);
public:
/**
* Set the Query expression.
*
* @param expr for more information: @ref anchor_dds_sub_query_expression "SQL expression"
* @throw dds::core::Exception
*/
void expression(const std::string& expr);
/**
* Get the Query expression.
*
* See @ref anchor_dds_sub_query_expression "SQL expression info"
*
* @return std::string The query expression
* @throw dds::core::Exception
*/
const std::string& expression();
/**
* Provides the beginning iterator of the query parameter list.
*
* See @ref anchor_dds_sub_query_expression "SQL expression info"
*
* @return dds::sub::cond::TQueryCondition::const_iterator
* The beginning iterator
* @throw dds::core::Exception
*/
const_iterator begin() const;
/**
* Provides the end iterator of the query parameter list.
*
* See @ref anchor_dds_sub_query_expression "SQL expression info"
*
* @return dds::sub::cond::TQueryCondition::const_iterator
* The end iterator
* @throw dds::core::Exception
*/
const_iterator end() const;
/**
* Provides the beginning iterator of the query parameter list.
*
* See @ref anchor_dds_sub_query_expression "SQL expression info"
*
* @return dds::sub::cond::TQueryCondition::iterator
* The beginning iterator
* @throw dds::core::Exception
*/
iterator begin();
/**
* Provides the end iterator of the query parameter list.
*
* See @ref anchor_dds_sub_query_expression "SQL expression info"
*
* @return dds::sub::cond::TQueryCondition::iterator
* The end iterator
* @throw dds::core::Exception
*/
iterator end();
/**
* Sets the query parameters.
*
* See @ref anchor_dds_sub_query_expression "SQL expression info"
*
* @param begin Iterator pointing to the beginning of the parameters to set
* @param end Iterator pointing to the end of the parameters to set
* @throw dds::core::Exception
*/
template<typename FWIterator>
void parameters(const FWIterator& begin, const FWIterator end);
/**
* Adds a parameter to the query.
*
* See @ref anchor_dds_sub_query_expression "SQL expression info"
*
* @param param The parameter to add
* @throw dds::core::Exception
*/
void add_parameter(const std::string& param);
/**
* Gets the number of parameters in the query.
*
* See @ref anchor_dds_sub_query_expression "SQL expression info"
*
* @return uint32_t The number of parameters in the query
* @throw dds::core::Exception
*/
uint32_t parameters_length() const;
/**
* This operation returns the DataReader associated with the QueryCondition.
*
* Note that there is exactly one DataReader associated with each QueryCondition.
*
* @cond
* Note also that since QueryCondition overrides this call since it inherits
* two different implementations from its two different parents. Not offering
* an implementation here would results in an ambiguity.
* @endcond
*
* @return dds::sub::AnyDataReader The associated DataReader
* @throw dds::core::Exception
*/
const dds::sub::AnyDataReader& data_reader() const;
};
#endif // OMG_DDS_CONTENT_SUBSCRIPTION_SUPPORT
#endif /* OMG_DDS_SUB_TQUERY_CONDITION_HPP_ */

View File

@@ -0,0 +1,143 @@
#ifndef OMG_DDS_SUB_TCOND_READ_CONDITION_HPP_
#define OMG_DDS_SUB_TCOND_READ_CONDITION_HPP_
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <dds/core/cond/TCondition.hpp>
#include <dds/sub/DataReader.hpp>
#include <dds/sub/AnyDataReader.hpp>
namespace dds
{
namespace sub
{
namespace cond
{
template <typename DELEGATE>
class TReadCondition;
}
}
}
/**
* @brief
* ReadCondition objects are conditions specifically dedicated
* to read operations and attached to one DataReader.
*
* ReadCondition objects allow an application to specify the data samples
* it is interested in (by specifying the desired sample states, view states,
* and instance states). (See the parameter definitions for DataReader's
* read/take operations.) This allows the middle-ware to enable the condition
* only when suitable information is available. They are to be used in
* conjunction with a WaitSet as normal conditions. More than one
* ReadCondition may be attached to the same DataReader.
*
* See the @ref anchor_dds_core_cond_waitset_examples "WaitSet examples" for some examples.<br>
* Although the WaitSet examples use the StatusCondition, the basic usage of this Condition
* with a WaitSet is the same.
*
* @see dds::core::cond::Condition
* @see for more information: @ref DCPS_Modules_Infrastructure_Status "Status concept"
* @see for more information: @ref DCPS_Modules_Infrastructure_Waitset "WaitSet concept"
* @see for more information: @ref DCPS_Modules_Infrastructure_Waitset "Subscription concept"
* @see for more information: @ref anchor_dds_core_cond_waitset_examples "WaitSet examples"
*/
template <typename DELEGATE>
class dds::sub::cond::TReadCondition : public dds::core::cond::TCondition<DELEGATE>
{
public:
OMG_DDS_REF_TYPE_PROTECTED_DC(TReadCondition, dds::core::cond::TCondition, DELEGATE)
OMG_DDS_IMPLICIT_REF_BASE(TReadCondition)
public:
/**
* Create a dds::sub::cond::ReadCondition associated with a DataReader.
*
* The ReadCondition can then be added to a dds::core::cond::WaitSet so that the
* application can wait for specific status changes that affect the Entity.
*
* @anchor anchor_dds_sub_cond_readcondition_state_mask
* State Masks.<br>
* The result of the ReadCondition depends on the selection of samples determined by
* three masks:
* - DataState::sample_state() is the mask, which selects only those samples with the desired
* sample states SampleState::read(), SampleState::not_read() or SampleState::any().
* - DataState::view_state() is the mask, which selects only those samples with the desired
* view states ViewState::new_view(), ViewState::not_new_view() or ViewState::any().
* - DataState::instance_state() is the mask, which selects only those samples with the desired
* view states InstanceState::alive(), InstanceState::not_alive_disposed(),
* InstanceState::not_alive_no_writers(), InstanceState::not_alive_mask() or InstanceState::any().
* See also @ref DCPS_Modules_Infrastructure_Status "Status Concept".
*
* @param dr The DataReader to associate with the ReadCondition.
* @param status A mask, which selects only those samples with the desired
* sample/view/instance states.
* @throw dds::core::Exception
*/
TReadCondition(const dds::sub::AnyDataReader& dr, const dds::sub::status::DataState& status);
/**
* Create a dds::sub::cond::ReadCondition associated with a DataReader.
*
* The ReadCondition can then be added to a dds::core::cond::WaitSet so that the
* application can wait for specific status changes that affect the Entity.
*
* The supplied functor will be called when this ReadCondition is triggered
* and either the inherited dds::core::cond::Condition::dispatch() is called or the
* dds::core::cond::WaitSet::dispatch() on the WaitSet to which this ReadCondition is
* attached to.
*
* See @ref anchor_dds_sub_cond_readcondition_state_mask "State mask info".
*
* @param dr The DataReader to associate with the ReadCondition.
* @param status A mask, which selects only those samples with the desired
* sample/view/instance states.
* @param functor The functor to be called when the ReadCondition triggers.
* @throw dds::core::Exception
*/
template <typename FUN>
TReadCondition(const dds::sub::AnyDataReader& dr, const dds::sub::status::DataState& status, FUN functor);
public:
/**
* This operation returns the set of data-states that are taken into
* account to determine the trigger_value of the ReadCondition.
*
* These are data-states specified when the ReadCondition was created.
*
* @return dds::sub::status::DataState The data state.
* @throw dds::core::Exception
*/
const dds::sub::status::DataState state_filter() const;
/**
* This operation returns the DataReader associated with the ReadCondition.
*
* Note that there is exactly one DataReader associated with each ReadCondition.
*
* @return dds::sub::AnyDataReader The associated DataReader
* @throw dds::core::Exception
*/
const dds::sub::AnyDataReader& data_reader() const;
};
#endif /* OMG_DDS_SUB_TCOND_READ_CONDITION_HPP_ */

View File

@@ -0,0 +1,57 @@
#ifndef OMG_DDS_SUB_DETAIL_QUERY_CONDITION_HPP_
#define OMG_DDS_SUB_DETAIL_QUERY_CONDITION_HPP_
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace sub
{
namespace cond
{
class QueryConditionDelegate;
}
}
}
}
}
namespace dds
{
namespace sub
{
namespace cond
{
template <typename DELEGATE>
class TQueryCondition;
namespace detail
{
typedef dds::sub::cond::TQueryCondition<org::eclipse::cyclonedds::sub::cond::QueryConditionDelegate> QueryCondition;
}
}
}
}
#endif /* OMG_DDS_SUB_DETAIL_QUERY_CONDITION_HPP_ */

View File

@@ -0,0 +1,50 @@
/*
* Copyright(c) 2006 to 2020 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef OMG_DDS_SUB_DETAIL_READ_CONDITION_HPP_
#define OMG_DDS_SUB_DETAIL_READ_CONDITION_HPP_
namespace org
{
namespace eclipse
{
namespace cyclonedds
{
namespace sub
{
namespace cond
{
class ReadConditionDelegate;
}
}
}
}
}
namespace dds
{
namespace sub
{
namespace cond
{
template <typename DELEGATE>
class TReadCondition;
namespace detail
{
typedef dds::sub::cond::TReadCondition<org::eclipse::cyclonedds::sub::cond::ReadConditionDelegate> ReadCondition;
}
}
}
}
#endif /* OMG_DDS_SUB_DETAIL_READ_CONDITION_HPP_ */

View File

@@ -0,0 +1,202 @@
/*
* Copyright(c) 2006 to 2021 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef CYCLONEDDS_DDS_SUB_COND_TQUERYCONDITION_IMPL_HPP_
#define CYCLONEDDS_DDS_SUB_COND_TQUERYCONDITION_IMPL_HPP_
/**
* @file
*/
/*
* OMG PSM class declaration
*/
#include <dds/sub/cond/TQueryCondition.hpp>
#include <org/eclipse/cyclonedds/sub/cond/QueryConditionDelegate.hpp>
// Implementation
namespace dds
{
namespace sub
{
namespace cond
{
template <typename DELEGATE>
TQueryCondition<DELEGATE>::TQueryCondition(
const dds::sub::Query& query,
const dds::sub::status::DataState& status)
{
this->set_ref(new DELEGATE(query.data_reader(),
query.expression(), query.delegate()->parameters(), status));
this->delegate()->init(this->impl_);
}
template <typename DELEGATE>
template <typename FUN>
TQueryCondition<DELEGATE>::TQueryCondition(
const dds::sub::Query& query,
const dds::sub::status::DataState& status, FUN functor)
{
this->set_ref(new DELEGATE(query.data_reader(),
query.expression(), query.delegate()->parameters(), status));
this->delegate()->set_handler(functor);
this->delegate()->init(this->impl_);
}
template <typename DELEGATE>
TQueryCondition<DELEGATE>::TQueryCondition(
const dds::sub::AnyDataReader& dr,
const std::string& expression,
const std::vector<std::string>& params,
const dds::sub::status::DataState& status)
{
this->set_ref(new DELEGATE(dr, expression, params, status));
this->delegate()->init(this->impl_);
}
template <typename DELEGATE>
TQueryCondition<DELEGATE>::TQueryCondition(
const dds::sub::AnyDataReader& dr,
const dds::sub::status::DataState& status)
{
this->set_ref(new DELEGATE(dr, status));
this->delegate()->init(this->impl_);
}
template <typename DELEGATE>
template <typename FUN>
TQueryCondition<DELEGATE>::TQueryCondition(
const dds::sub::AnyDataReader& dr,
const std::string& expression,
const std::vector<std::string>& params,
const dds::sub::status::DataState& status,
FUN functor)
{
this->set_ref(new DELEGATE(dr, expression, params, status));
this->delegate()->set_handler(functor);
this->delegate()->init(this->impl_);
}
template <typename DELEGATE>
template<typename FWIterator>
void TQueryCondition<DELEGATE>::parameters(const FWIterator& begin, const FWIterator end)
{
std::vector<std::string> params(begin, end);
this->delegate()->parameters(params);
}
template <typename DELEGATE>
void TQueryCondition<DELEGATE>::expression(
const std::string& expr)
{
this->delegate()->expression(expr);
}
template <typename DELEGATE>
const std::string& TQueryCondition<DELEGATE>::expression()
{
return this->delegate()->expression();
}
template <typename DELEGATE>
typename TQueryCondition<DELEGATE>::const_iterator TQueryCondition<DELEGATE>::begin() const
{
return this->delegate()->begin();
}
template <typename DELEGATE>
typename TQueryCondition<DELEGATE>::const_iterator TQueryCondition<DELEGATE>::end() const
{
return this->delegate()->end();
}
template <typename DELEGATE>
typename TQueryCondition<DELEGATE>::iterator TQueryCondition<DELEGATE>::begin()
{
return this->delegate()->begin();
}
template <typename DELEGATE>
typename TQueryCondition<DELEGATE>::iterator TQueryCondition<DELEGATE>::end()
{
return this->delegate()->end();
}
template <typename DELEGATE>
void TQueryCondition<DELEGATE>::add_parameter(
const std::string& param)
{
this->delegate()->add_parameter(param);
}
template <typename DELEGATE>
uint32_t TQueryCondition<DELEGATE>::parameters_length() const
{
return this->delegate()->parameters_length();
}
template <typename DELEGATE>
const AnyDataReader& TQueryCondition<DELEGATE>::data_reader() const
{
return this->delegate()->data_reader();
}
}
}
namespace core
{
namespace cond
{
template <typename DELEGATE>
TCondition<DELEGATE>::TCondition(const dds::sub::cond::TQueryCondition<org::eclipse::cyclonedds::sub::cond::QueryConditionDelegate>& h)
{
if (h.is_nil()) {
/* We got a null object and are not really able to do a typecheck here. */
/* So, just set a null object. */
*this = dds::core::null;
} else {
this->::dds::core::Reference<DELEGATE>::impl_ = ::std::dynamic_pointer_cast<DELEGATE_T>(h.delegate());
if (h.delegate() != this->::dds::core::Reference<DELEGATE>::impl_) {
throw dds::core::IllegalOperationError(std::string("Attempted invalid cast: ") + typeid(h).name() + " to " + typeid(*this).name());
}
}
}
template <typename DELEGATE>
TCondition<DELEGATE>&
TCondition<DELEGATE>::operator=(const dds::sub::cond::TQueryCondition<org::eclipse::cyclonedds::sub::cond::QueryConditionDelegate>& rhs)
{
if (this != static_cast<TCondition*>(&rhs)) {
if (rhs.is_nil()) {
/* We got a null object and are not really able to do a typecheck here. */
/* So, just set a null object. */
*this = dds::core::null;
} else {
TCondition other(rhs);
/* Dont have to copy when the delegate is the same. */
if (other.delegate() != this->::dds::core::Reference<DELEGATE>::impl_) {
*this = other;
}
}
}
return *this;
}
}
}
}
// End of implementation
#endif /* CYCLONEDDS_DDS_SUB_COND_TQUERYCONDITION_IMPL_HPP_ */

View File

@@ -0,0 +1,113 @@
/*
* Copyright(c) 2006 to 2021 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef CYCLONEDDS_DDS_CORE_COND_TREADCONDITION_IMPL_HPP_
#define CYCLONEDDS_DDS_CORE_COND_TREADCONDITION_IMPL_HPP_
/**
* @file
*/
/*
* OMG PSM class declaration
*/
#include <dds/sub/cond/TReadCondition.hpp>
#include <org/eclipse/cyclonedds/sub/cond/ReadConditionDelegate.hpp>
// Implementation
namespace dds
{
namespace sub
{
namespace cond
{
template <typename DELEGATE>
TReadCondition<DELEGATE>::TReadCondition(
const dds::sub::AnyDataReader& dr,
const dds::sub::status::DataState& status)
{
this->set_ref(new DELEGATE(dr, status));
this->delegate()->init(this->impl_);
}
template <typename DELEGATE>
template <typename FUN>
TReadCondition<DELEGATE>::TReadCondition(
const dds::sub::AnyDataReader& dr,
const dds::sub::status::DataState& status,
FUN functor)
{
this->set_ref(new DELEGATE(dr, status));
this->delegate()->init(this->impl_);
this->delegate()->set_handler(functor);
}
template <typename DELEGATE>
const dds::sub::status::DataState TReadCondition<DELEGATE>::state_filter() const
{
return this->delegate()->state_filter();
}
template <typename DELEGATE>
const AnyDataReader& TReadCondition<DELEGATE>::data_reader() const
{
return this->delegate()->data_reader();
}
}
}
namespace core
{
namespace cond
{
template <typename DELEGATE>
TCondition<DELEGATE>::TCondition(const dds::sub::cond::TReadCondition<org::eclipse::cyclonedds::sub::cond::ReadConditionDelegate>& h)
{
if (h.is_nil()) {
/* We got a null object and are not really able to do a typecheck here. */
/* So, just set a null object. */
*this = dds::core::null;
} else {
this->::dds::core::Reference<DELEGATE>::impl_ = ::std::dynamic_pointer_cast<DELEGATE_T>(h.delegate());
if (h.delegate() != this->::dds::core::Reference<DELEGATE>::impl_) {
throw dds::core::IllegalOperationError(std::string("Attempted invalid cast: ") + typeid(h).name() + " to " + typeid(*this).name());
}
}
}
template <typename DELEGATE>
TCondition<DELEGATE>&
TCondition<DELEGATE>::operator=(const dds::sub::cond::TReadCondition<org::eclipse::cyclonedds::sub::cond::ReadConditionDelegate>& rhs)
{
const TCondition<DELEGATE> &t = rhs;
if (this != &t) {
if (rhs.is_nil()) {
/* We got a null object and are not really able to do a typecheck here. */
/* So, just set a null object. */
*this = dds::core::null;
} else {
TCondition other(rhs);
/* Dont have to copy when the delegate is the same. */
if (other.delegate() != this->::dds::core::Reference<DELEGATE>::impl_) {
*this = other;
}
}
}
return *this;
}
}
}
}
// End of implementation
#endif /* CYCLONEDDS_DDS_CORE_COND_TREADCONDITION_IMPL_HPP_ */

View File

@@ -0,0 +1,129 @@
#ifndef OMG_DDS_SUB_PACKAGE_INCLUDE_HPP_
#define OMG_DDS_SUB_PACKAGE_INCLUDE_HPP_
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <dds/core/detail/conformance.hpp>
/* Depends on:
* <dds/sub/Subscriber.hpp>
* <dds/sub/status/DataStatus.hpp>
* <dds/sub/Sample.hpp>
* <dds/sub/LoanedSamples.hpp>
*/
#include <dds/sub/DataReader.hpp>
/////////////////////////////////////////////////////////////////////////////
// -- Status Includes
#include <dds/sub/status/DataState.hpp>
/////////////////////////////////////////////////////////////////////////////
// -- QoS Includes
#include <dds/sub/qos/DataReaderQos.hpp>
#include <dds/sub/qos/SubscriberQos.hpp>
/////////////////////////////////////////////////////////////////////////////
// -- Sub Includes
#include <dds/sub/Rank.hpp>
#include <dds/sub/GenerationCount.hpp>
/* Depends on:
* Forward declaration of AnyDataReader
*/
#include <dds/sub/AnyDataReaderListener.hpp>
/*
* Depends on:
* <dds/sub/GenerationCount.hpp>
* <dds/sub/Rank.hpp>
*/
#include <dds/sub/SampleInfo.hpp>
#include <dds/sub/LoanedSamples.hpp>
#include <dds/sub/SharedSamples.hpp>
/* Depends on:
* <dds/sub/qos/SubscriberQos.hpp>
* <dds/sub/qos/DataReaderQos.hpp>
*/
#include <dds/sub/Subscriber.hpp>
/* Depends on:
* <dds/sub/Subscriber.hpp>
*/
#include <dds/sub/CoherentAccess.hpp>
/* Depends on:
* <dds/sub/AnyDataReaderListener.hpp>
* <dds/sub/Subscriber.hpp>
*/
#include <dds/sub/SubscriberListener.hpp>
/* Depends on:
* <dds/sub/AnyDataReaderListener.hpp>
*/
#include <dds/sub/DataReaderListener.hpp>
/* Depends on:
* <dds/sub/Subscriber.hpp>
* <dds/sub/DataReader.hpp>
*/
#include <dds/sub/AnyDataReader.hpp>
/////////////////////////////////////////////////////////////////////////////
// -- Condition Includes
/* Depends on:
* <dds/sub/DataReader.hpp>
*/
#include <dds/sub/cond/ReadCondition.hpp>
#include <dds/sub/Query.hpp>
/* Depends on:
* <dds/sub/status/DataState.hpp>
* <dds/sub/cond/ReadCondition.hpp>
* <dds/sub/Query.hpp>
*/
#include <dds/sub/cond/QueryCondition.hpp>
/* Depends on:
* <dds/sub/Subscriber.hpp>
* <dds/sub/status/ReaderState.hpp>
*/
#include <dds/sub/find.hpp>
#include <dds/sub/discovery.hpp>
//
// Pretty Print Utilities
//
// #if (OMG_DDS_HAS_PRETTY_PRINT_COUT == 1)
std::ostream& operator << (std::ostream& os, const dds::sub::status::DataState& s);
std::ostream& operator << (std::ostream& os, const dds::sub::Rank& r);
std::ostream& operator << (std::ostream& os, const dds::sub::SampleInfo& si);
#include <dds/sub/detail/ddssub.hpp>
// #endif
#endif /* OMG_DDS_SUB_PACKAGE_INCLUDE_HPP_ */

View File

@@ -0,0 +1,22 @@
/*
* Copyright(c) 2006 to 2020 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef CYCLONEDDS_DDS_SUB_DETAIL_ANYDATAREADER_HPP_
#define CYCLONEDDS_DDS_SUB_DETAIL_ANYDATAREADER_HPP_
#include <dds/sub/detail/TAnyDataReaderImpl.hpp>
#include <org/eclipse/cyclonedds/sub/AnyDataReaderDelegate.hpp>
namespace dds { namespace sub { namespace detail {
typedef dds::sub::TAnyDataReader<org::eclipse::cyclonedds::sub::AnyDataReaderDelegate> AnyDataReader;
} } }
#endif /* CYCLONEDDS_DDS_SUB_DETAIL_ANYDATAREADER_HPP_ */

View File

@@ -0,0 +1,22 @@
/*
* Copyright(c) 2006 to 2020 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef OMG_DDS_SUB_DETAIL_COHERENT_ACCESS_HPP_
#define OMG_DDS_SUB_DETAIL_COHERENT_ACCESS_HPP_
#include <dds/sub/detail/TCoherentAccessImpl.hpp>
#include <org/eclipse/cyclonedds/sub/CoherentAccessDelegate.hpp>
namespace dds { namespace sub { namespace detail {
typedef ::dds::sub::TCoherentAccess<org::eclipse::cyclonedds::sub::CoherentAccessDelegate> CoherentAccess;
} } }
#endif /* OMG_DDS_SUB_DETAIL_COHERENT_ACCESS_HPP_ */

View File

@@ -0,0 +1,234 @@
/*
* Copyright(c) 2006 to 2020 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef OMG_DDS_SUB_DETAIL_DATA_READER_HPP_
#define OMG_DDS_SUB_DETAIL_DATA_READER_HPP_
#include <dds/topic/Topic.hpp>
#include <dds/topic/TopicInstance.hpp>
#include <dds/core/status/Status.hpp>
#include <dds/sub/status/detail/DataStateImpl.hpp>
#include <dds/sub/detail/Manipulators.hpp>
#include <dds/sub/LoanedSamples.hpp>
#include <dds/sub/Subscriber.hpp>
#include <dds/sub/Query.hpp>
#include <org/eclipse/cyclonedds/core/EntityDelegate.hpp>
#include <org/eclipse/cyclonedds/sub/AnyDataReaderDelegate.hpp>
#include <org/eclipse/cyclonedds/core/ScopedLock.hpp>
#include <org/eclipse/cyclonedds/ForwardDeclarations.hpp>
#include <dds/dds.h>
/***************************************************************************
*
* dds/sub/detail/DataReader<> DELEGATE declaration.
* Implementation can be found in dds/sub/detail/TDataReaderImpl.hpp
*
***************************************************************************/
template <typename T>
class dds::sub::detail::DataReader : public ::org::eclipse::cyclonedds::sub::AnyDataReaderDelegate
{
public:
typedef typename ::dds::core::smart_ptr_traits< DataReader<T> >::ref_type ref_type;
typedef typename ::dds::core::smart_ptr_traits< DataReader<T> >::weak_ref_type weak_ref_type;
DataReader(const dds::sub::Subscriber& sub,
const dds::topic::Topic<T>& topic,
const dds::sub::qos::DataReaderQos& qos,
dds::sub::DataReaderListener<T>* listener = NULL,
const dds::core::status::StatusMask& mask = ::dds::core::status::StatusMask::none());
DataReader(const dds::sub::Subscriber& sub,
const dds::topic::ContentFilteredTopic<T, dds::topic::detail::ContentFilteredTopic>& topic,
const dds::sub::qos::DataReaderQos& qos,
dds::sub::DataReaderListener<T>* listener = NULL,
const dds::core::status::StatusMask& mask = ::dds::core::status::StatusMask::none());
void common_constructor(dds::sub::DataReaderListener<T>* listener,
const dds::core::status::StatusMask& mask);
virtual ~DataReader();
void copy_samples(
dds::sub::detail::SamplesHolder& samples,
void**& c_sample_pointers,
dds_sample_info_t*& c_sample_infos,
int num_read);
void init(ObjectDelegate::weak_ref_type weak_ref);
dds::sub::status::DataState default_filter_state();
void default_filter_state(const dds::sub::status::DataState& state);
bool is_loan_supported();
dds::sub::LoanedSamples<org::eclipse::cyclonedds::topic::CDRBlob> read_cdr();
dds::sub::LoanedSamples<org::eclipse::cyclonedds::topic::CDRBlob> take_cdr();
dds::sub::LoanedSamples<T> read();
dds::sub::LoanedSamples<T> take();
template<typename SamplesFWIterator>
uint32_t read(SamplesFWIterator samples, uint32_t max_samples);
template<typename SamplesFWIterator>
uint32_t take(SamplesFWIterator samples, uint32_t max_samples);
template<typename SamplesBIIterator>
uint32_t read(SamplesBIIterator samples);
template<typename SamplesBIIterator>
uint32_t take(SamplesBIIterator samples);
dds::topic::TopicInstance<T> key_value(const dds::core::InstanceHandle& h);
T& key_value(T& key, const dds::core::InstanceHandle& h);
const dds::core::InstanceHandle lookup_instance(const T& key) const;
virtual const dds::sub::Subscriber& subscriber() const;
void close();
dds::sub::DataReaderListener<T>* listener();
void listener(dds::sub::DataReaderListener<T>* l,
const dds::core::status::StatusMask& event_mask);
dds::sub::DataReader<T, dds::sub::detail::DataReader> wrapper();
void on_requested_deadline_missed(dds_entity_t,
org::eclipse::cyclonedds::core::RequestedDeadlineMissedStatusDelegate &);
void on_requested_incompatible_qos(dds_entity_t,
org::eclipse::cyclonedds::core::RequestedIncompatibleQosStatusDelegate &);
void on_sample_rejected(dds_entity_t,
org::eclipse::cyclonedds::core::SampleRejectedStatusDelegate &);
void on_liveliness_changed(dds_entity_t,
org::eclipse::cyclonedds::core::LivelinessChangedStatusDelegate &);
void on_data_available(dds_entity_t);
void on_subscription_matched(dds_entity_t,
org::eclipse::cyclonedds::core::SubscriptionMatchedStatusDelegate &);
void on_sample_lost(dds_entity_t,
org::eclipse::cyclonedds::core::SampleLostStatusDelegate &);
private:
dds::sub::Subscriber sub_;
dds::sub::status::DataState status_filter_;
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
private:
enum SelectMode {
SELECT_MODE_READ,
SELECT_MODE_READ_INSTANCE,
SELECT_MODE_READ_NEXT_INSTANCE,
SELECT_MODE_READ_WITH_CONDITION,
SELECT_MODE_READ_INSTANCE_WITH_CONDITION,
SELECT_MODE_READ_NEXT_INSTANCE_WITH_CONDITION
};
public:
class Selector
{
public:
Selector(typename DataReader<T>::ref_type dr);
Selector& instance(const dds::core::InstanceHandle& h);
Selector& next_instance(const dds::core::InstanceHandle& h);
Selector& filter_state(const dds::sub::status::DataState& s);
Selector& max_samples(uint32_t n);
Selector& filter_content(const dds::sub::Query& query);
dds::sub::LoanedSamples<T> read();
dds::sub::LoanedSamples<T> take();
// --- Forward Iterators: --- //
template<typename SamplesFWIterator>
uint32_t read(SamplesFWIterator sfit, uint32_t max_samples);
template<typename SamplesFWIterator>
uint32_t take(SamplesFWIterator sfit, uint32_t max_samples);
// --- Back-Inserting Iterators: --- //
template<typename SamplesBIIterator>
uint32_t read(SamplesBIIterator sbit);
template<typename SamplesBIIterator>
uint32_t take(SamplesBIIterator sbit);
SelectMode get_mode() const;
private:
friend class DataReader;
SelectMode mode;
typename DataReader<T>::ref_type reader;
dds::sub::status::DataState state_filter_;
bool state_filter_is_set_;
dds::core::InstanceHandle handle;
uint32_t max_samples_;
dds::sub::Query query_;
};
class ManipulatorSelector: public Selector
{
public:
//ManipulatorSelector(DataReader<T>* dr);
ManipulatorSelector(typename DataReader<T>::ref_type dr);
bool read_mode();
void read_mode(bool b);
ManipulatorSelector&
operator >>(dds::sub::LoanedSamples<T>& samples);
private:
bool read_mode_;
};
private:
// ==============================================================
// == Selector Read/Take API
dds::sub::LoanedSamples<T> read(const Selector& selector);
dds::sub::LoanedSamples<T> take(const Selector& selector);
// --- Forward Iterators: --- //
template<typename SamplesFWIterator>
uint32_t read(SamplesFWIterator samples,
uint32_t max_samples, const Selector& selector);
template<typename SamplesFWIterator>
uint32_t take(SamplesFWIterator samples,
uint32_t max_samples, const Selector& selector);
// --- Back-Inserting Iterators: --- //
template<typename SamplesBIIterator>
uint32_t read(SamplesBIIterator samples, const Selector& selector);
template<typename SamplesBIIterator>
uint32_t take(SamplesBIIterator samples, const Selector& selector);
private:
T typed_sample_;
};
#endif /* OMG_TDDS_SUB_DETAIL_DATA_READER_HPP_ */

View File

@@ -0,0 +1,26 @@
/*
* Copyright(c) 2006 to 2020 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef OMG_DDS_SUB_DETAIL_GENERATION_COUNT_HPP_
#define OMG_DDS_SUB_DETAIL_GENERATION_COUNT_HPP_
#include <dds/sub/detail/TGenerationCountImpl.hpp>
#include <org/eclipse/cyclonedds/sub/GenerationCountImpl.hpp>
namespace dds {
namespace sub {
namespace detail {
typedef dds::sub::TGenerationCount< org::eclipse::cyclonedds::sub::GenerationCountImpl > GenerationCount;
}
}
}
#endif /* OMG_DDS_SUB_DETAIL_GENERATION_COUNT_HPP_ */

View File

@@ -0,0 +1,152 @@
/*
* Copyright(c) 2006 to 2021 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef OMG_SUB_DETAIL_LOANED_SAMPLES_IMPL_HPP_
#define OMG_SUB_DETAIL_LOANED_SAMPLES_IMPL_HPP_
namespace dds
{
namespace sub
{
namespace detail
{
template <typename T>
class LoanedSamples
{
public:
typedef std::vector< dds::sub::SampleRef<T, dds::sub::detail::SampleRef> > LoanedSamplesContainer;
typedef typename std::vector< dds::sub::SampleRef<T, dds::sub::detail::SampleRef> >::iterator iterator;
typedef typename std::vector< dds::sub::SampleRef<T, dds::sub::detail::SampleRef> >::const_iterator const_iterator;
public:
LoanedSamples() { }
~LoanedSamples()
{
}
public:
iterator mbegin()
{
return samples_.begin();
}
const_iterator begin() const
{
return samples_.begin();
}
const_iterator end() const
{
return samples_.end();
}
uint32_t length() const
{
return static_cast<uint32_t>(samples_.size());
}
void reserve(uint32_t s)
{
samples_.reserve(s);
}
void resize(uint32_t s)
{
samples_.resize(s);
}
dds::sub::SampleRef<T, dds::sub::detail::SampleRef>& operator[] (uint32_t i)
{
return this->samples_[i];
}
dds::sub::SampleRef<T, dds::sub::detail::SampleRef> * get_buffer() {
return this->samples_.data();
}
private:
LoanedSamplesContainer samples_;
};
template <>
class LoanedSamples<org::eclipse::cyclonedds::topic::CDRBlob>
{
public:
typedef std::vector< dds::sub::Sample<org::eclipse::cyclonedds::topic::CDRBlob, dds::sub::detail::Sample> > LoanedSamplesContainer;
typedef typename std::vector< dds::sub::Sample<org::eclipse::cyclonedds::topic::CDRBlob, dds::sub::detail::Sample> >::iterator iterator;
typedef typename std::vector< dds::sub::Sample<org::eclipse::cyclonedds::topic::CDRBlob, dds::sub::detail::Sample> >::const_iterator const_iterator;
public:
LoanedSamples() { }
~LoanedSamples()
{
}
public:
iterator mbegin()
{
return samples_.begin();
}
const_iterator begin() const
{
return samples_.begin();
}
const_iterator end() const
{
return samples_.end();
}
uint32_t length() const
{
return static_cast<uint32_t>(samples_.size());
}
void reserve(uint32_t s)
{
samples_.reserve(s);
}
void resize(uint32_t s)
{
samples_.resize(s);
}
dds::sub::Sample<org::eclipse::cyclonedds::topic::CDRBlob, dds::sub::detail::Sample>& operator[] (uint32_t i)
{
return this->samples_[i];
}
dds::sub::Sample<org::eclipse::cyclonedds::topic::CDRBlob, dds::sub::detail::Sample> * get_buffer() {
return this->samples_.data();
}
private:
LoanedSamplesContainer samples_;
};
}
}
}
#endif /* OMG_SUB_DETAIL_LOANED_SAMPLES_IMPL_HPP_ */

View File

@@ -0,0 +1,83 @@
/*
* Copyright(c) 2006 to 2021 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef CYCLONEDDS_DDS_SUB_DETAIL_LOANED_SAMPLES_IMPL_HPP_
#define CYCLONEDDS_DDS_SUB_DETAIL_LOANED_SAMPLES_IMPL_HPP_
/**
* @file
*/
/*
* OMG PSM class declaration
*/
// Implementation
namespace dds
{
namespace sub
{
template <typename T, template <typename Q> class DELEGATE>
LoanedSamples<T, DELEGATE>::LoanedSamples() : delegate_(new DELEGATE<T>()) { }
template <typename T, template <typename Q> class DELEGATE>
LoanedSamples<T, DELEGATE>::~LoanedSamples() { }
template <typename T, template <typename Q> class DELEGATE>
LoanedSamples<T, DELEGATE>::LoanedSamples(const LoanedSamples& other): delegate_(other.delegate_)
{
}
template <typename T, template <typename Q> class DELEGATE>
LoanedSamples<T, DELEGATE>::LoanedSamples(LoanedSamples&& other): delegate_(other.delegate_)
{
}
template <typename T, template <typename Q> class DELEGATE>
typename LoanedSamples<T, DELEGATE>::const_iterator LoanedSamples<T, DELEGATE>::begin() const
{
return delegate()->begin();
}
template <typename T, template <typename Q> class DELEGATE>
typename LoanedSamples<T, DELEGATE>::const_iterator LoanedSamples<T, DELEGATE>::end() const
{
return delegate()->end();
}
template <typename T, template <typename Q> class DELEGATE>
const typename LoanedSamples<T, DELEGATE>::DELEGATE_REF_T& LoanedSamples<T, DELEGATE>::delegate() const
{
return delegate_;
}
template <typename T, template <typename Q> class DELEGATE>
typename LoanedSamples<T, DELEGATE>::DELEGATE_REF_T& LoanedSamples<T, DELEGATE>::delegate()
{
return delegate_;
}
template <typename T, template <typename Q> class DELEGATE>
uint32_t LoanedSamples<T, DELEGATE>::length() const
{
return delegate_->length();
}
}
}
// End of implementation
#endif /* CYCLONEDDS_DDS_SUB_DETAIL_LOANED_SAMPLES_IMPL_HPP_ */

View File

@@ -0,0 +1,125 @@
/*
* Copyright(c) 2006 to 2020 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef CYCLONEDDS_DDS_SUB_DETAIL_MANIPULATOR_HPP_
#define CYCLONEDDS_DDS_SUB_DETAIL_MANIPULATOR_HPP_
/**
* @file
*/
#include <dds/sub/Query.hpp>
namespace dds
{
namespace sub
{
namespace functors
{
namespace detail
{
class MaxSamplesManipulatorFunctor
{
public:
MaxSamplesManipulatorFunctor(uint32_t n) :
n_(n)
{
}
template<typename S>
void operator()(S& s)
{
s.max_samples(n_);
}
private:
uint32_t n_;
};
class ContentFilterManipulatorFunctor
{
public:
ContentFilterManipulatorFunctor(const dds::sub::Query& q) :
query_(q)
{
}
template<typename S>
void operator()(S& s)
{
s.content(query_);
}
private:
const dds::sub::Query query_;
};
class StateFilterManipulatorFunctor
{
public:
StateFilterManipulatorFunctor(
const dds::sub::status::DataState& s) :
state_(s)
{
}
template<typename S>
void operator()(S& s)
{
s.state(state_);
}
private:
dds::sub::status::DataState state_;
};
class InstanceManipulatorFunctor
{
public:
InstanceManipulatorFunctor(const dds::core::InstanceHandle& h) :
handle_(h)
{
}
template<typename S>
void operator()(S& s)
{
s.instance(handle_);
}
private:
dds::core::InstanceHandle handle_;
};
class NextInstanceManipulatorFunctor
{
public:
NextInstanceManipulatorFunctor(
const dds::core::InstanceHandle& h) :
handle_(h)
{
}
template<typename S>
void operator()(S& s)
{
s.next_instance(handle_);
}
private:
dds::core::InstanceHandle handle_;
};
}
}
}
}
#endif /* CYCLONEDDS_DDS_SUB_DETAIL_MANIPULATOR_HPP_ */

View File

@@ -0,0 +1,32 @@
/*
* Copyright(c) 2006 to 2020 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef DDS_SUB_DETAIL_QUERY_HPP_
#define DDS_SUB_DETAIL_QUERY_HPP_
#include <dds/sub/TQuery.hpp>
#include <org/eclipse/cyclonedds/sub/QueryDelegate.hpp>
namespace dds
{
namespace sub
{
namespace detail
{
typedef dds::sub::TQuery<org::eclipse::cyclonedds::sub::QueryDelegate> Query;
}
}
}
#endif /* DDS_SUB_DETAIL_QUERY_HPP_ */

View File

@@ -0,0 +1,22 @@
/*
* Copyright(c) 2006 to 2020 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef OMG_DDS_SUB_DETAIL_RANK_HPP
#define OMG_DDS_SUB_DETAIL_RANK_HPP
#include <dds/sub/detail/TRankImpl.hpp>
#include <org/eclipse/cyclonedds/sub/RankImpl.hpp>
namespace dds { namespace sub { namespace detail {
typedef dds::sub::TRank< org::eclipse::cyclonedds::sub::RankImpl > Rank;
} } }
#endif /* OMG_DDS_SUB_DETAIL_RANK_HPP */

View File

@@ -0,0 +1,123 @@
#ifndef OMG_DDS_PUB_DETAIL_SAMPLE_HPP_
#define OMG_DDS_PUB_DETAIL_SAMPLE_HPP_
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace dds
{
namespace sub
{
namespace detail
{
template <typename T>
class Sample;
}}}
#include <dds/sub/SampleInfo.hpp>
//#include <dds/sub/detail/TSampleImpl.hpp>
namespace dds
{
namespace sub
{
namespace detail
{
template <typename T>
class Sample
{
public:
Sample() { }
Sample(const T& d, const dds::sub::SampleInfo& i)
{
this->data_ = d;
this->info_ = i;
}
Sample(const Sample& other)
{
copy(other);
}
Sample& operator=(const Sample& other)
{
return copy(other);
}
Sample& copy(const Sample& other)
{
this->data_ = other.data_;
this->info_ = other.info_;
return *this;
}
public:
const T& data() const
{
return data_;
}
T& data()
{
return data_;
}
void data(const T& d)
{
data_ = d;
}
const dds::sub::SampleInfo& info() const
{
return info_;
}
dds::sub::SampleInfo& info()
{
return info_;
}
void info(const dds::sub::SampleInfo& i)
{
info_ = i;
}
bool operator ==(const Sample& other) const
{
(void)other;
return false;
}
T* data_ptr()
{
return &this->data_;
}
private:
T data_;
dds::sub::SampleInfo info_;
};
}
}
}
#endif /* OMG_DDS_PUB_DETAIL_SAMPLE_HPP_ */

View File

@@ -0,0 +1,22 @@
/*
* Copyright(c) 2006 to 2020 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef OMG_DDS_SUB_DETAIL_SAMPLE_INFO_HPP_
#define OMG_DDS_SUB_DETAIL_SAMPLE_INFO_HPP_
#include <dds/sub/detail/TSampleInfoImpl.hpp>
#include <org/eclipse/cyclonedds/sub/SampleInfoImpl.hpp>
namespace dds { namespace sub { namespace detail {
typedef dds::sub::TSampleInfo<org::eclipse::cyclonedds::sub::SampleInfoImpl> SampleInfo;
} } }
#endif /* OMG_DDS_SUB_DETAIL_SAMPLE_INFO_HPP_ */

View File

@@ -0,0 +1,130 @@
#ifndef OMG_DDS_PUB_DETAIL_SAMPLEREF_HPP_
#define OMG_DDS_PUB_DETAIL_SAMPLEREF_HPP_
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace dds
{
namespace sub
{
namespace detail
{
template <typename T>
class SampleRef;
}}}
#include <dds/sub/SampleInfo.hpp>
#include <org/eclipse/cyclonedds/topic/datatopic.hpp>
namespace dds
{
namespace sub
{
namespace detail
{
template <typename T>
class SampleRef
{
public:
SampleRef()
{
this->data_ = nullptr;
}
SampleRef(ddscxx_serdata<T>* d, const dds::sub::SampleInfo& i)
{
this->data_ = d;
this->info_ = i;
}
SampleRef(const SampleRef& other)
{
copy(other);
}
virtual ~SampleRef()
{
if (data_ != nullptr) {
ddsi_serdata_unref(reinterpret_cast<ddsi_serdata *>(data_));
}
}
SampleRef& operator=(const SampleRef& other)
{
if (this != &other)
{
copy(other);
}
return *this;
}
public:
const T& data() const
{
if (data_ == nullptr)
{
throw dds::core::Error("Data is Null");
}
return *data_->getT();
}
const dds::sub::SampleInfo& info() const
{
return info_;
}
dds::sub::SampleInfo& info()
{
return info_;
}
bool operator ==(const SampleRef& other) const
{
(void)other;
return false;
}
ddscxx_serdata<T>* &data_ptr()
{
return this->data_;
}
private:
void copy(const SampleRef& other)
{
if (other.data_ == nullptr)
{
throw dds::core::Error("Other data is Null");
}
static_cast<void>(ddsi_serdata_ref(reinterpret_cast<ddsi_serdata* const>(other.data_)));
this->data_ = other.data_;
this->info_ = other.info_;
}
ddscxx_serdata<T>* data_;
dds::sub::SampleInfo info_;
};
}
}
}
#endif /* OMG_DDS_PUB_DETAIL_SAMPLEREF_HPP_ */

View File

@@ -0,0 +1,373 @@
/*
* Copyright(c) 2006 to 2021 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef CYCLONEDDS_DDS_SUB_DETAIL_SAMPLES_HOLDER_HPP_
#define CYCLONEDDS_DDS_SUB_DETAIL_SAMPLES_HOLDER_HPP_
/**
* @file
*/
#include <dds/sub/LoanedSamples.hpp>
#include "org/eclipse/cyclonedds/sub/AnyDataReaderDelegate.hpp"
#include "org/eclipse/cyclonedds/topic/datatopic.hpp"
namespace dds
{
namespace sub
{
namespace detail
{
template <typename T>
class LoanedSamplesHolder : public SamplesHolder
{
public:
LoanedSamplesHolder(dds::sub::LoanedSamples<T>& samples) : samples_(samples), index_(0)
{
}
void set_length(uint32_t len) {
this->samples_.delegate()->resize(len);
}
uint32_t get_length() const {
return this->index_;
}
SamplesHolder& operator++(int)
{
this->index_++;
return *this;
}
void *data()
{
return (*this->samples_.delegate())[this->index_].delegate().data_ptr();
}
detail::SampleInfo& info()
{
return (*this->samples_.delegate())[this->index_].delegate().info();
}
void **cpp_sample_pointers(size_t length)
{
return new void * [length];
}
dds_sample_info_t *cpp_info_pointers(size_t length)
{
return new dds_sample_info_t[length];
}
void set_sample_contents(void** c_sample_pointers, dds_sample_info_t *info)
{
uint32_t cpp_sample_size = this->samples_.delegate()->length();
auto tmp_iterator = samples_.delegate()->mbegin();
for (uint32_t i = 0; i < cpp_sample_size; ++i, ++tmp_iterator) {
/* Transfer ownership for ddscxx_serdata from c_sample_pointers to SampleRef objects. */
tmp_iterator->delegate().data_ptr() = static_cast<ddscxx_serdata<T>*>(c_sample_pointers[i]);
org::eclipse::cyclonedds::sub::AnyDataReaderDelegate::copy_sample_infos(info[i], tmp_iterator->delegate().info());
}
}
void fini_samples_buffers(void**& c_sample_pointers, dds_sample_info_t*& c_sample_infos)
{
delete [] c_sample_pointers;
delete [] c_sample_infos;
}
private:
dds::sub::LoanedSamples<T>& samples_;
uint32_t index_;
};
class CDRSamplesHolder : public SamplesHolder
{
public:
CDRSamplesHolder(dds::sub::LoanedSamples<org::eclipse::cyclonedds::topic::CDRBlob>& samples) : samples_(samples), index_(0)
{
}
void set_length(uint32_t len) {
this->samples_.delegate()->resize(len);
}
uint32_t get_length() const {
return this->index_;
}
SamplesHolder& operator++(int)
{
this->index_++;
return *this;
}
void *data()
{
return (*this->samples_.delegate())[this->index_].delegate().data_ptr();
}
detail::SampleInfo& info()
{
return (*this->samples_.delegate())[this->index_].delegate().info();
}
void **cpp_sample_pointers(size_t length)
{
return new void * [length];
}
dds_sample_info_t *cpp_info_pointers(size_t length)
{
return new dds_sample_info_t[length];
}
void set_sample_contents(void** c_sample_pointers, dds_sample_info_t *info)
{
struct ddsi_serdata **cdr_blobs = reinterpret_cast<struct ddsi_serdata **>(c_sample_pointers);
const uint32_t cpp_sample_size = this->samples_.delegate()->length();
for (uint32_t i = 0; i < cpp_sample_size; ++i)
{
struct ddsi_serdata * current_blob = cdr_blobs[i];
org::eclipse::cyclonedds::topic::CDRBlob &sample_data = (*this->samples_.delegate())[i].delegate().data();
// update the data kind
sample_data.kind(static_cast<org::eclipse::cyclonedds::topic::BlobKind>(current_blob->kind));
// if data is transferred using SHM, update the CDRBlob with iox_chunk
if(!update_cdrblob_from_iox_chunk(*current_blob, sample_data)) {
ddsrt_iovec_t blob_content;
ddsi_serdata_to_ser_ref(current_blob, 0, ddsi_serdata_size(current_blob), &blob_content);
copy_buffer_to_cdr_blob(reinterpret_cast<uint8_t *>(blob_content.iov_base),
blob_content.iov_len, sample_data.kind(), sample_data);
ddsi_serdata_to_ser_unref(current_blob, &blob_content);
ddsi_serdata_unref(current_blob);
}
// copy sample infos
org::eclipse::cyclonedds::sub::AnyDataReaderDelegate::copy_sample_infos(info[i], (*samples_.delegate())[i].delegate().info());
}
}
void fini_samples_buffers(void**& c_sample_pointers, dds_sample_info_t*& c_sample_infos)
{
delete [] c_sample_pointers;
delete [] c_sample_infos;
}
private:
dds::sub::LoanedSamples<org::eclipse::cyclonedds::topic::CDRBlob>& samples_;
uint32_t index_;
void copy_buffer_to_cdr_blob(const uint8_t * buffer, const size_t size,
const org::eclipse::cyclonedds::topic::BlobKind data_kind,
org::eclipse::cyclonedds::topic::CDRBlob & cdr_blob) const
{
// update the CDR header
memcpy(cdr_blob.encoding().data(), buffer, CDR_HEADER_SIZE);
// if the data kind is not empty
if (data_kind != org::eclipse::cyclonedds::topic::BlobKind::Empty) {
// get the actual data from the buffer
cdr_blob.payload().assign(buffer + CDR_HEADER_SIZE, buffer + size);
}
}
bool update_cdrblob_from_iox_chunk (ddsi_serdata & current_blob,
org::eclipse::cyclonedds::topic::CDRBlob &sample_data) {
#ifdef DDSCXX_HAS_SHM
// if the data is available on SHM
if (current_blob.iox_chunk && current_blob.iox_subscriber) {
// get the user iox header
auto iox_header = iceoryx_header_from_chunk(current_blob.iox_chunk);
// if the iox chunk has the data in serialized form
if (iox_header->shm_data_state == IOX_CHUNK_CONTAINS_SERIALIZED_DATA) {
copy_buffer_to_cdr_blob(reinterpret_cast<uint8_t *>(current_blob.iox_chunk),
iox_header->data_size, sample_data.kind(), sample_data);
} else if (iox_header->shm_data_state == IOX_CHUNK_CONTAINS_RAW_DATA) {
// serialize the data
auto serialized_size = ddsi_sertype_get_serialized_size(current_blob.type,
current_blob.iox_chunk);
// create a buffer to serialize
std::vector<uint8_t> buffer(serialized_size);
// serialize into the buffer
ddsi_sertype_serialize_into(current_blob.type, current_blob.iox_chunk, buffer.data(),
serialized_size);
// update the CDR blob with the serialized data
copy_buffer_to_cdr_blob(buffer.data(), serialized_size, sample_data.kind(), sample_data);
} else {
// this shouldn't never happen
ISOCPP_THROW_EXCEPTION(ISOCPP_PRECONDITION_NOT_MET_ERROR,
"The received sample over SHM is not initialized");
}
// release the chunk
free_iox_chunk(static_cast<iox_sub_t *>(current_blob.iox_subscriber), &current_blob.iox_chunk);
return true;
} else {
return false;
}
#else
(void) current_blob;
(void) sample_data;
return false;
#endif // DDSCXX_HAS_SHM
}
};
template <typename T, typename SamplesFWIterator>
class SamplesFWInteratorHolder : public SamplesHolder
{
public:
SamplesFWInteratorHolder(SamplesFWIterator& it) : iterator(it), size(0)
{
}
void set_length(uint32_t len) {
this->size = len;
}
uint32_t get_length() const {
return this->size;
}
SamplesHolder& operator++(int)
{
++this->iterator;
return *this;
}
void *data()
{
return (*iterator).delegate().data_ptr();
}
detail::SampleInfo& info()
{
return (*iterator).delegate().info();
}
void **cpp_sample_pointers(size_t length)
{
void **c_sample_pointers = new void * [length];
SamplesFWIterator tmp_iterator = iterator;
for (uint32_t i = 0; i < length; ++i, ++tmp_iterator) {
c_sample_pointers[i] = (*tmp_iterator).delegate().data_ptr();
}
return c_sample_pointers;
}
dds_sample_info_t *cpp_info_pointers(size_t length)
{
return new dds_sample_info_t[length];
}
void set_sample_contents(void**, dds_sample_info_t *info)
{
/* Samples have already been deserialized in their containers during the read/take call. */
SamplesFWIterator tmp_iterator = iterator;
for (uint32_t i = 0; i < size; ++i, ++tmp_iterator) {
org::eclipse::cyclonedds::sub::AnyDataReaderDelegate::copy_sample_infos(info[i], tmp_iterator->delegate().info());
}
}
void fini_samples_buffers(void**& c_sample_pointers, dds_sample_info_t*& c_sample_infos)
{
delete [] c_sample_infos;
delete [] c_sample_pointers;
}
private:
SamplesFWIterator& iterator;
uint32_t size;
};
template <typename T, typename SamplesBIIterator>
class SamplesBIIteratorHolder : public SamplesHolder
{
public:
SamplesBIIteratorHolder(SamplesBIIterator& it) : iterator(it), size(0)
{
}
void set_length(uint32_t len) {
this->size = len;
samples.resize(len);
}
uint32_t get_length() const {
return this->size;
}
SamplesHolder& operator++(int)
{
++this->iterator;
return *this;
}
void *data()
{
return this->samples[0].delegate().data_ptr();
}
detail::SampleInfo& info()
{
return this->samples[0].delegate().info();
}
void **cpp_sample_pointers(size_t length)
{
set_length(static_cast<uint32_t>(length));
void **c_sample_pointers = new void*[length];
for (uint32_t i = 0; i < length; ++i) {
c_sample_pointers[i] = samples[i].delegate().data_ptr();
}
return c_sample_pointers;
}
dds_sample_info_t *cpp_info_pointers(size_t length)
{
dds_sample_info_t *c_info_pointers = new dds_sample_info_t[length];
return c_info_pointers;
}
void set_sample_contents(void**, dds_sample_info_t *info)
{
/* Samples have already been deserialized in their containers during the read/take call. */
for (uint32_t i = 0; i < size; ++i) {
org::eclipse::cyclonedds::sub::AnyDataReaderDelegate::copy_sample_infos(info[i], samples[i].delegate().info());
this->iterator = std::move(samples[i]);
this->iterator++;
}
}
void fini_samples_buffers(void**& c_sample_pointers, dds_sample_info_t*& c_sample_infos)
{
delete [] c_sample_infos;
delete [] c_sample_pointers;
}
private:
SamplesBIIterator& iterator;
std::vector< dds::sub::Sample<T, dds::sub::detail::Sample> > samples;
uint32_t size;
};
}
}
}
#endif /* CYCLONEDDS_DDS_SUB_DETAIL_SAMPLES_HOLDER_HPP_ */

View File

@@ -0,0 +1,86 @@
/*
* Copyright(c) 2006 to 2020 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef CYCLONEDDS_DDS_SUB_DETAIL_SHARED_SAMPLES_HPP_
#define CYCLONEDDS_DDS_SUB_DETAIL_SHARED_SAMPLES_HPP_
/**
* @file
*/
#include <dds/sub/LoanedSamples.hpp>
// Implementation
namespace dds
{
namespace sub
{
namespace detail
{
template <typename T>
class SharedSamples
{
public:
typedef typename std::vector< dds::sub::Sample<T, Sample> >::iterator iterator;
typedef typename std::vector< dds::sub::Sample<T, Sample> >::const_iterator const_iterator;
public:
SharedSamples() { }
SharedSamples(dds::sub::LoanedSamples<T> ls) : samples_(ls) { }
~SharedSamples()
{
}
public:
iterator mbegin()
{
return samples_->begin();
}
const_iterator begin() const
{
return samples_.begin();
}
const_iterator end() const
{
return samples_.end();
}
uint32_t length() const
{
/** @internal @todo Possible RTF size issue ? */
return static_cast<uint32_t>(samples_.length());
}
void resize(uint32_t s)
{
samples_.resize(s);
}
private:
dds::sub::LoanedSamples<T> samples_;
};
}
}
}
// End of implementation
#endif /* CYCLONEDDS_DDS_SUB_DETAIL_SHARED_SAMPLES_HPP_ */

View File

@@ -0,0 +1,80 @@
/*
* Copyright(c) 2006 to 2020 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef CYCLONEDDS_DDS_SUB_SHARED_SAMPLES_IMPL_HPP_
#define CYCLONEDDS_DDS_SUB_SHARED_SAMPLES_IMPL_HPP_
/**
* @file
*/
/*
* OMG PSM class declaration
*/
// Implementation
namespace dds
{
namespace sub
{
template <typename T, template <typename Q> class DELEGATE>
SharedSamples<T, DELEGATE>::SharedSamples() : delegate_(new DELEGATE<T>()) { }
template <typename T, template <typename Q> class DELEGATE>
SharedSamples<T, DELEGATE>::SharedSamples(dds::sub::LoanedSamples<T> ls) : delegate_(new DELEGATE<T>(ls)) { }
template <typename T, template <typename Q> class DELEGATE>
SharedSamples<T, DELEGATE>::~SharedSamples() { }
template <typename T, template <typename Q> class DELEGATE>
SharedSamples<T, DELEGATE>::SharedSamples(const SharedSamples& other)
{
delegate_ = other.delegate_;
}
template <typename T, template <typename Q> class DELEGATE>
typename SharedSamples<T, DELEGATE>::const_iterator SharedSamples<T, DELEGATE>::begin() const
{
return delegate()->begin();
}
template <typename T, template <typename Q> class DELEGATE>
typename SharedSamples<T, DELEGATE>::const_iterator SharedSamples<T, DELEGATE>::end() const
{
return delegate()->end();
}
template <typename T, template <typename Q> class DELEGATE>
const typename SharedSamples<T, DELEGATE>::DELEGATE_REF_T& SharedSamples<T, DELEGATE>::delegate() const
{
return delegate_;
}
template <typename T, template <typename Q> class DELEGATE>
typename SharedSamples<T, DELEGATE>::DELEGATE_REF_T& SharedSamples<T, DELEGATE>::delegate()
{
return delegate_;
}
template <typename T, template <typename Q> class DELEGATE>
uint32_t SharedSamples<T, DELEGATE>::length() const
{
return delegate_->length();
}
}
}
// End of implementation
#endif /* CYCLONEDDS_DDS_SUB_SHARED_SAMPLES_IMPL_HPP_ */

View File

@@ -0,0 +1,29 @@
#ifndef OMG_DDS_SUB_DETAIL_SUBSCRIBER_HPP_
#define OMG_DDS_SUB_DETAIL_SUBSCRIBER_HPP_
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <dds/sub/detail/TSubscriberImpl.hpp>
#include <org/eclipse/cyclonedds/sub/SubscriberDelegate.hpp>
namespace dds { namespace sub { namespace detail {
typedef dds::sub::TSubscriber<org::eclipse::cyclonedds::sub::SubscriberDelegate> Subscriber;
} } }
#endif /* OMG_DDS_SUB_DETAIL_SUBSCRIBER_HPP_ */

View File

@@ -0,0 +1,132 @@
/*
* Copyright(c) 2006 to 2021 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef OMG_DDS_SUB_DETAIL_TANYDATAREADER_HPP_
#define OMG_DDS_SUB_DETAIL_TANYDATAREADER_HPP_
/**
* @file
*/
/*
* OMG PSM class declaration
*/
#include <dds/sub/TAnyDataReader.hpp>
#include <dds/topic/TopicDescription.hpp>
// Implementation
namespace dds
{
namespace sub
{
template <typename DELEGATE>
const dds::sub::Subscriber&
TAnyDataReader<DELEGATE>::subscriber() const
{
return this->delegate()->subscriber();
}
template <typename DELEGATE>
const dds::topic::TopicDescription&
TAnyDataReader<DELEGATE>::topic_description() const
{
return this->delegate()->topic_description();
}
template <typename DELEGATE>
void
TAnyDataReader<DELEGATE>::wait_for_historical_data(const dds::core::Duration& timeout)
{
this->delegate()->wait_for_historical_data(timeout);
}
template <typename DELEGATE>
dds::sub::qos::DataReaderQos
TAnyDataReader<DELEGATE>::qos() const
{
return this->delegate()->qos();
}
template <typename DELEGATE>
void
TAnyDataReader<DELEGATE>::qos(const dds::sub::qos::DataReaderQos& qos)
{
this->delegate()->qos(qos);
}
template <typename DELEGATE>
TAnyDataReader<DELEGATE>&
TAnyDataReader<DELEGATE>::operator << (const dds::sub::qos::DataReaderQos& qos)
{
this->delegate()->qos(qos);
return *this;
}
template <typename DELEGATE>
const TAnyDataReader<DELEGATE>&
TAnyDataReader<DELEGATE>::operator >> (dds::sub::qos::DataReaderQos& qos) const
{
qos = this->delegate()->qos();
return *this;
}
template <typename DELEGATE>
dds::core::status::LivelinessChangedStatus
TAnyDataReader<DELEGATE>::liveliness_changed_status()
{
return this->delegate()->liveliness_changed_status();
}
template <typename DELEGATE>
dds::core::status::SampleRejectedStatus
TAnyDataReader<DELEGATE>::sample_rejected_status()
{
return this->delegate()->sample_rejected_status();
}
template <typename DELEGATE>
dds::core::status::SampleLostStatus
TAnyDataReader<DELEGATE>::sample_lost_status()
{
return this->delegate()->sample_lost_status();
}
template <typename DELEGATE>
dds::core::status::RequestedDeadlineMissedStatus
TAnyDataReader<DELEGATE>::requested_deadline_missed_status()
{
return this->delegate()->requested_deadline_missed_status();
}
template <typename DELEGATE>
dds::core::status::RequestedIncompatibleQosStatus
TAnyDataReader<DELEGATE>::requested_incompatible_qos_status()
{
return this->delegate()->requested_incompatible_qos_status();
}
template <typename DELEGATE>
dds::core::status::SubscriptionMatchedStatus
TAnyDataReader<DELEGATE>::subscription_matched_status()
{
return this->delegate()->subscription_matched_status();
}
}
}
// End of implementation
#endif /* OMG_DDS_SUB_DETAIL_TANYDATAREADER_HPP_ */

View File

@@ -0,0 +1,51 @@
/*
* Copyright(c) 2006 to 2020 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef CYCLONEDDS_DDS_SUB_TCOHERENTACCESS_IMPL_HPP_
#define CYCLONEDDS_DDS_SUB_TCOHERENTACCESS_IMPL_HPP_
/**
* @file
*/
/*
* OMG PSM class declaration
*/
#include <dds/sub/TCoherentAccess.hpp>
// Implementation
namespace dds
{
namespace sub
{
template <typename DELEGATE>
TCoherentAccess<DELEGATE>::TCoherentAccess(const dds::sub::Subscriber& sub) : dds::core::Value<DELEGATE>(sub) { }
template <typename DELEGATE>
void TCoherentAccess<DELEGATE>::end()
{
this->delegate().end();
}
template <typename DELEGATE>
TCoherentAccess<DELEGATE>::~TCoherentAccess()
{
this->delegate().end();
}
}
}
// End of implementation
#endif /* CYCLONEDDS_DDS_SUB_TCOHERENTACCESS_IMPL_HPP_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,55 @@
/*
* Copyright(c) 2006 to 2020 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef CYCLONEDDS_DDS_SUB_DETAIL_TGENERATIONCOUNT_IMPL_HPP_
#define CYCLONEDDS_DDS_SUB_DETAIL_TGENERATIONCOUNT_IMPL_HPP_
/**
* @file
*/
/*
* OMG PSM class declaration
*/
#include <dds/sub/TGenerationCount.hpp>
// Implementation
namespace dds
{
namespace sub
{
template <typename DELEGATE>
TGenerationCount<DELEGATE>::TGenerationCount() { }
template <typename DELEGATE>
TGenerationCount<DELEGATE>::TGenerationCount(int32_t dgc, int32_t nwgc)
: dds::core::Value<DELEGATE>(dgc, nwgc) { }
template <typename DELEGATE>
int32_t TGenerationCount<DELEGATE>::disposed() const
{
return this->delegate().disposed();
}
template <typename DELEGATE>
inline int32_t TGenerationCount<DELEGATE>::no_writers() const
{
return this->delegate().no_writers();
}
}
}
// End of implementation
#endif /* CYCLONEDDS_DDS_SUB_DETAIL_TGENERATIONCOUNT_IMPL_HPP_ */

View File

@@ -0,0 +1,136 @@
/*
* Copyright(c) 2006 to 2020 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef CYCLONEDDS_DDS_SUB_DETAIL_QUERY_IMPL_HPP_
#define CYCLONEDDS_DDS_SUB_DETAIL_QUERY_IMPL_HPP_
/**
* @file
*/
// Implementation
#include <dds/sub/TQuery.hpp>
template <typename DELEGATE>
dds::sub::TQuery<DELEGATE>::TQuery(
const dds::sub::AnyDataReader& dr,
const std::string& expression) :
dds::core::Reference<DELEGATE>(new DELEGATE(AnyDataReader(dr), expression))
{
}
template <typename DELEGATE>
template<typename FWIterator>
dds::sub::TQuery<DELEGATE>::TQuery(
const dds::sub::AnyDataReader& dr,
const std::string& expression,
const FWIterator& params_begin,
const FWIterator& params_end) :
dds::core::Reference<DELEGATE>(new DELEGATE(AnyDataReader(dr), expression))
{
for (FWIterator it = params_begin; it != params_end; ++it) {
add_parameter(*it);
}
}
template <typename DELEGATE>
dds::sub::TQuery<DELEGATE>::TQuery(
const dds::sub::AnyDataReader& dr,
const std::string& expression,
const std::vector<std::string>& params) :
dds::core::Reference<DELEGATE>(new DELEGATE(AnyDataReader(dr), expression, params))
{
}
template <typename DELEGATE>
const std::string& dds::sub::TQuery<DELEGATE>::expression() const
{
return this->delegate()->expression();
}
template <typename DELEGATE>
void dds::sub::TQuery<DELEGATE>::expression(const std::string& expr)
{
this->delegate()->expression(expr);
}
/**
* Provides the begin iterator to the parameter list.
*/
template <typename DELEGATE>
typename dds::sub::TQuery<DELEGATE>::const_iterator dds::sub::TQuery<DELEGATE>::begin() const
{
return this->delegate()->begin();
}
/**
* The end iterator to the parameter list.
*/
template <typename DELEGATE>
typename dds::sub::TQuery<DELEGATE>::const_iterator dds::sub::TQuery<DELEGATE>::end() const
{
return this->delegate()->end();
}
/**
* Provides the begin iterator to the parameter list.
*/
template <typename DELEGATE>
typename dds::sub::TQuery<DELEGATE>::iterator dds::sub::TQuery<DELEGATE>::begin()
{
return this->delegate()->begin();
}
/**
* The end iterator to the parameter list.
*/
template <typename DELEGATE>
typename dds::sub::TQuery<DELEGATE>::iterator dds::sub::TQuery<DELEGATE>::end()
{
return this->delegate()->end();
}
template <typename DELEGATE>
template<typename FWIterator>
void dds::sub::TQuery<DELEGATE>::parameters(
const FWIterator& begin,
const FWIterator end)
{
for (FWIterator it = begin; it != end; ++it) {
add_parameter(*it);
}
}
template <typename DELEGATE>
void dds::sub::TQuery<DELEGATE>::add_parameter(
const std::string& param)
{
this->delegate()->add_parameter(param);
}
template <typename DELEGATE>
uint32_t dds::sub::TQuery<DELEGATE>::parameters_length() const
{
return this->delegate()->parameters_length();
}
template <typename DELEGATE>
const dds::sub::AnyDataReader&
dds::sub::TQuery<DELEGATE>::data_reader() const
{
return this->delegate()->data_reader();
}
#endif /* CYCLONEDDS_DDS_SUB_DETAIL_QUERY_IMPL_HPP_ */

View File

@@ -0,0 +1,59 @@
/*
* Copyright(c) 2006 to 2020 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef CYCLONEDDS_DDS_SUB_DETAIL_TRANK_IMPL_HPP_
#define CYCLONEDDS_DDS_SUB_DETAIL_TRANK_IMPL_HPP_
/**
* @file
*/
/*
* OMG PSM class declaration
*/
#include <dds/sub/TRank.hpp>
// Implementation
namespace dds
{
namespace sub
{
template <typename DELEGATE>
TRank<DELEGATE>::TRank() { }
template <typename DELEGATE>
TRank<DELEGATE>::TRank(int32_t s, int32_t a, int32_t ag)
: dds::core::Value<DELEGATE>(s, a, ag) { }
template <typename DELEGATE>
int32_t TRank<DELEGATE>::absolute_generation() const
{
return this->delegate().absolute_generation();
}
template <typename DELEGATE>
inline int32_t TRank<DELEGATE>::generation() const
{
return this->delegate().generation();
}
template <typename DELEGATE>
inline int32_t TRank<DELEGATE>::sample() const
{
return this->delegate().sample();
}
}
}
// End of implementation
#endif /* CYCLONEDDS_DDS_SUB_DETAIL_TRANK_IMPL_HPP_ */

View File

@@ -0,0 +1,66 @@
/*
* Copyright(c) 2006 to 2020 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef CYCLONEDDS_DDS_SUB_TSAMPLE_HPP_
#define CYCLONEDDS_DDS_SUB_TSAMPLE_HPP_
/**
* @file
*/
/*
* OMG PSM class declaration
*/
#include <dds/sub/TSample.hpp>
// Implementation
namespace dds
{
namespace sub
{
template <typename T, template <typename Q> class DELEGATE>
Sample<T, DELEGATE>::Sample() : dds::core::Value< DELEGATE<T> >() {}
template <typename T, template <typename Q> class DELEGATE>
Sample<T, DELEGATE>::Sample(const T& data, const SampleInfo& info) : dds::core::Value< DELEGATE<T> >(data, info) { }
template <typename T, template <typename Q> class DELEGATE>
Sample<T, DELEGATE>::Sample(const Sample& other) : dds::core::Value< DELEGATE<T> >(other.delegate()) { }
template <typename T, template <typename Q> class DELEGATE>
const typename Sample<T, DELEGATE>::DataType& Sample<T, DELEGATE>::data() const
{
return this->delegate().data();
}
template <typename T, template <typename Q> class DELEGATE>
void Sample<T, DELEGATE>::data(const DataType& d)
{
this->delegate().data(d);
}
template <typename T, template <typename Q> class DELEGATE>
const SampleInfo& Sample<T, DELEGATE>::info() const
{
return this->delegate().info();
}
template <typename T, template <typename Q> class DELEGATE>
void Sample<T, DELEGATE>::info(const SampleInfo& i)
{
this->delegate().info(i);
}
}
}
// End of implementation
#endif /* CYCLONEDDS_DDS_SUB_TSAMPLE_HPP_ */

View File

@@ -0,0 +1,78 @@
/*
* Copyright(c) 2006 to 2020 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef CYCLONEDDS_DDS_SUB_DETAIL_TSAMPLEINFO_IMPL_HPP_
#define CYCLONEDDS_DDS_SUB_DETAIL_TSAMPLEINFO_IMPL_HPP_
/**
* @file
*/
/*
* OMG PSM class declaration
*/
#include <dds/sub/TSampleInfo.hpp>
// Implementation
namespace dds
{
namespace sub
{
template <typename DELEGATE>
TSampleInfo<DELEGATE>::TSampleInfo() { }
template <typename DELEGATE>
const dds::core::Time TSampleInfo<DELEGATE>::timestamp() const
{
return this->delegate().timestamp();
}
template <typename DELEGATE>
const dds::sub::status::DataState TSampleInfo<DELEGATE>::state() const
{
return this->delegate().state();
}
template <typename DELEGATE>
dds::sub::GenerationCount TSampleInfo<DELEGATE>::generation_count() const
{
return this->delegate().generation_count();
}
template <typename DELEGATE>
dds::sub::Rank TSampleInfo<DELEGATE>::rank() const
{
return this->delegate().rank();
}
template <typename DELEGATE>
bool TSampleInfo<DELEGATE>::valid() const
{
return this->delegate().valid();
}
template <typename DELEGATE>
dds::core::InstanceHandle TSampleInfo<DELEGATE>::instance_handle() const
{
return this->delegate().instance_handle();
}
template <typename DELEGATE>
dds::core::InstanceHandle TSampleInfo<DELEGATE>::publication_handle() const
{
return this->delegate().publication_handle();
}
}
}
// End of implementation
#endif /* CYCLONEDDS_DDS_SUB_DETAIL_TSAMPLEINFO_IMPL_HPP_ */

View File

@@ -0,0 +1,54 @@
/*
* Copyright(c) 2006 to 2021 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef CYCLONEDDS_DDS_SUB_TSAMPLEREF_HPP_
#define CYCLONEDDS_DDS_SUB_TSAMPLEREF_HPP_
/**
* @file
*/
/*
* OMG PSM class declaration
*/
#include <dds/sub/TSampleRef.hpp>
// Implementation
namespace dds
{
namespace sub
{
template <typename T, template <typename Q> class DELEGATE>
SampleRef<T, DELEGATE>::SampleRef() : dds::core::Value< DELEGATE<T> >() {}
template <typename T, template <typename Q> class DELEGATE>
SampleRef<T, DELEGATE>::SampleRef(const T& data, const SampleInfo& info) : dds::core::Value< DELEGATE<T> >(data, info) { }
template <typename T, template <typename Q> class DELEGATE>
SampleRef<T, DELEGATE>::SampleRef(const SampleRef& other) : dds::core::Value< DELEGATE<T> >(other.delegate()) { }
template <typename T, template <typename Q> class DELEGATE>
const typename SampleRef<T, DELEGATE>::DataType& SampleRef<T, DELEGATE>::data() const
{
return this->delegate().data();
}
template <typename T, template <typename Q> class DELEGATE>
const SampleInfo& SampleRef<T, DELEGATE>::info() const
{
return this->delegate().info();
}
}
}
// End of implementation
#endif /* CYCLONEDDS_DDS_SUB_TSAMPLEREF_HPP_ */

View File

@@ -0,0 +1,121 @@
/*
* Copyright(c) 2006 to 2021 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef CYCLONEDDS_DDS_SUB_TSUBSCRIBER_IMPL_HPP_
#define CYCLONEDDS_DDS_SUB_TSUBSCRIBER_IMPL_HPP_
/**
* @file
*/
/*
* OMG PSM class declaration
*/
#include <dds/sub/TSubscriber.hpp>
// Implementation
namespace dds
{
namespace sub
{
template <typename DELEGATE>
TSubscriber<DELEGATE>::TSubscriber(const ::dds::domain::DomainParticipant& dp)
: ::dds::core::Reference<DELEGATE>(new DELEGATE(dp,
dp.default_subscriber_qos(),
NULL,
dds::core::status::StatusMask::none()))
{
this->delegate()->init(this->impl_);
}
template <typename DELEGATE>
TSubscriber<DELEGATE>::TSubscriber(const ::dds::domain::DomainParticipant& dp,
const dds::sub::qos::SubscriberQos& qos,
dds::sub::SubscriberListener* listener,
const dds::core::status::StatusMask& mask)
: ::dds::core::Reference<DELEGATE>(new DELEGATE(dp, qos, listener, mask))
{
this->delegate()->init(this->impl_);
}
template <typename DELEGATE>
void TSubscriber<DELEGATE>::notify_datareaders()
{
this->delegate()->notify_datareaders();
}
template <typename DELEGATE>
void TSubscriber<DELEGATE>::listener(Listener* listener,
const dds::core::status::StatusMask& event_mask)
{
return this->delegate()->listener(listener, event_mask);
}
template <typename DELEGATE>
typename TSubscriber<DELEGATE>::Listener* TSubscriber<DELEGATE>::listener() const
{
return this->delegate()->listener();
}
template <typename DELEGATE>
const dds::sub::qos::SubscriberQos& TSubscriber<DELEGATE>::qos() const
{
return this->delegate()->qos();
}
template <typename DELEGATE>
void TSubscriber<DELEGATE>::qos(const dds::sub::qos::SubscriberQos& sqos)
{
this->delegate()->qos(sqos);
}
template <typename DELEGATE>
dds::sub::qos::DataReaderQos TSubscriber<DELEGATE>::default_datareader_qos() const
{
return this->delegate()->default_datareader_qos();
}
template <typename DELEGATE>
TSubscriber<DELEGATE>& TSubscriber<DELEGATE>::default_datareader_qos(
const dds::sub::qos::DataReaderQos& qos)
{
this->delegate()->default_datareader_qos(qos);
return *this;
}
template <typename DELEGATE>
const dds::domain::DomainParticipant& TSubscriber<DELEGATE>::participant() const
{
return this->delegate()->participant();
}
template <typename DELEGATE>
TSubscriber<DELEGATE>& TSubscriber<DELEGATE>::operator << (const dds::sub::qos::SubscriberQos& qos)
{
this->qos(qos);
return *this;
}
template <typename DELEGATE>
const TSubscriber<DELEGATE>& TSubscriber<DELEGATE>::operator >> (dds::sub::qos::SubscriberQos& qos) const
{
qos = this->qos();
return *this;
}
}
}
// End of implementation
#endif /* CYCLONEDDS_DDS_SUB_TSUBSCRIBER_IMPL_HPP_ */

View File

@@ -0,0 +1,21 @@
/*
* Copyright(c) 2006 to 2021 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef OMG_DDS_SUB_PACKAGE_DETAIL_INCLUDE_HPP_
#define OMG_DDS_SUB_PACKAGE_DETAIL_INCLUDE_HPP_
#include "dds/sub/detail/TDataReaderImpl.hpp"
#include "dds/sub/detail/TQueryImpl.hpp"
#include "dds/sub/detail/TSampleImpl.hpp"
#include "dds/sub/detail/TSampleRefImpl.hpp"
#include "dds/sub/cond/detail/TQueryConditionImpl.hpp"
#endif /* OMG_DDS_SUB_PACKAGE_DETAIL_INCLUDE_HPP_ */

View File

@@ -0,0 +1,62 @@
/*
* Copyright(c) 2006 to 2020 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
/**
* @file
*/
#ifndef CYCLONEDDS_DDS_SUB_DETAIL_DISCOVERY_HPP_
#define CYCLONEDDS_DDS_SUB_DETAIL_DISCOVERY_HPP_
#include <dds/sub/DataReader.hpp>
namespace dds
{
namespace sub
{
template <typename FwdIterator>
void ignore(const dds::domain::DomainParticipant& dp, FwdIterator begin, FwdIterator end)
{
(void)dp;
(void)begin;
(void)end;
ISOCPP_THROW_EXCEPTION(ISOCPP_UNSUPPORTED_ERROR, "Function not currently supported");
}
template <typename T>
::dds::core::InstanceHandleSeq
matched_publications(const dds::sub::DataReader<T>& dr)
{
return dr.delegate()->matched_publications();
}
template <typename T, typename FwdIterator>
uint32_t
matched_publications(const dds::sub::DataReader<T>& dr,
FwdIterator begin, uint32_t max_size)
{
return dr.delegate()->matched_publications(begin, max_size);
}
template <typename T>
const dds::topic::PublicationBuiltinTopicData
matched_publication_data(const dds::sub::DataReader<T>& dr,
const ::dds::core::InstanceHandle& h)
{
return dr.delegate()->matched_publication_data(h);
}
}
}
#endif /* CYCLONEDDS_DDS_SUB_DETAIL_DISCOVERY_HPP_ */

View File

@@ -0,0 +1,218 @@
/*
* Copyright(c) 2006 to 2020 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef CYCLONEDDS_DDS_SUB_DETAIL_FIND_HPP_
#define CYCLONEDDS_DDS_SUB_DETAIL_FIND_HPP_
/**
* @file
*/
// Implementation
#include <string>
#include <vector>
#include <dds/sub/DataReader.hpp>
#include <dds/sub/Subscriber.hpp>
#include <dds/sub/status/DataState.hpp>
#include <dds/topic/TopicDescription.hpp>
#include <org/eclipse/cyclonedds/sub/SubscriberDelegate.hpp>
#include <org/eclipse/cyclonedds/sub/BuiltinSubscriberDelegate.hpp>
#include <org/eclipse/cyclonedds/sub/AnyDataReaderDelegate.hpp>
namespace dds
{
namespace sub
{
namespace detail
{
/*********************************************************************
* To be able to properly copy found readers into the given iterators
* (which are related to typed DataReaders or AnyDataReaders), we have
* to specialize the find() template functions.
* But template functions specialization is not supported by C++. So,
* we have to use these helper classes to get the specialization.
*********************************************************************/
typedef std::vector<org::eclipse::cyclonedds::sub::AnyDataReaderDelegate::ref_type> base_readers_vector;
typedef std::vector<org::eclipse::cyclonedds::sub::AnyDataReaderDelegate::ref_type>::iterator base_readers_iterator;
/*
* Copy helper class for typed readers.
*/
template <typename READER, typename ITERATOR>
class ReadersCopySpecialization
{
public:
static
bool copy(base_readers_iterator base_iter, ITERATOR typed_iter) {
bool copied = false;
try {
/* Cast base reader to typed delegate: */
typename READER::DELEGATE_REF_T reader_typed =
::std::dynamic_pointer_cast<typename READER::DELEGATE_T>(*base_iter);
READER dr(reader_typed);
if(dr != dds::core::null)
{
*typed_iter = dr;
copied = true;
}
} catch (...) {
/* Ignore, because subscriber can have returned readers that are of
* different types. */
}
return copied;
}
};
/*
* Copy helper class for any readers.
*/
template <typename ITERATOR>
class ReadersCopySpecialization<dds::sub::AnyDataReader, ITERATOR>
{
public:
static
bool copy(base_readers_iterator base_iter, ITERATOR any_iter) {
*any_iter = (*base_iter)->wrapper_to_any();
return true;
}
};
/*
* Copy helper class for list of readers.
*/
template <typename READER, typename ITERATOR>
class ReadersCopy
{
public:
static
uint32_t copy(base_readers_vector base_readers,
ITERATOR begin,
uint32_t max_size)
{
uint32_t size = 0;
base_readers_iterator iter;
for (iter = base_readers.begin(); (size < max_size) && (iter != base_readers.end()); ++iter) {
if (ReadersCopySpecialization<READER, ITERATOR>::copy(iter, begin)) {
begin++;
size++;
}
}
return size;
}
static
uint32_t copy(base_readers_vector base_readers,
ITERATOR begin)
{
uint32_t size = 0;
base_readers_iterator iter;
for (iter = base_readers.begin(); iter != base_readers.end(); ++iter) {
if (ReadersCopySpecialization<READER, ITERATOR>::copy(iter, begin)) {
begin++;
size++;
}
}
return size;
}
};
} /* namespace detail */
template <typename READER, typename FwdIterator>
uint32_t
find(const dds::sub::Subscriber& sub,
const std::string &topic_name,
FwdIterator begin, uint32_t max_size)
{
uint32_t size = 0;
if (max_size > 0) {
detail::base_readers_vector base_readers;
base_readers = sub.delegate()->find_datareaders(topic_name);
size = detail::ReadersCopy<READER, FwdIterator>::copy(base_readers, begin, max_size);
}
return size;
}
template <typename READER, typename BinIterator>
uint32_t
find(const dds::sub::Subscriber& sub,
const std::string &topic_name,
BinIterator begin)
{
uint32_t size = 0;
detail::base_readers_vector base_readers;
base_readers = sub.delegate()->find_datareaders(topic_name);
size = detail::ReadersCopy<READER, BinIterator>::copy(base_readers, begin);
return size;
}
template <typename READER, typename T, typename FwdIterator>
uint32_t
find(const dds::sub::Subscriber& sub,
const dds::topic::TopicDescription& topic_description,
FwdIterator begin, uint32_t max_size)
{
return find<READER, FwdIterator>(sub, topic_description.name(), begin, max_size);
}
template <typename READER, typename T, typename BinIterator>
uint32_t
find(const dds::sub::Subscriber& sub,
const dds::topic::TopicDescription& topic_description,
BinIterator begin)
{
return find<READER, BinIterator>(sub, topic_description.name(), begin);
}
template <typename READER, typename FwdIterator>
uint32_t
find(const dds::sub::Subscriber& sub,
const dds::sub::status::DataState& rs,
FwdIterator begin, uint32_t max_size)
{
uint32_t size = 0;
if (max_size > 0) {
detail::base_readers_vector base_readers;
base_readers = sub.delegate()->get_datareaders(rs);
size = detail::ReadersCopy<READER, FwdIterator>::copy(base_readers, begin, max_size);
}
return size;
}
template <typename READER, typename BinIterator>
uint32_t
find(const dds::sub::Subscriber& sub,
const dds::sub::status::DataState& rs,
BinIterator begin)
{
uint32_t size = 0;
detail::base_readers_vector base_readers;
base_readers = sub.delegate()->get_datareaders(rs);
size = detail::ReadersCopy<READER, BinIterator>::copy(base_readers, begin);
return size;
}
}
}
#endif /* CYCLONEDDS_DDS_SUB_DETAIL_FIND_HPP_ */

View File

@@ -0,0 +1,186 @@
#ifndef OMG_DDS_SUB_DISCOVERY_HPP_
#define OMG_DDS_SUB_DISCOVERY_HPP_
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <dds/domain/DomainParticipant.hpp>
#include <dds/sub/DataReader.hpp>
#include <dds/topic/BuiltinTopic.hpp>
#include <dds/sub/detail/discovery.hpp>
namespace dds
{
namespace sub
{
/**
* Ignore subscriptions.
*
* <b><i>This operation is not yet implemented. It is scheduled for a future release.</i></b>
*
* @param dp the DomainParticipant for which the remote
* entity will be ignored
*
* @param handle the InstanceHandle of the remote entity that
* has to be ignored
*/
void OMG_DDS_API ignore(const dds::domain::DomainParticipant& dp,
const dds::core::InstanceHandle& handle);
/**
* Ignore subscriptions.
*
* <b><i>This operation is not yet implemented. It is scheduled for a future release.</i></b>
*
* @param dp the DomainParticipant for which the remote
* entity will be ignored
*
* @param begin the start of the range to be ignored
*
* @param end the end of the range to be ignored
*/
template <typename FwdIterator>
void ignore(const dds::domain::DomainParticipant& dp, FwdIterator begin, FwdIterator end);
//==========================================================================
//== Discovery Management
/**
* This operation retrieves the list of publications currently "associated" with the
* DataReader. That is, subscriptions that have a matching Topic and compatible
* QoS that the application has not indicated should be “ignored” by means of the
* ignore_publication operation on the DomainParticipant.
*
* The handles returned in the dds::core::InstanceHandleSeq are the ones that are
* used by the DDS implementation to locally identify the corresponding matched
* DataWriter entities. You can access more detailed information about a particular
* publication by passing its publication_handle to either the
* dds::sub::matched_publication_data operation or to the read with instance
* operation on the built-in reader for the “DCPSPublication” topic.
*
* See @ref DCPS_Builtin_Topics "Builtin Topics" for more information.
*
* @param dr the DataReader
* @return a sequence of handles
* @throws dds::core::Error
* An internal error has occurred.
* @throws dds::core::NullReferenceError
* The entity was not properly created and references to dds::core::null.
* @throws dds::core::AlreadyClosedError
* The entity has already been closed.
* @throws dds::core::NotEnabledError
* The DataReader has not yet been enabled.
* @throws dds::core::UnsupportedError
* OpenSplice is configured not to maintain the
* information about “associated” subscriptions.
* @throws dds::core::OutOfResourcesError
* The Data Distribution Service ran out of resources to
* complete this operation.
*/
template <typename T>
::dds::core::InstanceHandleSeq
matched_publications(const dds::sub::DataReader<T>& dr);
/**
* This operation retrieves the list of publications currently "associated" with the
* DataReader. That is, subscriptions that have a matching Topic and compatible
* QoS that the application has not indicated should be “ignored” by means of the
* ignore_publication operation on the DomainParticipant.
*
* The handles returned in the dds::core::InstanceHandleSeq are the ones that are
* used by the DDS implementation to locally identify the corresponding matched
* DataWriter entities. You can access more detailed information about a particular
* publication by passing its publication_handle to either the
* dds::sub::matched_publication_data operation or to the read with instance
* operation on the built-in reader for the “DCPSPublication” topic.
*
* See @ref DCPS_Builtin_Topics "Builtin Topics" for more information.
*
* @param dr the DataReader
* @param begin an iterator indicating the beginning of a sequence of
* instance handles in which to put the matched subscriptions
* @param max_size the maximum number of matched subscriptions to return
* @return the number of matched subscriptions returned
* @throws dds::core::Error
* An internal error has occurred.
* @throws dds::core::NullReferenceError
* The entity was not properly created and references to dds::core::null.
* @throws dds::core::AlreadyClosedError
* The entity has already been closed.
* @throws dds::core::NotEnabledError
* The DataReader has not yet been enabled.
* @throws dds::core::UnsupportedError
* OpenSplice is configured not to maintain the
* information about “associated” subscriptions.
* @throws dds::core::OutOfResourcesError
* The Data Distribution Service ran out of resources to
* complete this operation.
*/
template <typename T, typename FwdIterator>
uint32_t
matched_publications(const dds::sub::DataReader<T>& dr,
FwdIterator begin, uint32_t max_size);
/**
* This operation retrieves information on the specified publication that is currently
* “associated” with the DataReader. That is, a publication with a matching Topic
* and compatible QoS that the application has not indicated should be “ignored” by
* means of the ignore_publication operation on the DomainParticipant.
* The publication_handle must correspond to a publication currently associated
* with the DataReader, otherwise the operation will fail and throw
* InvalidArgumentError. The operation dds::sub::matched_publications can
* be used to find the publications that are currently matched with the DataReader.
*
* The operation may fail if the infrastructure does not locally maintain the
* connectivity information. This is the case when OpenSplice is configured not to
* maintain discovery information in the Networking Service. (See the description for
* the NetworkingService/Discovery/enabled property in the Deployment
* Manual for more information about this subject.) In such cases the operation will
* throw UnsupportedError.
*
* See also @ref DCPS_Builtin_Topics and @ref DCPS_Builtin_Topics_PublicationData.
*
* @param dr the DataReader
* @param h the InstanceHandle
* @return the PublicationBuiltinTopicData
* @throws dds::core::Error
* An internal error has occurred.
* @throws dds::core::NullReferenceError
* The entity was not properly created and references to dds::core::null.
* @throws dds::core::AlreadyClosedError
* The entity has already been closed.
* @throws dds::core::NotEnabledError
* The DataReader has not yet been enabled.
* @throws dds::core::UnsupportedError
* OpenSplice is configured not to maintain the
* information about “associated” subscriptions.
* @throws dds::core::InvalidArgumentError
* Publication not associated with the DataReader.
* @throws dds::core::OutOfResourcesError
* The Data Distribution Service ran out of resources to
* complete this operation.
*/
template <typename T>
const dds::topic::PublicationBuiltinTopicData
matched_publication_data(const dds::sub::DataReader<T>& dr,
const ::dds::core::InstanceHandle& h);
}
}
#endif /* OMG_DDS_SUB_DISCOVERY_HPP_ */

View File

@@ -0,0 +1,217 @@
#ifndef OMG_DDS_SUB_FIND_HPP_
#define OMG_DDS_SUB_FIND_HPP_
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <string>
#include <dds/sub/detail/find.hpp>
namespace dds
{
namespace sub
{
/**
* This operation returns the built-in Subscriber associated with the given
* given DomainParticipant.
*
* Each DomainParticipant contains several built-in
* Topic objects. The built-in Subscriber contains the corresponding DataReader
* objects to access them. All these DataReader objects belong to a single built-in
* Subscriber. Note that there is exactly one built-in Subscriber associated with
* each DomainParticipant.
*
* See @ref DCPS_Builtin_Topics "Builtin Topics" for more information.
*
* @param dp the domain participant
* @return the built-in Subscriber
*/
const dds::sub::Subscriber OMG_DDS_API
builtin_subscriber(const dds::domain::DomainParticipant& dp);
/**
* This function retrieves a previously-created DataReader
* belonging to the Subscriber that is attached to a Topic with a
* matching topic_name. If no such DataReader exists, the operation
* will return an empty container.
*
* The use of this
* operation on the built-in Subscriber allows access to the
* built-in DataReader entities for the built-in topics
* (see @ref DCPS_Builtin_Topics "Builtin Topics").
*
* @param sub the Subscriber for which to find a DataReader
* @param topic_name the topic name to find
* @param begin a forward iterator pointing to the start of a
* container in which to put the DataReaders
* @param max_size the number of DataReaders to return
* @return the total number of elements returned. Notice that
* at most max_size will be copied using the provided iterator
*
*/
template <typename READER, typename FwdIterator>
uint32_t
find(const dds::sub::Subscriber& sub,
const std::string &topic_name,
FwdIterator begin, uint32_t max_size);
/**
* This function retrieves a previously-created DataReader
* belonging to the Subscriber that is attached to a Topic with a
* matching topic_name. If no such DataReader exists, the operation
* will return an empty container.
*
* The use of this
* operation on the built-in Subscriber allows access to the
* built-in DataReader entities for the built-in topics
* (see @ref DCPS_Builtin_Topics "Builtin Topics").
*
* @param sub the Subscriber for which to find a DataReader
* @param topic_name the topic name to find
* @param begin a back inserting iterator pointing to the start of a
* container in which to put the DataReaders
* @return the total number of elements returned
*/
template <typename READER, typename BinIterator>
uint32_t
find(const dds::sub::Subscriber& sub,
const std::string &topic_name,
BinIterator begin);
/**
* This function retrieves a previously-created DataReader
* belonging to the Subscriber that is attached to a Topic with a
* matching topic_name. If no such DataReader exists, the operation
* will return an empty container.
*
* The use of this
* operation on the built-in Subscriber allows access to the
* built-in DataReader entities for the built-in topics
* (see @ref DCPS_Builtin_Topics "Builtin Topics").
*
* @param sub the Subscriber for which to find a DataReader
* @param topic_description the topic description to find
* @param begin a forward iterator pointing to the start of a
* container in which to put the DataReaders
* @param max_size the number of DataReaders to return
* @return the total number of elements returned. Notice that
* at most max_size will be copied using the provided iterator
*/
template <typename READER, typename T, typename FwdIterator>
uint32_t
find(const dds::sub::Subscriber& sub,
const dds::topic::TopicDescription& topic_description,
FwdIterator begin, uint32_t max_size);
/**
* This function retrieves a previously-created DataReader
* belonging to the Subscriber that is attached to a Topic with a
* matching topic_name. If no such DataReader exists, the operation
* will return an empty container.
*
* The use of this
* operation on the built-in Subscriber allows access to the
* built-in DataReader entities for the built-in topics
* (see @ref DCPS_Builtin_Topics "Builtin Topics").
*
* @param sub the Subscriber for which to find a DataReader
* @param topic_description the topic description to find
* @param begin a back inserting iterator pointing to the start of a
* container in which to put the DataReaders
* @return the total number of elements returned
*/
template <typename READER, typename T, typename BinIterator>
uint32_t
find(const dds::sub::Subscriber& sub,
const dds::topic::TopicDescription& topic_description,
BinIterator begin);
/**
* This operation allows the application to access the DataReader objects that contain
* samples with the specified sample_states, view_states, and
* instance_states.
*
* If the Presentation QosPolicy of the Subscriber to which the DataReader
* belongs has the access_scope set to GROUP, this operation should only be
* invoked inside a begin_access/end_access block. Otherwise it will throw
* error PreconditionNotMetError.
*
* Depending on the setting of the dds::core::policy::Presentation QoSPolicy,
* the returned collection of DataReader objects may be:
* - a set containing each DataReader at most once in no specified order,
* - a list containing each DataReader one or more times in a specific order.
*
* This difference is due to the fact that, in the second situation it is required to access
* samples belonging to different DataReader objects in a particular order. In this case,
* the application should process each DataReader in the same order it appears in the
* list and read or take exactly one sample from each DataReader. The patterns that
* an application should use to access data is fully described in dds::core::policy::Presentation.
*
* @param sub the Subscriber for which to find a DataReader
* @param data_state the data_state to find
* @param begin a forward iterator pointing to the start of a
* container in which to put the DataReaders
* @param max_size the number of DataReaders to return
* @return the total number of elements returned. Notice that
* at most max_size will be copied using the provided iterator
*/
template <typename READER, typename FwdIterator>
uint32_t
find(const dds::sub::Subscriber& sub,
const dds::sub::status::DataState& data_state,
FwdIterator begin, uint32_t max_size);
/**
* This operation allows the application to access the DataReader objects that contain
* samples with the specified sample_states, view_states, and
* instance_states.
*
* If the Presentation QosPolicy of the Subscriber to which the DataReader
* belongs has the access_scope set to GROUP, this operation should only be
* invoked inside a begin_access/end_access block. Otherwise it will throw
* error PreconditionNotMetError.
*
* Depending on the setting of the dds::core::policy::Presentation QoSPolicy,
* the returned collection of DataReader objects may be:
* - a set containing each DataReader at most once in no specified order,
* - a list containing each DataReader one or more times in a specific order.
*
* This difference is due to the fact that, in the second situation it is required to access
* samples belonging to different DataReader objects in a particular order. In this case,
* the application should process each DataReader in the same order it appears in the
* list and read or take exactly one sample from each DataReader. The patterns that
* an application should use to access data is fully described in dds::core::policy::Presentation.
*
* @param sub the Subscriber for which to find a DataReader
* @param rs the data_state to find
* @param begin a back inserting iterator pointing to the start
* of a container in which to put the DataReaders
* @return the total number of elements returned
*/
template <typename READER, typename BinIterator>
uint32_t
find(const dds::sub::Subscriber& sub,
const dds::sub::status::DataState& rs,
BinIterator begin);
}
}
#endif /* OMG_DDS_SUB_FIND_HPP_ */

View File

@@ -0,0 +1,35 @@
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OMG_DDS_SUB_QOS_DATA_READER_QOS_HPP_
#define OMG_DDS_SUB_QOS_DATA_READER_QOS_HPP_
#include <dds/sub/qos/detail/DataReaderQos.hpp>
namespace dds
{
namespace sub
{
namespace qos
{
typedef dds::sub::qos::detail::DataReaderQos DataReaderQos;
}
}
}
#endif /* OMG_DDS_SUB_QOS_DATA_READER_QOS_HPP_ */

View File

@@ -0,0 +1,36 @@
#ifndef OMG_DDS_SUB_QOS_SUBSCRIBER_QOS_HPP_
#define OMG_DDS_SUB_QOS_SUBSCRIBER_QOS_HPP_
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <dds/sub/qos/detail/SubscriberQos.hpp>
namespace dds
{
namespace sub
{
namespace qos
{
typedef dds::sub::qos::detail::SubscriberQos SubscriberQos;
}
}
}
#endif /* OMG_DDS_SUB_QOS_SUBSCRIBER_QOS_HPP_ */

View File

@@ -0,0 +1,150 @@
#ifndef OMG_DDS_SUB_QOS_DETAIL_DATA_READER_QOS_HPP_
#define OMG_DDS_SUB_QOS_DETAIL_DATA_READER_QOS_HPP_
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <dds/core/detail/TEntityQosImpl.hpp>
#include <org/eclipse/cyclonedds/sub/qos/DataReaderQosDelegate.hpp>
#ifdef DOXYGEN_FOR_ISOCPP
/* The above macro is never (and must never) be defined in normal compilation.
*
* The class below is just used to create informative API documentation.
* The predoxygen.py script will copy this over the QoS API header file.
*/
/**
* @brief
* This class provides the basic mechanism for an application to specify Quality of
* Service attributes for a DataReader.
*
* @par Attributes
* @anchor anchor_dds_sub_datareader_qos_defaults
* QosPolicy | Desciption | Default Value
* ---------------------------------------------- | ----------------------------------------------------------------------------------- | --------------------
* dds::core::policy::Durability | Data storage settings for late joiners (@ref DCPS_QoS_Durability "info") | Durability::Volatile()
* dds::core::policy::Deadline | Period in which new sample is written (@ref DCPS_QoS_Deadline "info") | Deadline::Deadline(infinite)
* dds::core::policy::LatencyBudget | Used for optimization (@ref DCPS_QoS_LatencyBudget "info") | LatencyBudget::LatencyBudget(zero)
* dds::core::policy::Liveliness | Liveliness assertion mechanism (@ref DCPS_QoS_Liveliness "info") | Liveliness::Automatic()
* dds::core::policy::Reliability | Reliability settings (@ref DCPS_QoS_Reliability "info") | Reliability::BestEffort()
* dds::core::policy::DestinationOrder | DataReader data order settings (@ref DCPS_QoS_DestinationOrder "info") | DestinationOrder::ReceptionTimestamp()
* dds::core::policy::History | Data storage settings (@ref DCPS_QoS_History "info") | History::KeepLast(depth 1)
* dds::core::policy::ResourceLimits | Maximum resource settings (@ref DCPS_QoS_ResourceLimits "info") | ResourceLimits::ResourceLimits(all unlimited)
* dds::core::policy::UserData | Additional information (@ref DCPS_QoS_UserData "info") | UserData::UserData(empty)
* dds::core::policy::Ownership | Exclusive ownership or not (@ref DCPS_QoS_Ownership "info") | Ownership::Shared()
* dds::core::policy::TimeBasedFilter | Maximum data rate (@ref DCPS_QoS_TimeBasedFilter "info") | TimeBasedFilter::TimeBasedFilter(0)
* dds::core::policy::ReaderDataLifecycle | Instance state changes and notifications (@ref DCPS_QoS_ReaderDataLifecycle "info") | ReaderDataLifecycle::NoAutoPurgeDisposedSamples()
* dds::core::policy::DataRepresentation | Supported data representation kinds (@ref DCPS_QoS_DataRepresentation "info") | DataRepresentation::DataRepresentation(dds::core::policy::DataRepresentationId::XCDR1)
* dds::core::policy::TypeConsistencyEnforcement | Type consistency enforcement policies (@ref DCPS_QoS_TypeConsistencyEnforcement "info") | dds::core::policy::TypeConsistencyKind::DISALLOW_TYPE_COERCION
*
* A QosPolicy can be set when the DataReader is created or modified with the set
* qos operation.
* Both operations take the DataReaderQos object as a parameter. There may be cases
* where several policies are in conflict. Consistency checking is performed each time
* the policies are modified when they are being created and, in case they are already
* enabled, via the set qos operation.
*
* Some QosPolicy have "immutable" semantics meaning that they can only be
* specified either at DataReader creation time or prior to calling the enable
* operation on the DataReader.
*
* @see for more information: @ref DCPS_QoS
*/
class dds::sub::qos::DataReaderQos : public ::dds::core::EntityQos<org::eclipse::cyclonedds::sub::qos::DataReaderQosDelegate>
{
public:
/**
* Create a @ref anchor_dds_sub_datareader_qos_defaults "default" QoS.
*/
DataReaderQos() {}
/**
* Create copied QoS.
*
* @param qos the QoS to copy policies from.
*/
DataReaderQos(const DataReaderQos& qos);
/**
* Create a DataReader QoS from a TopicQos.
*
* This operation will copy the QosPolicy settings from the TopicQos to the
* corresponding QosPolicy settings in the DataReaderQos. The related value
* in DataReaderQos will be repliced, while the other policies will get the
* @ref anchor_dds_sub_datareader_qos_defaults "default" QoS policies.
*
* This is a "convenience" operation. It can be used to merge
* @ref anchor_dds_sub_datareader_qos_defaults "default" DataReader
* QosPolicy settings with the corresponding ones on the Topic. The resulting
* DataReaderQos can then be used to create a new DataReader, or set its
* DataReaderQos.
* @code{.cpp}
* dds::topic::qos::TopicQos topicQos = topic.qos();
* dds::sub::qos::DataReaderQos readerQos(topicQos);
* // Policies of the DataReaderQos that are not present in the TopicQos
* // have the default value.
* @endcode
*
* This operation does not check the resulting DataReaderQos for self
* consistency. This is because the "merged" DataReaderQos may not be the
* final one, as the application can still modify some QosPolicy settings prior to
* applying the DataReaderQos to the DataReader.
*
* @param qos the QoS to copy policies from.
*/
DataReaderQos(const dds::topic::qos::TopicQos& qos);
/**
* Assign dds::topic::qos::TopicQos policies to the DataReaderQos.
*
* This operation will copy the QosPolicy settings from the TopicQos to the
* corresponding QosPolicy settings in the DataReaderQos (replacing the values,
* if present).
*
* This is a "convenience" operation, useful in combination with the operations
* Subscriber::default_datareader_qos() and dds::topic::Topic::qos().
* This operation can be used to merge the DataReader
* QosPolicy settings with the corresponding ones on the Topic. The resulting
* DataReaderQos can then be used to create a new DataReader, or set its
* DataReaderQos.
* @code{.cpp}
* dds::topic::qos::TopicQos topicQos = topic.qos();
* dds::sub::qos::DataReaderQos readerQos = subscriber.default_datareader_qos();
* readerQos = topicQos;
* // Policies of the DataReaderQos that are not present in the TopicQos are untouched.
* @endcode
*
* This operation does not check the resulting DataReaderQos for self
* consistency. This is because the "merged" DataReaderQos may not be the
* final one, as the application can still modify some QosPolicy settings prior to
* applying the DataReaderQos to the DataReader.
*
* @param qos the QoS to copy policies from.
*/
DataReaderQos& operator= (const dds::topic::qos::TopicQos& other);
};
#else /* DOXYGEN_FOR_ISOCPP */
namespace dds { namespace sub { namespace qos { namespace detail {
typedef ::dds::core::TEntityQos< ::org::eclipse::cyclonedds::sub::qos::DataReaderQosDelegate > DataReaderQos;
} } } }
#endif /* DOXYGEN_FOR_ISOCPP */
#endif /* OMG_DDS_SUB_QOS_DETAIL_DATA_READER_QOS_HPP_ */

View File

@@ -0,0 +1,82 @@
#ifndef OMG_DDS_SUB_QOS_DETAIL_SUBSCRIBER_QOS_HPP_
#define OMG_DDS_SUB_QOS_DETAIL_SUBSCRIBER_QOS_HPP_
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <dds/core/detail/TEntityQosImpl.hpp>
#include <org/eclipse/cyclonedds/sub/qos/SubscriberQosDelegate.hpp>
#ifdef DOXYGEN_FOR_ISOCPP
/* The above macro is never (and must never) be defined in normal compilation.
*
* The class below is just used to create informative API documentation.
* The predoxygen.py script will copy this over the QoS API header file.
*/
/**
* @brief
* This class provides the basic mechanism for an application to specify Quality of
* Service attributes for a Subscriber.
*
* @par Attributes
* @anchor anchor_dds_sub_subscriber_qos_defaults
* QosPolicy | Desciption | Default Value
* ------------------------------------ | --------------------------------------------------------------------- | --------------------
* dds::core::policy::Presentation | Data-instance change dependencies (@ref DCPS_QoS_Presentation "info") | Presentation::InstanceAccessScope(coherent=false, ordered=false)
* dds::core::policy::Partition | Active partitions (@ref DCPS_QoS_Partition "info") | Partition::Partition(empty)
* dds::core::policy::GroupData | Additional information (@ref DCPS_QoS_GroupData "info") | GroupData::GroupData(empty)
* dds::core::policy::EntityFactory | Create enabled (@ref DCPS_QoS_EntityFactory "info") | EntityFactory::AutoEnable()
*
* A QosPolicy can be set when the Subscriber is created or modified with the set qos
* operation.
* Both operations take the SubscriberQos object as a parameter. There may be cases where
* several policies are in conflict. Consistency checking is performed each time the
* policies are modified when they are being created and, in case they are already
* enabled, via the set qos operation.
*
* Some QosPolicy have "immutable" semantics meaning that they can only be
* specified either at Subscriber creation time or prior to calling the enable operation
* on the Subscriber.
*
* @see for more information: @ref DCPS_QoS
*/
class dds::sub::qos::SubscriberQos : public ::dds::core::EntityQos<org::eclipse::cyclonedds::sub::qos::SubscriberQosDelegate>
{
public:
/**
* Create @ref anchor_dds_sub_subscriber_qos_defaults "default" QoS.
*/
SubscriberQos() {}
/**
* Create copied QoS type.
*
* @param qos the QoS to copy policies from.
*/
SubscriberQos(const SubscriberQos& qos);
};
#else /* DOXYGEN_FOR_ISOCPP */
namespace dds { namespace sub { namespace qos { namespace detail {
typedef ::dds::core::TEntityQos< ::org::eclipse::cyclonedds::sub::qos::SubscriberQosDelegate> SubscriberQos;
} } } }
#endif /* DOXYGEN_FOR_ISOCPP */
#endif /* OMG_DDS_SUB_QOS_DETAIL_SUBSCRIBER_QOS_HPP_ */

View File

@@ -0,0 +1,711 @@
#ifndef OMG_DDS_SUB_DATA_STATE_HPP_
#define OMG_DDS_SUB_DATA_STATE_HPP_
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <bitset>
#include <dds/core/types.hpp>
namespace dds
{
namespace sub
{
namespace status
{
class SampleState;
class ViewState;
class InstanceState;
class DataState;
}
}
}
/**
* @brief
* Class to hold SampleState information.
*
* For each sample, the Data Distribution Service internally maintains a
* sample_state specific to each DataReader. The sample_state can either be
* READ_SAMPLE_STATE or NOT_READ_SAMPLE_STATE.
* - <b><i>read</i></b>
* - The DataReader has already accessed that
* sample by means of read. Had the sample been accessed by take it would
* no longer be available to the DataReader.
* - <b><i>not_read</i></b>
* - The DataReader has not accessed that sample before.
*
* @see for more information: @ref DCPS_Modules_Subscription_SampleInfo "SampleInfo"
*/
class OMG_DDS_API dds::sub::status::SampleState : public std::bitset<OMG_DDS_STATE_BIT_COUNT>
{
public:
/**
* Convenience typedef for std::bitset<OMG_DDS_STATE_BIT_COUNT>.
*/
typedef std::bitset<OMG_DDS_STATE_BIT_COUNT> MaskType;
public:
/**
* Construct a SampleState with default MaskType.
*/
SampleState();
/**
* Construct a SampleState with MaskType of i.
*
* @param i MaskType
*/
explicit SampleState(uint32_t i);
/**
* Copy constructor.
* Construct a SampleState with existing SampleState.
*
* @param src the SampleState to copy from
*/
SampleState(const SampleState& src);
/**
* Copy assignment operator.
*
* Copy the contents from one SampleState to another.
*
* @param src the SampleState to copy from
*
* @return reference to the SampleState instance that was copied to
*/
SampleState& operator=(const SampleState& src) = default;
/**
* Construct a SampleState with existing MaskType.
*
* @param src the MaskType to copy from
*/
SampleState(const MaskType& src);
public:
/**
* Get the READ_SAMPLE_STATE.
*
* <i>read</i>
* - The DataReader has already accessed that
* sample by means of read. Had the sample been accessed by take it would
* no longer be available to the DataReader.
*
* @return the read SampleState
*/
inline static const SampleState read();
/**
* Get the NOT_READ_SAMPLE_STATE.
*
*<i>not_read</i>
* - The DataReader has not accessed that sample before.
*
* @return the not_read SampleState
*/
inline static const SampleState not_read();
/**
* Get any SampleState.
*
* Either the sample has already been read or not read.
*
* @return any SampleState
*/
inline static const SampleState any();
};
/**
* @brief
* Class to hold sample ViewState information.
*
* For each instance (identified by the key), the Data Distribution Service internally
* maintains a view_state relative to each DataReader. The ViewSate can
* either be NEW_VIEW_STATE or NOT_NEW_VIEW_STATE.
* - <b><i>new_view</i></b>
* - Either this is the first time that the DataReader
* has ever accessed samples of that instance, or else that the DataReader has
* accessed previous samples of the instance, but the instance has since been reborn
* (i.e. become not-alive and then alive again).
* - <b><i>not_new_view</i></b>
* - The DataReader has already accessed
* samples of the same instance and that the instance has not been reborn since.
*
* @see for more information: @ref DCPS_Modules_Subscription_SampleInfo "SampleInfo"
*/
class OMG_DDS_API dds::sub::status::ViewState : public std::bitset<OMG_DDS_STATE_BIT_COUNT>
{
public:
/**
* Convenience typedef for std::bitset<OMG_DDS_STATE_BIT_COUNT>.
*/
typedef std::bitset<OMG_DDS_STATE_BIT_COUNT> MaskType;
public:
/**
* Construct a ViewState with default MaskType.
*/
ViewState();
/**
* Construct a ViewState with MaskType of i.
*
* @param m the MaskType
*/
explicit ViewState(uint32_t m);
/**
* Copy constructor.
*
* Construct a ViewState with existing ViewState.
*
* @param src the ViewState to copy from
*/
ViewState(const ViewState& src);
/**
* Copy assignment operator.
*
* Copy the contents from one ViewState to another.
*
* @param src the ViewState to copy from
*
* @return reference to the ViewState instance that was copied to
*/
ViewState& operator=(const ViewState& src) = default;
/**
* Construct a ViewState with existing MaskType.
*
* @param src the MaskType to copy from
*/
ViewState(const MaskType& src);
public:
/**
* Get the NEW_VIEW_STATE.
*
* <i>new_view</i>
* - Either this is the first time that the DataReader
* has ever accessed samples of that instance, or else that the DataReader has
* accessed previous samples of the instance, but the instance has since been reborn
* (i.e. become not-alive and then alive again).
*
* @return the new_view ViewState
*/
inline static const ViewState new_view();
/**
* Get the NOT_NEW_VIEW_STATE.
*
* <i>not_new_view</i>
* - The DataReader has already accessed
* samples of the same instance and that the instance has not been reborn since.
*
* @return the not_new_view ViewState
*/
inline static const ViewState not_new_view();
/**
* Get any ViewState.
*
* Either the sample has already been seen or not seen.
*
* @return the any ViewState
*/
inline static const ViewState any();
};
/**
* @brief
* Class to hold sample InstanceState information.
*
* For each instance the Data Distribution Service internally maintains an
* InstanceState. The InstanceState can be:
* - <b><i>alive</i></b>, which indicates that
* - samples have been received for the instance
* - there are live DataWriter objects writing the instance
* - the instance has not been explicitly disposed of (or else samples have been
* received after it was disposed of)
* - <b><i>not_alive_disposed</i></b>, which indicates that
* - the instance was disposed
* of by a DataWriter, either explicitly by means of the dispose operation or
* implicitly in case the autodispose_unregistered_instances field of the
* WriterDataLyfecycle QosPolicy equals TRUE when the instance gets
* unregistered, WriterDataLifecycle QosPolicy and no new
* samples for that instance have been written afterwards.
* - <b><i>not_alive_no_writers</i></b>, which indicates that
* - the instance has been
* declared as not-alive by the DataReader because it detected that there are no live
* DataWriter objects writing that instance.
*
* @see for more information: @ref DCPS_Modules_Subscription_SampleInfo "SampleInfo"
*/
class OMG_DDS_API dds::sub::status::InstanceState : public std::bitset<OMG_DDS_STATE_BIT_COUNT>
{
public:
/**
* Convenience typedef for std::bitset<OMG_DDS_STATE_BIT_COUNT>.
*/
typedef std::bitset<OMG_DDS_STATE_BIT_COUNT> MaskType;
public:
/**
* Construct an InstanceState with no state flags set.
*/
InstanceState();
/**
* Construct an InstanceState with an uint32_t m, representing a bit array.
*
* @param m the bit array to initialize the bitset with
*/
explicit InstanceState(uint32_t m);
/**
* Copy constructor.
*
* Construct an InstanceState with existing InstanceState.
*
* @param src the InstanceState to copy from
*/
InstanceState(const InstanceState& src);
/**
* Copy assignment operator.
*
* Copy the contents from one InstanceState to another.
*
* @param src the InstanceState to copy from
*
* @return reference to the InstanceState instance that was copied to
*/
InstanceState& operator=(const InstanceState& src) = default;
/**
* Construct an InstanceState with existing MaskType.
*
* @param src the bitset to copy from
*/
InstanceState(const MaskType& src);
public:
/**
* Get ALIVE_INSTANCE_STATE.
*
* <i>alive</i>, which indicates that
* - samples have been received for the instance
* - there are live DataWriter objects writing the instance
* - the instance has not been explicitly disposed of (or else samples have been
* received after it was disposed of)
*
* @return the alive InstanceState
*/
inline static const InstanceState alive();
/**
* Get NOT_ALIVE_DISPOSED_INSTANCE_STATE.
*
* <i>not_alive_disposed</i>, which indicates that
* - the instance was disposed
* of by a DataWriter, either explicitly by means of the dispose operation or
* implicitly in case the autodispose_unregistered_instances field of the
* WriterDataLyfecycle QosPolicy equals TRUE when the instance gets
* unregistered, WriterDataLifecycle QosPolicy and no new
* samples for that instance have been written afterwards.
*
* @return the not_alive_disposed InstanceState
*/
inline static const InstanceState not_alive_disposed();
/**
* Get NOT_ALIVE_NO_WRITERS_INSTANCE_STATE.
*
* <i>not_alive_no_writers</i>, which indicates that
* - the instance has been
* declared as not-alive by the DataReader because it detected that there are no live
* DataWriter objects writing that instance.
*
* @return the not_alive_no_writers InstanceState
*/
inline static const InstanceState not_alive_no_writers();
/**
* Get not_alive mask
*
* <i>not_alive</i> = not_alive_disposed | not_alive_no_writers:
* - <i>not_alive_disposed</i>, which indicates that
* - the instance was disposed
* of by a DataWriter, either explicitly by means of the dispose operation or
* implicitly in case the autodispose_unregistered_instances field of the
* WriterDataLyfecycle QosPolicy equals TRUE when the instance gets
* unregistered, WriterDataLifecycle QosPolicy and no new
* samples for that instance have been written afterwards.
* - <i>not_alive_no_writers</i>, which indicates that
* - the instance has been
* declared as not-alive by the DataReader because it detected that there are no live
* DataWriter objects writing that instance.
*
* @return the not_alive_mask InstanceState
*/
inline static const InstanceState not_alive_mask();
/**
* Get any InstanceState.
*
* This Instance is either in existence or not in existence.
*
* @return the any InstanceState
*/
inline static const InstanceState any();
};
/**
* @brief
* Class to hold sample DataState information.
*
* The DataState is part of dds::sub::SampleInfo but can also be used as data filter for
* @ref dds::sub::DataReader "DataReaders".
*
* The DataState contains the following:
* - The sample_state of the Data value (i.e., if the sample has already been READ or NOT_READ by that same DataReader).
* - The view_state of the related instance (i.e., if the instance is NEW, or NOT_NEW for that DataReader).
* - The instance_state of the related instance (i.e., if the instance is ALIVE, NOT_ALIVE_DISPOSED, or NOT_ALIVE_NO_WRITERS).
*
* @see for more information: @ref DCPS_Modules_Subscription_SampleInfo "SampleInfo"
*/
class OMG_DDS_API dds::sub::status::DataState
{
public:
/**
* Create a DataState instance.
*
* Construct a DataState with:
* - SampleState::any
* - ViewState::any
* - InstanceState::any
*
*/
DataState()
: ss_(dds::sub::status::SampleState::any()),
vs_(dds::sub::status::ViewState::any()),
is_(dds::sub::status::InstanceState::any())
{ }
/**
* Create a DataState instance.
*
* Construct a DataState with:
* - Given SampleState ss
* - ViewState::any
* - InstanceState::any
*
* @param ss the SampleState to construct DataState from
*/
/* implicit */ DataState(const dds::sub::status::SampleState& ss)
: ss_(ss),
vs_(dds::sub::status::ViewState::any()),
is_(dds::sub::status::InstanceState::any())
{ }
/**
* Create a DataState instance.
*
* Construct a DataState with:
* - SampleState::any
* - Given ViewState vs
* - InstanceState::any
*
* @param vs the ViewState to construct DataState from
*/
/* implicit */ DataState(const dds::sub::status::ViewState& vs)
: ss_(dds::sub::status::SampleState::any()),
vs_(vs),
is_(dds::sub::status::InstanceState::any())
{ }
/**
* Create a DataState instance.
*
* Construct a DataState with:
* - SampleState::any
* - ViewState::any
* - Given InstanceState is
*
* @param is InstanceState to construct DataState from
*/
/* implicit */ DataState(const dds::sub::status::InstanceState& is)
: ss_(dds::sub::status::SampleState::any()),
vs_(dds::sub::status::ViewState::any()),
is_(is)
{ }
/**
* Create a DataState instance.
*
* Construct a DataState with:
* - Given SampleState ss
* - Given ViewState vs
* - Given InstanceState is
*
* @param ss SampleState
* @param vs ViewState
* @param is InstanceState
*/
DataState(const dds::sub::status::SampleState& ss,
const dds::sub::status::ViewState& vs,
const dds::sub::status::InstanceState& is)
: ss_(ss), vs_(vs), is_(is)
{ }
/**
* Set SampleState.
*
* @param ss SampleState
*/
DataState& operator << (const dds::sub::status::SampleState& ss)
{
ss_ = ss;
return *this;
}
/**
* Set InstanceState.
*
* @param is InstanceState
*/
DataState& operator << (const dds::sub::status::InstanceState& is)
{
is_ = is;
return *this;
}
/**
* Set ViewState.
*
* @param vs ViewState
*/
DataState& operator << (const dds::sub::status::ViewState& vs)
{
vs_ = vs;
return *this;
}
/**
* Get SampleState.
*
* @param ss SampleState
* @return the DataState
*/
const DataState& operator >> (dds::sub::status::SampleState& ss) const
{
ss = ss_;
return *this;
}
/**
* Get InstanceState.
*
* @param is InstanceState
* @return the DataState
*/
const DataState& operator >> (dds::sub::status::InstanceState& is) const
{
is = is_;
return *this;
}
/**
* Get ViewState.
*
* @param vs ViewState
* @return the DataState
*/
const DataState& operator >> (dds::sub::status::ViewState& vs) const
{
vs = vs_;
return *this;
}
/**
* Check if this DataState is equal with another
*
* @return true if equal
*/
bool operator ==(const DataState& o) const
{
return ((ss_ == o.ss_) && (vs_ == o.vs_) && (is_ == o.is_));
}
/**
* Check if this DataState is not equal with another
*
* @return true if not equal
*/
bool operator !=(const DataState& o) const
{
return !operator==(o);
}
/**
* Get SampleState.
*
* @return the SampleState
*/
const dds::sub::status::SampleState& sample_state() const
{
return ss_;
}
/**
* Set SampleState.
*
* @param ss SampleState
*/
void sample_state(const dds::sub::status::SampleState& ss)
{
*this << ss;
}
/**
* Get InstanceState.
*
* @return the InstanceState
*/
const dds::sub::status::InstanceState& instance_state() const
{
return is_;
}
/**
* Set InstanceState.
*
* @param is InstanceState
*/
void instance_state(const dds::sub::status::InstanceState& is)
{
*this << is;
}
/**
* Get ViewState.
*
* @return the ViewState
*/
const dds::sub::status::ViewState& view_state() const
{
return vs_;
}
/**
* Set ViewState.
*
* @param vs ViewState
*/
void view_state(const dds::sub::status::ViewState& vs)
{
*this << vs;
}
/**
* Create a DataState instance.
*
* Return a DataState with:
* - SampleState::any
* - ViewState::any
* - InstanceState::any
*
* @return the any DataState
*/
static DataState any()
{
return DataState(dds::sub::status::SampleState::any(),
dds::sub::status::ViewState::any(),
dds::sub::status::InstanceState::any());
}
/**
* Create a DataState instance.
*
* Return a DataState with:
* - SampleState::not_read
* - ViewState::any
* - InstanceState::alive
*
* @return the new_data DataState
*/
static DataState new_data()
{
return DataState(dds::sub::status::SampleState::not_read(),
dds::sub::status::ViewState::any(),
dds::sub::status::InstanceState::alive());
}
/**
* Create a DataState instance.
*
* Return a DataState with:
* - SampleState::any
* - ViewState::any
* - InstanceState::alive
*
* @return the any_data DataState
*/
static DataState any_data()
{
return DataState(dds::sub::status::SampleState::any(),
dds::sub::status::ViewState::any(),
dds::sub::status::InstanceState::alive());
}
/**
* Create a DataState instance.
*
* Return a DataState with:
* - SampleState::any
* - ViewState::new_view
* - InstanceState::alive
*
* @return the new_instance DataState
*/
static DataState new_instance()
{
return DataState(dds::sub::status::SampleState::any(),
dds::sub::status::ViewState::new_view(),
dds::sub::status::InstanceState::alive());
}
private:
dds::sub::status::SampleState ss_;
dds::sub::status::ViewState vs_;
dds::sub::status::InstanceState is_;
};
#endif /* OMG_DDS_SUB_DATA_STATE_HPP_ */

View File

@@ -0,0 +1,97 @@
/*
* Copyright(c) 2006 to 2020 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef CYCLONEDDS_DDS_SUB_STATUS_DATASTATE_IMPL_HPP_
#define CYCLONEDDS_DDS_SUB_STATUS_DATASTATE_IMPL_HPP_
/**
* @file
*/
#include <dds/sub/status/DataState.hpp>
/*
* OMG PSM class declaration
*/
// Implementation
namespace dds
{
namespace sub
{
namespace status
{
inline const SampleState SampleState::read()
{
return SampleState(0x0001 << 0u);
}
inline const SampleState SampleState::not_read()
{
return SampleState(0x0001 << 1u);
}
inline const SampleState SampleState::any()
{
return SampleState(0xffff);
}
inline const ViewState ViewState::new_view()
{
return ViewState(0x0001 << 0u);
}
inline const ViewState ViewState::not_new_view()
{
return ViewState(0x0001 << 1u);
}
inline const ViewState ViewState::any()
{
return ViewState(0xffff);
}
inline const InstanceState InstanceState::alive()
{
return InstanceState(0x0001 << 0u);
}
inline const InstanceState InstanceState::not_alive_disposed()
{
return InstanceState(0x0001 << 1u);
}
inline const InstanceState InstanceState::not_alive_no_writers()
{
return InstanceState(0x0001 << 2u);
}
inline const InstanceState InstanceState::not_alive_mask()
{
return not_alive_disposed() | not_alive_no_writers();
}
inline const InstanceState InstanceState::any()
{
return InstanceState(0xffff);
}
} /* namespace status */
} /* namespace sub */
} /* namespace dds */
// End of implementation
#endif /* CYCLONEDDS_DDS_SUB_STATUS_DATASTATE_IMPL_HPP_ */