![Abstract composition of orange triangles and scattered points on white background (no text or symbols)](.vortex-opensplice-streams-api-reference-guide/06dec6afe5725f62e7cf41c2e584e4b8c1e0816a6c87c3bd54200f8d5aa9fd86.jpg)

# VORTEX

# OPENSPLICE

# Streams API Reference Guide

# Release 6.x

# Contents

# 1 Preface 1

1.1 About The Vortex Streams API Reference Guide
1.2 Intended Audience
1.3 Organisation
1.4 Conventions

# 2 Introduction 3

2.1 Features . 3
2.2 Getting Started 3

# 3 API Reference 5

3.1 Introduction 5
3.2 QoS Policies 5
3.3 StreamDataWriter Class 6
3.4 StreamDataReader Class 10
3.5 FooStreamFilterCallback Interface . 16

# 4 Contacts & Notices 17

4.1 Contacts 17
4.2 Notices 17

# 1

# Preface

# 1.1 About The Vortex Streams API Reference Guide

The Vortex Streams API Reference Guide provides a detailed overview of the Vortex OpenSplice Streams API. The Streams API is an add-on, built on the Data Centric Public Subscribe (DCPS) paradigm that is implemented by Vortex OpenSplice and standardized in the OMG’s Data Distribution Service Specification.

This Guide complements the Vortex OpenSplice C++ Reference Guide.

# 1.2 Intended Audience

The Streams API Reference Guide is intended to be used by C++ programmers who are using the OpenSplice Streams API to develop applications. While not strictly required, it is assumed that the reader has a basic understanding of the DDS C++ API as detailed in the Vortex OpenSplice C++ Reference Guide.

# 1.3 Organisation

This Guide is organised in two parts.

The Introduction provides some background information about the features of the Streams API and how to use them. It also gives a broad overview of all entities and relations between entities in the Streams API.

The API Reference provides detailed descriptions of all of the classes and operations of the Streams API.

# 1.4 Conventions

The icons shown below are used in ADLINK product documentation to help readers to quickly identify information relevant to their specific use of Vortex OpenSplice.

<table><tr><td>Icon</td><td>Meaning</td></tr><tr><td>&lt;img src="images/2a05f87a4292bfecb242bff603249f384f86fc8d046326ed5c2af664e82a5224.jpg"/&gt;</td><td>Item of special significance or where caution needs to be taken.</td></tr><tr><td>&lt;img src="images/2f8a03184f07ba6929c0610d462b5baa13e1b03d87dee3b76889cd5a2761eb27.jpg"/&gt;</td><td>Item contains helpful hint or special information.</td></tr><tr><td>&lt;img src="images/4fe2b4a96e5a4b452bc5568d6f3865119632a2c2edabd550e9a06ba0786d19b9.jpg"/&gt;</td><td>Information applies to Windows (e.g. XP, 2003, Windows 7) only.</td></tr><tr><td>&lt;img src="images/d49e0d6b73988cff221027da5cd9beb3a26afc33ca172d9bb314798958ce59e7.jpg"/&gt;</td><td>Information applies to Unix-based systems (e.g. Solaris) only.</td></tr><tr><td>&lt;img src="images/8900901b866cfe9cfcd7831571589bc731bf0d8c1bc097997ff86d32e54d94ff.jpg"/&gt;</td><td>Information applies to Linux-based systems (e.g. Ubuntu) only.</td></tr><tr><td>&lt;img src="images/8722f419d393c3bbb0a636f2f9be25626b1ff366bae29885cce82fe83d6c1e42.jpg"/&gt;</td><td>C language specific.</td></tr><tr><td>&lt;img src="images/5187ea8199f4587188507201b111cab32a79fe7de38664ea33120658de893b1d.jpg"/&gt;</td><td>C++ language specific.</td></tr><tr><td>&lt;img src="images/0388ee0b2ce3ef57acafdcc66c22e17bfdd93ab5193748ca350639f6a130cba1.jpg"/&gt;</td><td>C# language specific.</td></tr><tr><td>&lt;img src="images/16f7797247fe2ad4c3e888f65321777b2aaf2ae21b5f4149dd3385a6356449ea.jpg"/&gt;</td><td>Java language specific.</td></tr></table>

