RTI Connext C# API  6.1.2
LoanedSample< T > Class Template Reference

Contains the data and the information associated with a sample, which are only valid until their LoanedSamples<T> container is Disposed More...

Public Member Functions

void Deconstruct (out T data, out SampleInfo info)
 Allows deconstructing a LoanedSample into a tuple with the data and the info. More...
 
override string ToString ()
 Returns Data.ToString() when Info.ValidData is true; otherwise it returns a readable summary of the Info. More...
 

Properties

Data [get]
 Gets the data More...
 
SampleInfo Info [get]
 Gets the information about this sample More...
 

Detailed Description

Contains the data and the information associated with a sample, which are only valid until their LoanedSamples<T> container is Disposed

Any reference contained within a LoanedSample is only valid until the corresponding LoanedSamples<T> has been Disposed. Attempting to access any data within the sample after that is undefined behavior.

Template Parameters
TThe topic type of the data

Member Function Documentation

◆ Deconstruct()

void Deconstruct ( out T  data,
out SampleInfo  info 
)

Allows deconstructing a LoanedSample into a tuple with the data and the info.

Parameters
dataOutput parameter assigned this.Data
infoOutput parameter assigned this.Info

For example:

using var samples = reader.Take();
foreach (var (data, info) in samples)
{
if (info.ValidData)
{
Console.WriteLine(data);
}
}

◆ ToString()

override string ToString ( )

Returns Data.ToString() when Info.ValidData is true; otherwise it returns a readable summary of the Info.

Property Documentation

◆ Data

T Data
get

Gets the data

◆ Info

SampleInfo Info
get

Gets the information about this sample