RTI Connext Modern C++ API Version 7.2.0
dds::sub::status::InstanceState Class Reference

Indicates if the samples are from a live dds::pub::DataWriter or not. More...

#include <dds/sub/status/DataState.hpp>

Inherits std::bitset< OMG_DDS_STATE_BIT_COUNT >.

Public Types

typedef std::bitset< OMG_DDS_STATE_BIT_COUNT > MaskType
 An std::bitset of InstanceStates. More...
 

Public Member Functions

 InstanceState (const MaskType &other)
 Create an InstanceState from MaskType. More...
 

Static Public Member Functions

static const InstanceState alive ()
 Creates an alive InstanceState object. More...
 
static const InstanceState not_alive_disposed ()
 Creates a not_alive_disposed InstanceState object. More...
 
static const InstanceState not_alive_no_writers ()
 Creates a not_alive_no_writers InstanceState object. More...
 
static const InstanceState not_alive_mask ()
 Creates an InstanceState object representing any not alive state. More...
 
static const InstanceState any ()
 Creates an InstanceState object representing any instance state. More...
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &os, const InstanceState &s)
 Prints an instance state as a readable string. More...
 

Detailed Description

Indicates if the samples are from a live dds::pub::DataWriter or not.

For each instance, the middleware internally maintains an instance state. The instance state can be:

The precise behavior events that cause the instance state to change depends on the setting of the OWNERSHIP QoS:

The instance state available in the dds::sub::SampleInfo is a snapshot of the instance state of the instance at the time the collection was obtained (i.e. at the time read or take was called). The instance state is therefore the same for all samples in the returned collection that refer to the same instance.

For example, you can check if an instance is disposed as follows:

for (auto sample : reader.take()) {
if (sample.info().state().instance_state() ==
// ...
}
}
static const InstanceState not_alive_disposed()
Creates a not_alive_disposed InstanceState object.
Definition: status/DataState.hpp:230

Member Typedef Documentation

◆ MaskType

typedef std::bitset<OMG_DDS_STATE_BIT_COUNT > dds::sub::status::InstanceState::MaskType

An std::bitset of InstanceStates.

Constructor & Destructor Documentation

◆ InstanceState()

dds::sub::status::InstanceState::InstanceState ( const MaskType other)
inline

Create an InstanceState from MaskType.

Parameters
otherThe MaskType to create the InstanceState with

Member Function Documentation

◆ alive()

static const InstanceState dds::sub::status::InstanceState::alive ( )
inlinestatic

Creates an alive InstanceState object.

The instance is currently in existence.

Referenced by dds::sub::status::DataState::any_data(), dds::sub::status::DataState::new_data(), and dds::sub::status::DataState::new_instance().

◆ not_alive_disposed()

static const InstanceState dds::sub::status::InstanceState::not_alive_disposed ( )
inlinestatic

Creates a not_alive_disposed InstanceState object.

Indicates that the instance has been disposed by a DataWriter.

◆ not_alive_no_writers()

static const InstanceState dds::sub::status::InstanceState::not_alive_no_writers ( )
inlinestatic

Creates a not_alive_no_writers InstanceState object.

Indicates that none of the DataWriters that are currently alive (according to the dds::core::policy::Liveliness policy) are writing the instance.

◆ not_alive_mask()

static const InstanceState dds::sub::status::InstanceState::not_alive_mask ( )
inlinestatic

Creates an InstanceState object representing any not alive state.

This is equivalent to not_alive_disposed() | not_alive_no_writers()

◆ any()

static const InstanceState dds::sub::status::InstanceState::any ( )
inlinestatic

Creates an InstanceState object representing any instance state.

This is equivalent to not_alive_mask() | alive().

Referenced by dds::sub::status::DataState::any().

Friends And Related Function Documentation

◆ operator<<()

std::ostream & operator<< ( std::ostream &  os,
const InstanceState s 
)
related

Prints an instance state as a readable string.