CoreDX DDS C++ Reference Manual
Public Member Functions | List of all members
DDS::Subscriber Class Reference

The Subscriber configures, creates, manages and destroys DataReaders. More...

Inheritance diagram for DDS::Subscriber:
DDS::Entity

Public Member Functions

ReturnCode_t enable ()
 Enables the Subscriber. More...
 
InstanceHandle_t get_instance_handle ()
 This operation returns the InstanceHandle_t that identifies the Subscriber.
 
StatusMask get_status_changes ()
 This returns the list of triggered communication statuses in the Subscriber. More...
 
DataReadercreate_datareader (TopicDescription *a_topic, const DataReaderQos &qos, DataReaderListener *a_listener, StatusMask mask)
 This operation creates a DataReader. More...
 
ReturnCode_t delete_datareader (class DataReader *a_datareader)
 This operation deletes a DataReader. More...
 
ReturnCode_t delete_contained_entities ()
 This operation deletes all the DataReaders created by means of the Subscriber::create_datareader() operation on the Subscriber s. More...
 
DataReaderlookup_datareader (const char *topic_name)
 This operation retrieves a previously-created DataReader contained in the Subscriber, attached to a Topic named topic_name. More...
 
ReturnCode_t get_datareaders (DataReaderSeq *readers, SampleStateMask sample_states, ViewStateMask view_states, InstanceStateMask instance_states)
 This operation allows the application to access DataReader objects that contain samples with the specified sample_states, view_states, and instance_states. More...
 
DomainParticipantget_participant ()
 This operation returns the DomainParticipant this Subscriber belongs to.
 
ReturnCode_t set_qos (const SubscriberQos &qos)
 Sets the SubscriberQos values. More...
 
ReturnCode_t get_qos (SubscriberQos &qos)
 Returns the current SubscriberQos settings held in the Subscriber s. More...
 
ReturnCode_t set_listener (SubscriberListener *a_listener, StatusMask mask)
 Installs a SubscriberListener on Subscriber s. More...
 
SubscriberListenerget_listener ()
 This operation returns the currently installed SubscriberListener. More...
 
ReturnCode_t begin_access ()
 This operation indicates that the application is about to access the data samples in any of the DataReader objects contained in the Subscriber s. More...
 
ReturnCode_t end_access ()
 This operation closes a corresponding Subscriber::begin_access().
 
ReturnCode_t set_default_datareader_qos (const DataReaderQos &qos)
 Sets the default DataReaderQos held in the Subscriber. More...
 
ReturnCode_t get_default_datareader_qos (DataReaderQos &qos)
 Provides access to the default DataReaderQos settings held in the Subscriber s. More...
 
ReturnCode_t copy_from_topic_qos (DataReaderQos &a_datareader_qos, const TopicQos &a_topic_qos)
 This operation copies the QoS settings in a_topic_qos to the corresponding settings in a_datareader_qos. More...
 
- Public Member Functions inherited from DDS::Entity
virtual StatusConditionget_statuscondition ()
 Gets the StatusCondition associated with this Entity. NOTE: The entity maintains ownership of the statuscondition, and it remains valid only as long as the Entity is valid. Destroying the Entity also destroys the status condition.
 

Detailed Description

The Subscriber configures, creates, manages and destroys DataReaders.

Member Function Documentation

ReturnCode_t DDS::Subscriber::begin_access ( )

This operation indicates that the application is about to access the data samples in any of the DataReader objects contained in the Subscriber s.

The application is expected to use this operation only if PRESENTATION QosPolicy of the Subscriber has the access_scope set to GROUP. [Otherwise this routine has no effect.]

ReturnCode_t DDS::Subscriber::copy_from_topic_qos ( DataReaderQos a_datareader_qos,
const TopicQos a_topic_qos 
)

This operation copies the QoS settings in a_topic_qos to the corresponding settings in a_datareader_qos.

The a_datareader_qos parameter is populated with a copy of the QoS policies from the a_topic_qos structure. QoS entries in the datareader qos structure will be overwritten with the values from the topic.

DataReader* DDS::Subscriber::create_datareader ( TopicDescription a_topic,
const DataReaderQos qos,
DataReaderListener a_listener,
StatusMask  mask 
)

This operation creates a DataReader.

The created DataReader is contained within the Subscriber s. It is associated with the Topic, ContentFilteredTopic, or MultiTopic indicated by a_topic, and has the DataReaderQos indicated by qos. The qos argument may be passed DATAREADER_QOS_DEFAULT, which indicates that the Subscriber should use its currently configured default data reader QoS values. The DataReaderListener a_listener, is installed at creation time.

The created DataReader (if not NULL) must be destroyed by a call to Subscriber::delete_datareader().

This routine will fail if the provided QoS settings are internally inconsistent. In this case, the routine will return NULL.

ReturnCode_t DDS::Subscriber::delete_contained_entities ( )

This operation deletes all the DataReaders created by means of the Subscriber::create_datareader() operation on the Subscriber s.

This routine will recursively call the corresponding delete_contained_entities() operation on each of the contained DataReader objects. If successful, this operation will recursively delete all objects contained with this Subscriber. After successful execution, the application may delete the Subscriber by calling DomainParticipant::delete_subscriber().

If any of the objects cannot be deleted, this routine will return RETCODE_PRECONDITION_NOT_MET.

ReturnCode_t DDS::Subscriber::delete_datareader ( class DataReader a_datareader)

This operation deletes a DataReader.

If the provided DataReader a_datareader was not created by Subscriber s, the routine will fail and will return RETCODE_PRECONDITION_NOT_MET. If the indicated DataReader has any outstanding ReadCondition or QueryCondition objects the routine will fail and will return RETCODE_PRECONDITION_NOT_MET. If the indicated DataReader has any outstanding 'loans' (from read() or take() operations), the routine will fail and will return RETCODE_PRECONDITION_NOT_MET.

ReturnCode_t DDS::Subscriber::enable ( )
virtual

Enables the Subscriber.

A Subscriber is created either enabled or not based on the DomainParticipantQos setting entity_factory. When a Subscriber is not enabled, only the following sub-set of all Subscriber operations are legal:

Any other Subscriber operation may return the NOT_ENABLED error. Subscriber::enable() may be called on an already enabled Subscriber [it will have no effect].

Reimplemented from DDS::Entity.

ReturnCode_t DDS::Subscriber::get_datareaders ( DataReaderSeq readers,
SampleStateMask  sample_states,
ViewStateMask  view_states,
InstanceStateMask  instance_states 
)

This operation allows the application to access 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 be invoked only inside a begin_access/end_access block. Otherwise it will return the error PRECONDITION_NOT_MET.

The returned collection of DataReader objects may either be a set (containing each DataReader at most once in no specified order), or a list (containing each DataReader one or more times in a specific order).

  1. If PRESENTATION access_scope is INSTANCE or TOPIC, the returned collection is a set.
  2. If PRESENTATION access_scope is GROUP and ordered_access is set to TRUE, then the returned collection is a list.

This difference supports alternate access mechanisms.

ReturnCode_t DDS::Subscriber::get_default_datareader_qos ( DataReaderQos qos)

Provides access to the default DataReaderQos settings held in the Subscriber s.

The provided qos argument is populated with the current default qos settings.

SubscriberListener* DDS::Subscriber::get_listener ( )

This operation returns the currently installed SubscriberListener.

Note
Because the infrastructure makes a copy of the listener provided in Subscriber::set_listener(), the returned structure pointer will not match the pointer originally provided. However, the function pointers within the structure will match. Also, the application should not free the data referenced by the returned pointer.
ReturnCode_t DDS::Subscriber::get_qos ( SubscriberQos qos)

Returns the current SubscriberQos settings held in the Subscriber s.

The qos parameter is populated with a copy of the current Subscriber QoS properties.

Note
The qos structure may contain sequences or strings that are populated with dynamic memory. The caller is responsible for freeing the dynamic memory of these items.
For example, the sequence 'qos->group_data' may have dynamically allocated memory assigned. This can be released by a call to seq_clear(&qos->group_data).
StatusMask DDS::Subscriber::get_status_changes ( )
virtual

This returns the list of triggered communication statuses in the Subscriber.

If the Subscriber is not enabled, all statuses will be untriggered. The list returned by get_status_changes may be empty. The list of statuses returned by get_status_changes operation contains statuses that are triggered on the Subscriber itself and does not include statuses from contained DataReader objects.

Implements DDS::Entity.

DataReader* DDS::Subscriber::lookup_datareader ( const char *  topic_name)

This operation retrieves a previously-created DataReader contained in the Subscriber, attached to a Topic named topic_name.

If multiple DataReaders are found, one of them will be returned. If no matching DataReader is found, this routine will return NULL.

This routine is useful to obtain access to a particular built-in DataReader.

ReturnCode_t DDS::Subscriber::set_default_datareader_qos ( const DataReaderQos qos)

Sets the default DataReaderQos held in the Subscriber.

This default qos will be used during subsequent calls to Subscriber::create_datareader() if the special DATAREADER_QOS_DEFAULT value is provided for qos.
This routine may fail if the provided qos argument is not internally consistent. In this case, INCONSISTENT_POLICY will be returned, and no changes will be made to the Subscriber.

ReturnCode_t DDS::Subscriber::set_listener ( SubscriberListener a_listener,
StatusMask  mask 
)

Installs a SubscriberListener on Subscriber s.

Only one listener may be attached to a Subscriber at a time. A call to set_listener() will replace any current listener with a_listener.

a_listener can be NULL, which indicates a listener that does nothing.

The infrastructure will make an internal copy of the listener structure so that it need not be persisted by the application.

ReturnCode_t DDS::Subscriber::set_qos ( const SubscriberQos qos)

Sets the SubscriberQos values.

These QoS values affect the behavior of the Subscriber.


© 2009-2017 Twin Oaks Computing, Inc
Castle Rock, CO 80108
All rights reserved.