# 2

# Introduction

# 2.1 Features

Vortex OpenSplice Streams API supports a common data-distribution pattern where continuous flows or streams of data have to be transported with minimal overhead and therefore maximal achievable throughput.

Vortex OpenSplice Streams API implements this streams pattern by transparent packing and queuing of data samples using auto-generated containers, thus minimizing the overhead normally associated with the management and distribution of individual DDS samples.

# 2.2 Getting Started

The Vortex OpenSplice Streams API is divided in two main components:

• type-specific code that can be generated using the Vortex OpenSplice IDL Pre-Processor
• a Streams library.

Applications that wish to use the Streams API are required to do two things:

1. Link against one of the Vortex OpenSplice Streams libraries available within the Vortex OpenSplice distribution. There are separate libraries for either CORBA-Cohabitation mode or Standalone C++ mode.
2. Annotate the data-model IDL file with #pragma stream directives for each data type for which a Stream needs to be created.

The Vortex OpenSplice Streams API is built on the DCPS API. Since the C++ bindings of Vortex OpenSplice are available in two flavours, so is the Streams API. In the following paragraphs the steps will be discussed to build a simple application that uses the following data-model:

```c
Space.idl:
module Space {
    struct Foo {
    long long_1;
    long long_2;
    };
    #pragma stream Foo
    struct Type2 {
    long long_1;
    long long_2;
    long long_3;
    };
    #pragma stream Type2
    #pragma keylist Type2 long_1
};
```

Using this model, both Foo and Type2 can be used with the Streams API. In addition Type2 can also be used as a regular DDS topic, with long\_1 as key.

The following relevant Streams API classes are generated based on this model for Foo:

```autohotkey
Space::FooStreamDataWriter
Space::FooStreamDataReader
Space::FooStreamBuf
```

It is recommended to use smart references to the StreamDataWriter and StreamDataReader classes in applications. The regular Vortex OpenSplice C++ smart-pointer &lt;class&gt;\_var types are available for this purpose. See the section on Memory Management in the Vortex OpenSplice C++ Reference Guide for more information.

# 2.2.1 CORBA Cohabitation Mode

In CORBA Co-habitation mode, idlpp generates code that can be processed with any of the supported ORB compilers (OpenFusion TAO, Mico, etc.).

First idlpp is executed on the Space.idl file:

```powershell
$ idlpp -I$OSPL_HOME/etc/idl -l cpp -C Space.idl
```

The standard Vortex OpenSplice IDL directory is referenced as include-path, since it contains definitions of some basic data-types and interfaces that are required if DDS Topics are created for any of the types in the IDL file. The other parameters are used to put idlpp in C++ CORBA-Cohabitation mode.

As usual when DDS topics are created, the above command generates, among other files, a file called SpaceDcps.idl. The file SpaceStreams.idl is also generated.

To proceed, idlpp should be executed on the ExampleStreams.idl file:

```powershell
$ idlpp -I$OSPL_HOME/etc/idl -l cpp -C SpaceStreams.idl
```

This creates the descriptions of the DCPS entities that are required to manage the DDS topics that will be used for the Streams types, just like with the original IDL file, in a file called SpaceStreamsDcps.idl.

Now all four IDL files should be processed with the appropriate (ORB-specific) CORBA IDL processor. After this step all code and header files are generated to start using the Streams API in application code.

# 2.2.2 Standalone Mode

In Standalone C++ mode, the generated interfaces are not required to be processed by an IDL compiler. Instead, idlpp will use the cppgen code-generator that is part of the Vortex OpenSplice distribution. idlpp will automatically call cppgen to process certain files; the user is only required to execute idlpp, first on the original IDL file:

```powershell
$ idlpp -I$OSPL_HOME/etc/idl -l cpp -S Space.idl
```

This creates SpaceStreams.idl, which in turn also needs to be processed by idlpp:

```powershell
$ idlpp -I$OSPL_HOME/etc/idl -l cpp -S -i SpaceStreams.idl
```

The -i parameter is required because normally no code is generated for interfaces (for DDS topics, only datatypes are generated). In the case of streams, interfaces should not be ignored.

# 3

# API Reference

# 3.1 Introduction

As described in :ref:‘Getting Started &lt;Getting Started&gt;‘, the Vortex OpenSplice IDL preprocessor generates typed Streams API classes for each type that is annotated with a streams pragma.

As in the Vortex OpenSplice C++ Reference Guide, the fictional type Foo, defined in module Space, is used as an example. When the Foo type is annotated with a pragma streams, FooStreamDataWriter and FooStreamDataReader classes will be generated.

This section describes the usage of all operations on these classes.

# 3.2 QoS Policies

<table><tr><td>StreamDataWriterQos</td><td>StreamDataReaderQos</td></tr><tr><td>StreamFlushQosPolicy</td><td></td></tr></table>

<table><tr><td>StreamFlushQosPolicy</td><td>Type</td><td>Default value</td></tr><tr><td>max_delay</td><td>DDS::Duration_t</td><td>DDS::DURATION_INFINITE</td></tr><tr><td>max_samples</td><td>long</td><td>0</td></tr></table>

# 3.2.1 StreamDataWriterQos

# StreamFlushQosPolicy

# Scope

DDS::Streams

# Synopsis

```c
#include &lt;streams_ccpp.h&gt;

struct StreamFlushQosPolicy {
    Duration_t max_delay;
    long max_samples;
};
```

# Description

The StreamFlushQosPolicy can be used to set limits on the stream(s) of the StreamDataWriter it is applied to.

# Attributes

Duration\_t max\_delay Time-based limit. The StreamDataWriter will automatically flush all of its streams each max\_delay period.

![The image displays a standard warning sign in the shape of an equilateral triangle with a thick red border and a white interior. Centered inside the triangle is a black exclamation mark.](.vortex-opensplice-streams-api-reference-guide/4b63a5386fa0d7494f53f803d811287c953f18c6f7016f88ac608e6e82e9b1be.jpg)

Note: max\_delay is not yet implemented. It is scheduled for a future release.

long max\_samples Samples-per-stream based limit. The StreamDataWriter will automatically flush a stream when, after appending a sample, the number of samples in that stream equals max\_samples.

# Detailed Description

By setting the StreamFlushQosPolicy, the StreamDataWriter will automatically flush its stream(s) based on a particular limit. The attributes can be combined, for example a max\_delay of 1 second and a max\_samples of 100 will result in a flush at least each second or sooner if 100 samples are appended to a stream.

The max\_delay limit applies to all streams in case a StreamDataWriter manages more than one stream. It is initialized when the first stream is created, and applied to all streams created after that.

In case of a manual flush (when the application calls the flush operation), the max\_samples limit is reinitialized.

# StreamDataReaderQos

Currently no QoS properties for a StreamDataReader have been identified, but the StreamDataReaderQos is defined in the API to maintain consistency with the StreamDataWriter; it is reserved for future use.

# 3.3 StreamDataWriter Class

# 3.3.1 Constructors

Scope
```autohotkey
Space::FooStreamDataWriter
```
Synopsis

```c
#include &lt;SpaceStreamsApi.h&gt;

ooStreamDataWriter(
    DDS::Publisher_ptr publisher,
    DDS::Streams::StreamDataWriterQos &sqos,
    const char* streamName);

FooStreamDataWriter(
    DDS::DomainId_t domainId,
    DDS::Streams::StreamDataWriterQos &sqos,
    const char* streamName);

FooStreamDataWriter(
    DDS::Streams::StreamDataWriterQos &sqos,
    const char* streamName);

FooStreamDataWriter(
    DDS::Publisher_ptr publisher,
    const char* streamName);

FooStreamDataWriter(
    DDS::DomainId_t domainId,
    const char* streamName);
```

# Description

# 3.3. StreamDataWriter Class

Multiple constructors are available to create a FooStreamDataWriter. Depending on which parameters are supplied by the application, one of the overloaded constructors will be selected to create a new instance of the FooStreamDataWriter class.

# Parameters

in DDS::Publisher\_ptr publisher A pointer to a pre-created DDS Publisher. This parameter is optional; if a publisher is not supplied the FooStreamDataWriter will create an internal publisher.
in DDS::DomainId\_t domainId The id of the DDS domain to attach to. The DDS::DOMAIN\_ID\_DEFAULT macro can be used to connect to the default domain, which is also used if the parameter is omitted.
in DDS::Streams::StreamDataWriterQos &sqos The QoS settings that are applied to the FooStreamDataWriter.
in const char\* streamName The system-wide unique name of the stream that is used to create a DDS (container-)topic for the stream(s) that are handled by the FooStreamDataWriter.

# Exceptions

Constructors cannot return a value, therefore they throw exceptions when the object cannot be constructed. Besides exceptions, the regular Vortex OpenSplice error logging framework is used to report additional information when a constructor fails.

The constructors throw a StreamsException if an error occurs. The application may catch these exceptions to detect when creation of a StreamDataWriter doesn’t succeed.

```rust
DDS::Streams::StreamException {
    out const char *message;
    out DDS::ReturnCode_t id
}
```

The message contains a description of the error. The id field contains a DDS error code that represents the error condition.

# Detailed Description

When a pre-created publisher is not supplied, the FooStreamDataWriter will create an internal DDS participant and DDS publisher. This will naturally consume some resources, so when a lot of streams need to be created it is recommended to supply a publisher that can be re-used for each FooStreamDataWriter instance.

The streamName is a required parameter. The FooStreamDataWriter will create a DDS topic of the correct type and name it after the supplied streamName.

# 3.3.2 append

# Scope

Space::FooStreamDataWriter

# Synopsis

```cpp
#include &lt;SpaceStreamsApi.h&gt;

DDS::ReturnCode_t
append(
    StreamId id,
    const Foo &data)
```

# Description

Write a sample to the stream with the supplied id.

# 3.3. StreamDataWriter Class

# Parameters

in StreamId id The stream id.

in Foo &data The data to write to the stream.

# Return Value

ReturnCode\_t Possible return codes of the operation are: DDS::RETCODE\_OK, DDS::RETCODE\_PRECONDITION\_NOT\_MET.

# Detailed Description

Using the append operation, the application can write data to a stream. Note that for each stream of a certain type, multiple instances of this stream-type can be created by assigning unique ids to each of streams. Each id then represents an instance of the stream of the associated type. So the actual stream instance is selected based on the supplied StreamId.

When the stream doesn’t exist it is automatically created based on the current QoS settings.

# Return Code

When the operation returns:

RETCODE\_OK The data was successfully appended to the stream.

RETCODE\_PRECONDITION\_NOT\_MET A precondition failed, data was not appended.

If the StreamDataWriter QoS specifies an auto-flush maximum samples limit, an append may trigger a flush. In that case the append call forwards the return code of the flush to the application, so any return code that is specified in the next section may also be returned by append.

# 3.3.3 flush

# Scope

Space::FooStreamDataWriter

# Synopsis

```cpp
#include &lt;SpaceStreamsApi.h&gt;
DDS::ReturnCode_t
flush(
    DDS::Streams::StreamId id)
```

# Description

Write all data in a stream to the DDS subsystem.

# Parameters

in StreamId id The id of the stream.

# Return Value

ReturnCode\_t Possible return codes of the operation are: DDS::RETCODE\_OK, DDS::RETCODE\_PRECONDITION\_NOT\_MET.

# Detailed Description

When a stream is flushed, all data in the stream is delivered to DDS and the stream is emptied. The memory allocated will be reused the next time data is appended to the stream.

The flush operation results in a write call on the underlying DDS subsystem. Depending on the result of the write, this result is returned back to the application.

# Return Code

RETCODE\_OK The stream was successfully flushed.

# 3.3. StreamDataWriter Class

RETCODE\_PRECONDITION\_NOT\_MET A precondition failed; most likely the stream doesn’t exist.

See the Vortex OpenSplice C++ Reference Guide for possible result codes returned by a DDS write operation.

# 3.3.4 get\_qos

Scope
```autohotkey
Space::FooStreamDataWriter
```
Synopsis

```cpp
#include &lt;SpaceStreamsApi.h&gt;

DDS::ReturnCode_t
get_qos(
    DDS::Streams::StreamDataWriterQos &qos)
```

# Description

This operation allows access to the existing set of QoS policies for a FooStreamDataWriter.

Parameters

inout StreamDataWriterQos &qos A pointer to a StreamDatatWriterQos object to which the current QoS settings will be copied.

Return Value

ReturnCode\_t Possible return code of the operation is: DDS::RETCODE\_OK.

Detailed Description

The existing list of QoS settings of the FooStreamDataWriter is copied to the object pointed to by qos. The application can then inspect and, if necessary, modify the settings and apply the settings using the set\_qos operation.

Return Code

RETCODE\_OK The QoS settings were successfully copied to the supplied qos object.

# 3.3.5 set\_qos

Scope
```autohotkey
Space::FooStreamDataWriter
```

Synopsis
```cpp
#include &lt;SpaceStreamsApi.h&gt;

DDS::ReturnCode_t
set_qos(
    DDS::Streams::StreamDataWriterQos &qos)
```

# Description

This operation allows replacing the existing set of QoS policies for a FooStreamDataWriter.

Parameters

in StreamDataWriterQos &qos A pointer to a qos object with the new policies.

Return Value

# 3.3. StreamDataWriter Class

ReturnCode\_t Possible return codes of the operation are: DDS::RETCODE\_OK, DDS::RETCODE\_UNSUPPORTED.

# Detailed Description

This operation allows replacing the set of QoS policies of a FooStreamDataWriter.

![The image displays a triangular warning sign featuring a thick red border and a white interior. In the center is a black exclamation mark.](.vortex-opensplice-streams-api-reference-guide/4c565bc875b26550a605dd295c976c69a1f490da58353d6199a92327b7987e9b.jpg)

Note: A new StreamFlushQosPolicy may decrease the value of max\_samples, but ting streams are not allowed to violate this limit. Any streams that contain data that exceeds the max\_samples value are automatically flushed before the new policy is applied.

# Return Code

RETCODE\_OK The QoS settings were successfully applied to the FooStreamDataWriter.

RETCODE\_UNSUPPORTED The application attempted to set QoS policies or values that are not (yet) supported.

# 3.4 StreamDataReader Class

# 3.4.1 Constructors

# Scope

Space::FooStreamDataReader

# Synopsis

```cpp
#include &lt;SpaceStreamsApi.h&gt;

FooStreamDataReader(
    DDS::Subscriber_ptr subscriber,
    DDS::Streams::StreamDataReaderQos &sqos,
    const char* streamName);

FooStreamDataReader(
    DDS::DomainId_t domainId,
    DDS::Streams::StreamDataReaderQos &sqos,
    const char* streamName);

FooStreamDataReader(
    DDS::Streams::StreamDataReaderQos &sqos,
    const char* streamName);

FooStreamDataReader(
    DDS::Subscriber_ptr subscriber,
    const char* streamName);

FooStreamDataReader(
    DDS::DomainId_t domainId,
    const char* streamName);
```

# Description

Multiple constructors are available to create a FooStreamDataReader. Depending on which parameters are supplied by the application, one of the overloaded constructors will be selected to create a new instance of a FooStreamDataReader class.

# Parameters

in DDS::Subscriber\_ptr subscriber A pointer to a pre-created DDS Subscriber. This parameter is optional; if a subscriber is not supplied the FooStreamDataReader will create an internal subscriber.

# 3.4. StreamDataReader Class

in DDS::DomainId\_t domainId The id of the DDS domain to attach to. The DDS::DOMAIN\_ID\_DEFAULT macro can be used to connect to the default domain, which is also used if the parameter is omitted.

in DDS::Streams::StreamDataReaderQos &sqos The QoS settings that are applied to the FooStreamDataReader.

in const char\* streamName The system-wide unique name of the stream which is also used to create a DDS (container-)topic for the stream(s) that are handled by the FooStreamDataReader.

# Exceptions

Constructors cannot return a value, therefore they throw exceptions when the object cannot be constructed. Besides exceptions, the regular Vortex OpenSplice error logging framework is used to report additional information when a constructor fails.

The constructors throw a StreamsException if an error occurs. The application may catch these exceptions to detect when creation of a StreamDataReader doesn’t succeed.

```rust
DDS::Streams::StreamException {
    out const char *message;
    out DDS::ReturnCode_t id
}
```

The message contains a description of the error. The id field contains a DDS error code that represents the error condition.

# Detailed Description

When a pre-created subscriber is not supplied, the FooStreamDataReader will create an internal DDS participant and DDS subscriber. This will naturally consume some resources, so when a lot of instances need to be created it is recommended to supply a subscriber that can be re-used for each FooStreamDataReader instance.

The streamName is a required parameter. The FooStreamDataReader will create a DDS topic of the correct type and name it after the supplied streamName.

# 3.4.2 get

# Scope

Space::FooStreamDataReader

# Synopsis

```cpp
#include &lt;SpaceStreamsApi.h&gt;

DDS::ReturnCode_t
get(
    DDS::Streams::StreamId id,
    Space::FooStreamBuf data_values,
    long max_samples,
    DDS::Duration_t timeout);
```

# Description

Check if any data is available in a stream and retrieve it, emptying the stream.

# Parameters

in StreamId id The id of the stream instance from which to retrieve the data.

inout FooStreamBuf data\_values The buffer in which the data is stored.

in long max\_samples The maximum amount of data samples retrieved. Default is DDS::LENGTH\_UNLIMITED.

# 3.4. StreamDataReader Class

in Duration\_t timeout Blocking time, in case no data is immediately available.

# Return Value

ReturnCode\_t Possible return codes of the operation are: DDS::RETCODE\_OK, DDS::RETCODE\_PRECONDITION\_NOT\_MET.

# Detailed Description

Using the get operation, the application can retrieve data from a stream. The stream is selected based on the supplied StreamId.

If no data is available initially, the get operation blocks for a maximum period specified in the timeout parameter. If data becomes available during the timeout period the FooStreamDataReader proceeds to retrieve the data and return it to the application. To return immediately, the application can use the special value DDS::DURATION\_ZERO as a timeout parameter. To block indefinitely until data is available, the value DDS::DURATION\_INFINITE should be passed.

The data is returned in a buffer that is to be supplied by the application. The application is responsible for allocating a buffer that is large enough to contain the available data. If more data is available than will fit in the buffer, the excess data will be stored by the StreamDataReader and returned to the application during the next call to get (or get\_w\_filter). In this state, the StreamDataReader will only attempt to retrieve new data after all data that was stored internally is returned to the application.

Since allocating memory for the buffer is an expensive operation, it is recommended to re-use the same buffer for each subsequent call to get or get\_w\_filter. The max\_samples parameter can be used to limit the amount of data that is returned with each get or get\_w\_filter call.

Note: Internal pre-allocation of buffers, using a loans registry similar to the DCPS API, will be implemented in a future version.

# Return Code

DDS::RETCODE\_OK Data is returned in the data\_values buffer.

DDS::RETCODE\_NO\_DATA There is currently no data available.

DDS::RETCODE\_PRECONDITION\_NOT\_MET The operation could not be performed because a precondition is not met; most likely the data\_values buffer is not preallocated.

The list of possible return codes includes all possible return codes of waitset.wait() and take\_instance() calls. These DCPS calls are used internally by the Streams API. There is one exception: if the waitset.wait() returns a DDS::RETCODE\_TIMEOUT, this return code is translated to a DDS::RETCODE\_NO\_DATA return code.

See the Vortex OpenSplice C++ Reference Guide for possible result codes returned by a DDS take\_instance operation and for waitset.wait().

# 3.4.3 get\_w\_filter

# Scope

Space::FooStreamDataReader

# Synopsis

```cpp
#include &lt;SpaceStreamsApi.h&gt;

DDS::ReturnCode_t
get_w_filter(
    DDS::Streams::StreamId id,
    Space::FooStreamBuf data_values,
    long max_samples,
```

# 3.4. StreamDataReader Class

```txt
DDS::Duration_t timeout
Space::FooStreamFilterCallback a_filter);
```

# Description

Check if any data is available in a stream and retrieve it if it matches the filter, discard otherwise.

# Parameters

in StreamId id The id of the stream instance of which to retrieve the data.

inout FooStreamBuf data\_values The buffer in which the data is stored.

in long max\_samples The maximum amount of data samples retrieved.

in Duration\_t timeout Blocking time, in case no data is immediately available.

in FooStreamFilterCallback a\_filter Pointer to a function that implements a filter for the data.

# Return Value

```txt
ReturnCode_t Possible return codes of the operation are: DDS::RETCODE_OK, DDS::RETCODE_PRECONDITION_NOT_MET.
```

# Detailed Description

The get\_w\_filter operation is equivalent to the get operation, the description of get also applies to get\_w\_filter.

The difference is that get\_w\_filter allows the application to supply a FooStreamFilterCallback instance that implements the match\_data() operation. Each data sample is matched against the filter and only data for which the filter returns true is returned to the application.

Samples that do not match the filter are not considered in relation to max\_samples and the data\_values buffer length; the buffer does not need to be capable of holding all available samples, just the samples that pass the filter.

Samples are only evaluated once and are discarded if not matched.

# Return Code

DDS::RETCODE\_OK Data is returned in the data\_values buffer.

DDS::RETCODE\_NO\_DATA There is no data available during the period specified by timeout.

DDS::RETCODE\_PRECONDITION\_NOT\_MET The operation could not be performed because a precondition is not met; most likely the data\_values buffer is not preallocated.

The list of possible return codes includes all possible return codes of waitset.wait() and take\_instance() calls. These DCPS calls are used internally by the Streams API. There’s one exception: If the waitset.wait() returns a DDS::RETCODE\_TIMEOUT, this return code is translated to a DDS::RETCODE\_NO\_DATA return code.

See the Vortex OpenSplice C++ Reference Guide for possible result codes returned by a DDS take\_instance operation and waitset.wait().

# 3.4.4 return\_loan

Scope

```autohotkey
Space::FooStreamDataReader
```

Synopsis

```cpp
#include &lt;SpaceStreamsApi.h&gt;

DDS::ReturnCode_t
return_loan(
    Space::FooStreamBuf data_values)
```

# Description

The application should use this operation to indicate that it has finished accessing the sequence of data\_values.

# Parameters

inout FooStreamBuf data\_values The data sequence which was loaned from the FooStreamDataReader.

# Return Value

ReturnCode\_t Possible return codes of the operation are: DDS::RETCODE\_OK, DDS::RETCODE\_PRECONDITION\_NOT\_MET.

# Detailed Description

When the application does not pre-allocate a buffer to hold the data, the FooStreamDataReader will do so itself when a get operation is invoked. The application calls return\_loan to indicate that it has finished accessing this buffer so the FooStreamDataReader can reclaim the resources allocated for the buffer.

Note: Internal pre-allocation will be implemented in a future release. This operation has no effect on buffers allocated by the application.

# 3.4.5 get\_qos

# Scope

Space::FooStreamDataReader

# Synopsis

```cpp
#include &lt;SpaceStreamsApi.h&gt;

DDS::ReturnCode_t
get_qos(
    DDS::Streams::StreamDataReaderQos &qos)
```

# Description

This operation allows access to the existing set of QoS policies for a FooStreamDataReader.

# Parameters

inout StreamDataReaderQos &qos A pointer to a StreamDataReaderQos object to which the current QoS settings will be copied.

# Return Value

ReturnCode\_t Possible return code of the operation is: DDS::RETCODE\_OK.

# Detailed Description

The existing list of QoS settings of the FooStreamDataReader is copied to the object pointed to by qos. The application can then inspect and, if necessary, modify the settings and apply the settings using the set\_qos operation.

# Return Code

RETCODE\_OK The QoS settings were successfully copied to the supplied qos object.

# 3.4. StreamDataReader Class

# 3.4.6 set\_qos

# Scope

```autohotkey
Space::FooStreamDataReader
```

# Synopsis

```cpp
#include &lt;SpaceStreamsApi.h&gt;

DDS::ReturnCode_t
set_qos(
    DDS::Streams::StreamDataReaderQos &qos)
```

# Description

This operation allows replacing the existing set of QoS policies for a FooStreamDataReader.

# Parameters

in StreamDataReaderQos &qos A pointer to a qos object with the new policies.

# Return Value

```txt
ReturnCode_t Possible return codes of the operation are: DDS::RETCODE_OK, DDS::RETCODE_UNSUPPORTED.
```

# Detailed Description

This operation allows replacing the set of QoS policies of a FooStreamDataReader.

# Return Code

RETCODE\_OK The QoS settings were successfully applied to the FooStreamDataWriter.

RETCODE\_UNSUPPORTED The application attempted to set QoS policies or values that are not (yet) supported.

# 3.4.7 interrupt

# Scope

```autohotkey
Space::FooStreamDataReader
```

# Synopsis

```cpp
#include &lt;SpaceStreamsApi.h&gt;
DDS::ReturnCode_t
interrupt();
```

# Description

Interrupt a blocking get operation from a different thread.

# Return Value

```txt
ReturnCode_t Possible return codes of the operation are: DDS::RETCODE_OK, DDS::RETCODE_ERROR.
```

# Detailed Description

The get operation accepts a timeout parameter which causes the FooStreamDataReader to block until data becomes available. It can block indefinitely when an infinite timeout is supplied and data never becomes available because there are simply no compatible writers.

In such cases it can be desirable to interrupt the get operation from the application, i.e. for termination or reclaiming of resources.

# 3.4. StreamDataReader Class

The interrupt call triggers an internal GuardCondition by calling DDS::GuardCondition::set\_trigger\_value(true). This causes the get operation to return with a DDS::RETCODE\_NO\_DATA result.

# Return Code

The return code of this operation is determined by the result of DDS::GuardCondition::set\_trigger\_value()

DDS::RETCODE\_OK The GuardCondition was triggered successfully

DDS::RETCODE\_ERROR An internal error occurred

# 3.5 FooStreamFilterCallback Interface

# Scope

Space::FooStreamDataReader

# Synopsis

```cpp
#include &lt;SpaceStreamsApi.h&gt;
boolean
a_filter(
    const Space::Foo &data)
```

# Description

Function interface for filters that are passed to the get\_w\_filter and/or peek\_w\_filter operations.

# Parameters

in const Foo &data A data sample.

# Return Value

boolean Return true if the supplied data matches, false if it doesn’t match.

# Detailed Description

The application can supply any function that adheres to the FooStreamFilterCallback interface, to filter data that is retrieved by the get\_w\_filter operation. If the data matches the filter, the function returns true and the data is added to the data\_values buffer that is returned by the get\_w\_filter operation. Data that doesn’t match the filter is discarded.

# 4

# Contacts & Notices

# 4.1 Contacts

# ADLINK Technology Corporation

400 TradeCenter

Suite 5900

Woburn, MA

01801

USA

Tel: +1 781 569 5819

# ADLINK Technology Limited

The Edge

5th Avenue

Team Valley

Gateshead

NE11 0XA

UK

Tel: +44 (0)191 497 9900

# ADLINK Technology SARL

28 rue Jean Rostand

91400 Orsay

France

Tel: +33 (1) 69 015354

Web: http://ist.adlinktech.com/

Contact: http://ist.adlinktech.com

E-mail: ist\_info@adlinktech.com

LinkedIn: https://www.linkedin.com/company/79111/

Twitter: https://twitter.com/ADLINKTech\_usa

Facebook: https://www.facebook.com/ADLINKTECH

# 4.2 Notices

Copyright © 2018 ADLINK Technology Limited. All rights reserved.

This document may be reproduced in whole but not in part. The information contained in this document is subject to change without notice and is made available in good faith without liability on the part of ADLINK Technology Limited. All trademarks acknowledged.
[🔗 Link to the original document](.vortex-opensplice-streams-api-reference-guide/vortex-opensplice-streams-api-reference-guide.pdf)
