RTI Connext Modern C++ API Version 7.3.0
dds::pub::AnyDataWriter Class Reference

<<reference-type>> This class provides an non-template holder for representing a DataWriter of any type More...

#include "dds/pub/AnyDataWriter.hpp"

Public Member Functions

template<typename T >
 AnyDataWriter (const dds::pub::DataWriter< T > &dw)
 Create an AnyDataWriter that represents a generic, untyped DataWriter. More...
 
const dds::pub::qos::DataWriterQos qos () const
 Get the QoS for this AnyDataWriter. More...
 
void qos (const dds::pub::qos::DataWriterQos &the_qos)
 Set the QoS for this AnyDataWriter. More...
 
const std::string & topic_name () const
 Get the topic name for this AnyDataWriter. More...
 
const std::string & type_name () const
 Get the type name for this AnyDataWriter. More...
 
const dds::pub::Publisherpublisher () const
 Get the publisher for this AnyDataWriter. More...
 
void wait_for_acknowledgments (const dds::core::Duration &timeout)
 
void close ()
 Close the DataWriter. More...
 
void retain ()
 Retain this AnyDataWriter. More...
 
template<typename T >
AnyDataWriteroperator= (const dds::pub::DataWriter< T > &other)
 Assign a different DataWriter. More...
 
template<typename T >
DataWriter< T > get ()
 Gets the typed DataWriter from this AnyDataWriter. More...
 

Related Functions

(Note that these are not member functions.)

template<typename T >
DataWriter< T > get (const AnyDataWriter &any_writer)
 Same as AnyDataWriter::get() More...
 

Detailed Description

<<reference-type>> This class provides an non-template holder for representing a DataWriter of any type

This class is useful for code that uses DataWriters of different types. It provides access to type-independent DataWriter functions.

An AnyDataWriter is always created from a typed DataWriter, increasing its reference count. The member function get() allows getting the typed DataWriter back.

Constructor & Destructor Documentation

◆ AnyDataWriter()

template<typename T >
dds::pub::AnyDataWriter::AnyDataWriter ( const dds::pub::DataWriter< T > &  dw)
inline

Create an AnyDataWriter that represents a generic, untyped DataWriter.

Template Parameters
TThe type of the DataWriter that this AnyDataWriter is being created from
Parameters
dwThe typed DataWriter that this AnyDataWriter will represent

Referenced by operator=().

Member Function Documentation

◆ qos() [1/2]

const dds::pub::qos::DataWriterQos dds::pub::AnyDataWriter::qos ( ) const
inline

Get the QoS for this AnyDataWriter.

Returns
dds::pub::qos::DataWriterQos The DataWriterQos

◆ qos() [2/2]

void dds::pub::AnyDataWriter::qos ( const dds::pub::qos::DataWriterQos the_qos)
inline

Set the QoS for this AnyDataWriter.

Parameters
the_qosThe QoS to set

◆ topic_name()

const std::string & dds::pub::AnyDataWriter::topic_name ( ) const
inline

Get the topic name for this AnyDataWriter.

Returns
The topic name

◆ type_name()

const std::string & dds::pub::AnyDataWriter::type_name ( ) const
inline

Get the type name for this AnyDataWriter.

Returns
The type name

◆ publisher()

const dds::pub::Publisher & dds::pub::AnyDataWriter::publisher ( ) const
inline

Get the publisher for this AnyDataWriter.

Returns
The publisher

◆ wait_for_acknowledgments()

void dds::pub::AnyDataWriter::wait_for_acknowledgments ( const dds::core::Duration timeout)
inline

◆ close()

void dds::pub::AnyDataWriter::close ( )
inline

Close the DataWriter.

See also
DataWriter::close()

◆ retain()

void dds::pub::AnyDataWriter::retain ( )
inline

Retain this AnyDataWriter.

See also
DataWriter::retain()

◆ operator=()

template<typename T >
AnyDataWriter & dds::pub::AnyDataWriter::operator= ( const dds::pub::DataWriter< T > &  other)
inline

Assign a different DataWriter.

Replaces the reference to the current writer with a new one, whose type T can be different.

References AnyDataWriter().

◆ get()

template<typename T >
DataWriter< T > dds::pub::AnyDataWriter::get ( )
inline

Gets the typed DataWriter from this AnyDataWriter.

Template Parameters
TThe type of the DataWriter to extract
Returns
The typed DataWriter that this AnyDataWriter represents
Exceptions
dds::core::InvalidDowncastErrorIf this AnyDataWriter doesn't represent a DataWriter<T>.

Referenced by get().

Friends And Related Function Documentation

◆ get()

template<typename T >
DataWriter< T > get ( const AnyDataWriter any_writer)
related

Same as AnyDataWriter::get()

Examples
Foo.hpp.

References get().