OpenSplice ISO C++ 2 DCPS  v6.x
ISO C++ 2 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
dds::sub::CoherentAccess Class Reference

Class for RAII way of beginning/ending coherent access. More...

#include "CoherentAccess.hpp"

Inheritance diagram for dds::sub::CoherentAccess:
Inheritance graph

Public Member Functions

 CoherentAccess (const dds::sub::Subscriber &sub)
 
 ~CoherentAccess ()
 
void end ()
 
bool operator!= (const Value &other) const
 
D * operator-> ()
 
const D * operator-> () const
 
bool operator== (const Value &other) const
 

Detailed Description

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.

dds::topic::Topic<Foo::Bar> topic(participant, "TopicName");
dds::sub::Subscriber subscriber(participant, sQos);
{
std::vector< dds::sub::DataReader<Foo::Bar> > readers;
// Start coherent access.
dds::sub::CoherentAccess coherentAccess(subscriber);
// Find (previously created with the subscriber) datareaders that now got data.
dds::sub::find< dds::sub::DataReader<Foo::Bar> >(subscriber,
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()
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
See also
Subscription
dds::sub::Subscriber

Definition at line 94 of file CoherentAccess.hpp.

Constructor & Destructor Documentation

◆ CoherentAccess()

dds::sub::CoherentAccess::CoherentAccess ( const dds::sub::Subscriber sub)
explicit

Creating a CoherentAccess object, which will begin ‘coherent access’ of received samples using DataReader objects attached to this Subscriber.

Note that a coherent subscriber should first be enabled, otherwise this operation will throw dds::core::NotEnabledError. Please consult dds::core::Entity::enable() for additional information about coherent access.

Parameters
subThe Subscriber to begin the coherent access on.
Exceptions
dds::core::ErrorAn internal error has occurred.
dds::core::AlreadyClosedErrorThe Subscriber has already been closed.
dds::core::NotEnabledErrorThe Subscriber has not yet been enabled.
dds::core::OutOfResourcesErrorThe Data Distribution Service ran out of resources to complete this operation.
dds::core::NullReferenceErrorThe Subscriber was not properly created and references to dds::core::null.

Definition at line 41 of file CoherentAccessImpl.hpp.

◆ ~CoherentAccess()

dds::sub::CoherentAccess::~CoherentAccess ( )

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.

Definition at line 52 of file CoherentAccessImpl.hpp.

Member Function Documentation

◆ end()

void dds::sub::CoherentAccess::end ( )

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.

Please consult dds::core::Entity::enable() for additional information about coherent access.

Exceptions
dds::core::ErrorAn internal error has occurred.
dds::core::AlreadyClosedErrorThe Subscriber has already been closed.
dds::core::NotEnabledErrorThe Subscriber has not yet been enabled.
dds::core::NullReferenceErrorThe Subscriber was not properly created and references to dds::core::null.

Definition at line 44 of file CoherentAccessImpl.hpp.

◆ operator!=()

template<typename D >
bool dds::core::Value< D >::operator!= ( const Value< D > &  other) const
inherited

Compare this Value with another Value

Parameters
otherValue
Returns
true if not equal

Definition at line 99 of file Value.hpp.

◆ operator->() [1/2]

template<typename D >
D * dds::core::Value< D >::operator-> ( )
inherited

The operator->() is provided to be able to directly invoke functions on the delegate.

The decision to provide direct access to the delegate was motivated by the need for providing a way that was not invasive with respect to the CXXDDS API and yet would allow for vendor-specific extension. Thus vendor-specific extensions can be invoked on the Value and on all its subclasses as follows:

my_dds_value.standard_function();
my_dds_value->vendor_specific_extension();
Returns
a reference to delegate.

Definition at line 111 of file Value.hpp.

◆ operator->() [2/2]

template<typename D >
const D * dds::core::Value< D >::operator-> ( ) const
inherited

The operator->() is provided to be able to directly invoke functions on the delegate.

The decision to provide direct access to the delegate was motivated by the need for providing a way that was not invasive with respect to the CXXDDS API and yet would allow for vendor-specific extension. Thus vendor-specific extensions can be invoked on the Value and on all its subclasses as follows:

my_dds_value.standard_function();
my_dds_value->vendor_specific_extension();
Returns
a reference to delegate.

Definition at line 105 of file Value.hpp.

◆ operator==()

template<typename D >
bool dds::core::Value< D >::operator== ( const Value< D > &  other) const
inherited

Compare this Value with another Value

Parameters
otherValue
Returns
true if equal

Definition at line 93 of file Value.hpp.


The documentation for this class was generated from the following files: