OpenSplice Java 5 DCPS  v6.x
OpenSplice Java 5 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
org.opensplice.dds.sub.SampleImpl< TYPE > Class Template Reference
Inheritance diagram for org.opensplice.dds.sub.SampleImpl< TYPE >:
Inheritance graph
Collaboration diagram for org.opensplice.dds.sub.SampleImpl< TYPE >:
Collaboration graph

Public Member Functions

 SampleImpl (OsplServiceEnvironment environment, TYPE data, DDS.SampleInfo info)
 
SampleImpl< TYPE > clone ()
 
int getAbsoluteGenerationRank ()
 The sampleRank and generationRank available in the Sample are computed based solely on the actual samples in the ordered collection returned by org.omg.dds.sub.DataReader#read() or org.omg.dds.sub.DataReader#take(). More...
 
TYPE getData ()
 Get the data associated with this Sample, if any. More...
 
int getDisposedGenerationCount ()
 For each instance the middleware internally maintains two counts: the disposedGenerationCount and noWritersGenerationCount, relative to each org.omg.dds.sub.DataReader: More...
 
ServiceEnvironment getEnvironment ()
 
int getGenerationRank ()
 The sampleRank and generationRank available in the Sample are computed based solely on the actual samples in the ordered collection returned by org.omg.dds.sub.DataReader#read() or org.omg.dds.sub.DataReader#take(). More...
 
DDS.SampleInfo getInfo ()
 
InstanceHandle getInstanceHandle ()
 Gets the InstanceHandle of the associated data Sample. More...
 
InstanceState getInstanceState ()
 For each instance the middleware internally maintains an instanceState. More...
 
TYPE getKeyValue ()
 
int getNoWritersGenerationCount ()
 For each instance the middleware internally maintains two counts: the disposedGenerationCount and noWritersGenerationCount, relative to each org.omg.dds.sub.DataReader: More...
 
InstanceHandle getPublicationHandle ()
 Gets the InstanceHandle of the associated publication. More...
 
int getSampleRank ()
 The sampleRank and generationRank available in the Sample are computed based solely on the actual samples in the ordered collection returned by org.omg.dds.sub.DataReader#read() or org.omg.dds.sub.DataReader#take(). More...
 
SampleState getSampleState ()
 For each sample received, the middleware internally maintains a sampleState relative to each org.omg.dds.sub.DataReader. More...
 
Time getSourceTimestamp ()
 Gets the timestamp of the sample. More...
 
ViewState getViewState ()
 For each instance (identified by the key), the middleware internally maintains a viewState relative to each org.omg.dds.sub.DataReader More...
 
void setContent (TYPE data, DDS.SampleInfo info)
 
void setData (TYPE data)
 
void setInfo (DDS.SampleInfo info)
 

Detailed Description

Definition at line 34 of file SampleImpl.java.

Constructor & Destructor Documentation

◆ SampleImpl()

org.opensplice.dds.sub.SampleImpl< TYPE >.SampleImpl ( OsplServiceEnvironment  environment,
TYPE  data,
DDS.SampleInfo  info 
)

Definition at line 40 of file SampleImpl.java.

Member Function Documentation

◆ clone()

Implements org.omg.dds.sub.Sample< TYPE >.

Definition at line 143 of file SampleImpl.java.

◆ getAbsoluteGenerationRank()

int org.opensplice.dds.sub.SampleImpl< TYPE >.getAbsoluteGenerationRank ( )

The sampleRank and generationRank available in the Sample are computed based solely on the actual samples in the ordered collection returned by org.omg.dds.sub.DataReader#read() or org.omg.dds.sub.DataReader#take().

  • The sampleRank indicates the number of samples of the same instance that follow the current one in the collection.
  • The generationRank available in the Sample indicates the difference in 'generations' between the sample (S) and the Most Recent Sample of the same instance that appears In the returned Collection (MRSIC). That is, it counts the number of times the instance transitioned from not-alive to alive in the time from the reception of S to the reception of MRSIC.

The absoluteGenerationRank available in the Sample indicates the difference in 'generations' between the sample (S) and the Most Recent Sample of the same instance that the middleware has received (MRS). That is, it counts the number of times the instance transitioned from not-alive to alive in the time from the reception of S to the time when org.omg.dds.sub.DataReader#read() or org.omg.dds.sub.DataReader#take() was called.

absoluteGenerationRank = (MRS.disposedGenerationCount

Implements org.omg.dds.sub.Sample< TYPE >.

Definition at line 138 of file SampleImpl.java.

◆ getData()

TYPE org.opensplice.dds.sub.SampleImpl< TYPE >.getData ( )

Get the data associated with this Sample, if any.

Normally each Sample contains both meta-data ("Sample Info") and some data. However there are situations where a Sample contains only the Sample Info and does not have any associated data. This occurs when the Service notifies the application of a change of state for an instance that was caused by some internal mechanism (such as a timeout) for which there is no associated data. An example of this situation is when the Service detects that an instance has no writers and changes the corresponding instanceState to org.omg.dds.sub.InstanceState#NOT_ALIVE_NO_WRITERS.

The actual set of scenarios under which the middleware returns Samples containing no data is implementation dependent. The application can distinguish whether a particular Sample has data by examining the value returned by this method. If the result is not null, then the Sample contains valid data. If it is null, the Sample contains no data.

To ensure correctness and portability, the application must check for a null result from this method prior to using it. If the data is null, the application should access only the Sample Info.

Returns
the data associated with this sample. This method will return null if this sample contains no valid data.

Implements org.omg.dds.sub.Sample< TYPE >.

Definition at line 53 of file SampleImpl.java.

◆ getDisposedGenerationCount()

int org.opensplice.dds.sub.SampleImpl< TYPE >.getDisposedGenerationCount ( )

For each instance the middleware internally maintains two counts: the disposedGenerationCount and noWritersGenerationCount, relative to each org.omg.dds.sub.DataReader:

  • The disposedGenerationCount and noWritersGenerationCount are initialized to zero when the DataReader first detects the presence of a never-seen-before instance.
  • The disposedGenerationCount is incremented each time the instanceState of the corresponding instance changes from NOT_ALIVE_DISPOSED to ALIVE.
  • The noWritersGenerationCount is incremented each time the instanceState of the corresponding instance changes from NOT_ALIVE_NO_WRITERS to ALIVE.

The disposedGenerationCount and noWritersGenerationCount available in the Sample capture a snapshot of the corresponding counters at the time the sample was received.

Returns
the disposed generation count
See also
getNoWritersGenerationCount()

Implements org.omg.dds.sub.Sample< TYPE >.

Definition at line 118 of file SampleImpl.java.

◆ getEnvironment()

Returns
the org.omg.dds.core.ServiceEnvironment object that directly or indirectly was used to create this object.

Implements org.omg.dds.core.DDSObject.

Definition at line 48 of file SampleImpl.java.

◆ getGenerationRank()

int org.opensplice.dds.sub.SampleImpl< TYPE >.getGenerationRank ( )

The sampleRank and generationRank available in the Sample are computed based solely on the actual samples in the ordered collection returned by org.omg.dds.sub.DataReader#read() or org.omg.dds.sub.DataReader#take().

  • The sampleRank indicates the number of samples of the same instance that follow the current one in the collection.
  • The generationRank available in the Sample indicates the difference in 'generations' between the sample (S) and the Most Recent Sample of the same instance that appears In the returned Collection (MRSIC). That is, it counts the number of times the instance transitioned from not-alive to alive in the time from the reception of S to the reception of MRSIC.

The generationRank is computed using the formula:

generationRank = (MRSIC.disposedGenerationCount

Implements org.omg.dds.sub.Sample< TYPE >.

Definition at line 133 of file SampleImpl.java.

◆ getInfo()

DDS.SampleInfo org.opensplice.dds.sub.SampleImpl< TYPE >.getInfo ( )

Definition at line 73 of file SampleImpl.java.

◆ getInstanceHandle()

InstanceHandle org.opensplice.dds.sub.SampleImpl< TYPE >.getInstanceHandle ( )

Gets the InstanceHandle of the associated data Sample.

Returns
the InstanceHandle of the sample

Implements org.omg.dds.sub.Sample< TYPE >.

Definition at line 106 of file SampleImpl.java.

◆ getInstanceState()

InstanceState org.opensplice.dds.sub.SampleImpl< TYPE >.getInstanceState ( )

For each instance the middleware internally maintains an instanceState.

The instanceState can be org.omg.dds.sub.InstanceState#ALIVE, org.omg.dds.sub.InstanceState#NOT_ALIVE_DISPOSED, or org.omg.dds.sub.InstanceState#NOT_ALIVE_NO_WRITERS.

  • ALIVE indicates that (a) samples have been received for the instance, (b) there are live org.omg.dds.pub.DataWriter entities writing the instance, and (c) the instance has not been explicitly disposed (or else more samples have been received after it was disposed).
  • NOT_ALIVE_DISPOSED indicates the instance was explicitly disposed by a DataWriter by means of org.omg.dds.pub.DataWriter#dispose(InstanceHandle).
  • NOT_ALIVE_NO_WRITERS indicates the instance has been declared as not-alive by the org.omg.dds.sub.DataReader because it detected that there are no live DataWriter entities writing that instance.

The precise behavior events that cause the instanceState to change depends on the setting of the org.omg.dds.core.policy.Ownership:

The instanceState available in the Sample is a snapshot of the instanceState of the instance at the time the collection was obtained (i.e., at the time org.omg.dds.sub.DataReader#read() or org.omg.dds.sub.DataReader#take() was called). The instanceState is therefore the same for all samples in the returned collection that refer to the same instance.

Returns
the InstanceState

Implements org.omg.dds.sub.Sample< TYPE >.

Definition at line 95 of file SampleImpl.java.

◆ getKeyValue()

TYPE org.opensplice.dds.sub.SampleImpl< TYPE >.getKeyValue ( )

Definition at line 61 of file SampleImpl.java.

◆ getNoWritersGenerationCount()

int org.opensplice.dds.sub.SampleImpl< TYPE >.getNoWritersGenerationCount ( )

For each instance the middleware internally maintains two counts: the disposedGenerationCount and noWritersGenerationCount, relative to each org.omg.dds.sub.DataReader:

  • The disposedGenerationCount and noWritersGenerationCount are initialized to zero when the DataReader first detects the presence of a never-seen-before instance.
  • The disposedGenerationCount is incremented each time the instanceState of the corresponding instance changes from NOT_ALIVE_DISPOSED to ALIVE.
  • The noWritersGenerationCount is incremented each time the instanceState of the corresponding instance changes from NOT_ALIVE_NO_WRITERS to ALIVE.

The disposedGenerationCount and noWritersGenerationCount available in the Sample capture a snapshot of the corresponding counters at the time the sample was received.

Returns
the no writers generation count
See also
getDisposedGenerationCount()

Implements org.omg.dds.sub.Sample< TYPE >.

Definition at line 123 of file SampleImpl.java.

◆ getPublicationHandle()

InstanceHandle org.opensplice.dds.sub.SampleImpl< TYPE >.getPublicationHandle ( )

Gets the InstanceHandle of the associated publication.

Returns
the PublicationHandle

Implements org.omg.dds.sub.Sample< TYPE >.

Definition at line 112 of file SampleImpl.java.

◆ getSampleRank()

int org.opensplice.dds.sub.SampleImpl< TYPE >.getSampleRank ( )

The sampleRank and generationRank available in the Sample are computed based solely on the actual samples in the ordered collection returned by org.omg.dds.sub.DataReader#read() or org.omg.dds.sub.DataReader#take().

  • The sampleRank indicates the number of samples of the same instance that follow the current one in the collection.
  • The generationRank available in the Sample indicates the difference in 'generations' between the sample (S) and the Most Recent Sample of the same instance that appears In the returned Collection (MRSIC). That is, it counts the number of times the instance transitioned from not-alive to alive in the time from the reception of S to the reception of MRSIC.
Returns
the sample rank
See also
getAbsoluteGenerationRank()
getGenerationRank()

Implements org.omg.dds.sub.Sample< TYPE >.

Definition at line 128 of file SampleImpl.java.

◆ getSampleState()

SampleState org.opensplice.dds.sub.SampleImpl< TYPE >.getSampleState ( )

For each sample received, the middleware internally maintains a sampleState relative to each org.omg.dds.sub.DataReader.

The sampleState can either be org.omg.dds.sub.SampleState#READ or org.omg.dds.sub.SampleState#NOT_READ.

The sampleState will, in general, be different for each sample in the collection returned by org.omg.dds.sub.DataReader#read() or org.omg.dds.sub.DataReader#take().

Returns
the SampleState

Implements org.omg.dds.sub.Sample< TYPE >.

Definition at line 83 of file SampleImpl.java.

◆ getSourceTimestamp()

Time org.opensplice.dds.sub.SampleImpl< TYPE >.getSourceTimestamp ( )

Gets the timestamp of the sample.

This is the timestamp provided by the DataWriter at the time the sample was produced.

Returns
the timestamp

Implements org.omg.dds.sub.Sample< TYPE >.

Definition at line 101 of file SampleImpl.java.

◆ getViewState()

ViewState org.opensplice.dds.sub.SampleImpl< TYPE >.getViewState ( )

For each instance (identified by the key), the middleware internally maintains a viewState relative to each org.omg.dds.sub.DataReader

The viewState can either be org.omg.dds.sub.ViewState#NEW or org.omg.dds.sub.ViewState#NOT_NEW.

  • NEW indicates that either this is the first time that the DataReader has ever accessed samples of that instance, or else that the DataReader has accessed previous samples of the instance, but the instance has since been reborn (i.e., become not-alive and then alive again). These two cases are distinguished by examining the disposedGenerationCount and the noWritersGenerationCount.
  • NOT_NEW indicates that the DataReader has already accessed samples of the same instance and that the instance has not been reborn since.

The viewState available in the Sample is a snapshot of the viewState of the instance relative to the DataReader used to access the samples at the time the collection was obtained (i.e., at the time org.omg.dds.sub.DataReader#read() or org.omg.dds.sub.DataReader#take() was called). The viewState is therefore the same for all samples in the returned collection that refer to the same instance.

Returns
the ViewState
See also
getDisposedGenerationCount()
getNoWritersGenerationCount()

Implements org.omg.dds.sub.Sample< TYPE >.

Definition at line 89 of file SampleImpl.java.

◆ setContent()

void org.opensplice.dds.sub.SampleImpl< TYPE >.setContent ( TYPE  data,
DDS.SampleInfo  info 
)

Definition at line 77 of file SampleImpl.java.

◆ setData()

void org.opensplice.dds.sub.SampleImpl< TYPE >.setData ( TYPE  data)

Definition at line 65 of file SampleImpl.java.

◆ setInfo()

void org.opensplice.dds.sub.SampleImpl< TYPE >.setInfo ( DDS.SampleInfo  info)

Definition at line 69 of file SampleImpl.java.


The documentation for this class was generated from the following file: