TYPE
- The concrete type of the data encapsulated by this Sample.public interface Sample<TYPE> extends Cloneable, Serializable, DDSObject
DataReader
's read or take operations.
It consists of two parts: the Data (getData()
) and the "Sample
Info" (the remainder of the methods defined by this interface).
Interpretation of the Sample Info
In addition to the data value itself, the Sample contains information
pertaining to it:
getSampleState()
) of the Data value
(i.e., if the sample has already been SampleState.READ
or
SampleState.NOT_READ
by that same DataReader
).
getViewState()
) of the related instance
(i.e., if the current generation of the instance is
ViewState.NEW
or ViewState.NOT_NEW
for that
DataReader).getInstanceState()
) of the related
instance (i.e., if the instance is InstanceState.ALIVE
,
InstanceState.NOT_ALIVE_DISPOSED
, or
InstanceState.NOT_ALIVE_NO_WRITERS
).getData()
return a non-null value. Some samples do not contain data, instead
indicating only a change on the instanceState of the corresponding
instance.getDisposedGenerationCount()
) and
noWritersGenerationCount (getNoWritersGenerationCount()
)
for the related instance at the time the sample was received.
These counters indicate the number of times the instance had
become ALIVE (with instanceState = InstanceState.ALIVE
)
at the time the sample was received.getSampleRank()
) and generationRank
(getGenerationRank()
) of the sample within the returned
sequence. These ranks provide a preview of the samples that
follow within the sequence returned by the
DataReader.read()
or DataReader.take()
operations.getAbsoluteGenerationRank()
)
of the sample within the DataReader. This rank provides a preview
of what is available within the DataReader.getSourceTimestamp()
) of the sample.
This is the time stamp provided by the DataWriter
at the
time the sample was produced.getInstanceHandle()
) that identifies
locally the corresponding instance.getPublicationHandle()
) that
identifies locally the DataWriter
that modified the
instance. The publicationHandle is the same InstanceHandle
that is returned by the operation
DataReader.getMatchedPublications()
on the DataReader and can also be used as a parameter to the
operation
DataReader.getMatchedPublicationData(InstanceHandle)
.getDisposedGenerationCount()
), noWritersGenerationCount
(getNoWritersGenerationCount()
), sampleRank
(getSampleRank()
), generationRank (getGenerationRank()
),
and absoluteGenerationRank (getAbsoluteGenerationRank()
). These
counters and ranks allow the application to distinguish samples belonging
to different 'generations' of the instance. Note that it is possible for
an instance to transition from not-alive to alive (and back) several times
before the application accesses the data by means of
DataReader.read()
or DataReader.take()
. In this case the
returned collection may contain samples that cross generations (i.e., some
samples were received before the instance became not-alive, others after
the instance reappeared again). Using the information in the Sample the
application can anticipate what other information regarding the same
instance appears in the returned collection as well as in the
infrastructure and thus make appropriate decisions. For example, an
application desiring to only consider the most current sample for each
instance would only look at samples with sampleRank == 0. Similarly an
application desiring to only consider samples that correspond to the
latest generation in the collection will only look at samples with
generationRank == 0. An application desiring only samples pertaining to
the latest generation available will ignore samples for which
absoluteGenerationRank != 0. Other application-defined criteria may also
be used.Modifier and Type | Interface and Description |
---|---|
static interface |
Sample.Iterator<IT_DATA> |
Modifier and Type | Method and Description |
---|---|
Sample<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
DataReader.read() or DataReader.take() . |
TYPE |
getData()
Get the data associated with this Sample, if any.
|
int |
getDisposedGenerationCount()
For each instance the middleware internally maintains two counts: the
disposedGenerationCount and noWritersGenerationCount, relative to each
DataReader :
The disposedGenerationCount and noWritersGenerationCount are
initialized to zero when the DataReader first detects the
presence of a never-seen-before instance. |
int |
getGenerationRank()
The sampleRank and generationRank available in the Sample are computed
based solely on the actual samples in the ordered collection returned
by
DataReader.read() or DataReader.take() . |
ModifiableInstanceHandle |
getInstanceHandle() |
InstanceState |
getInstanceState()
For each instance the middleware internally maintains an
instanceState.
|
int |
getNoWritersGenerationCount()
For each instance the middleware internally maintains two counts: the
disposedGenerationCount and noWritersGenerationCount, relative to each
DataReader :
The disposedGenerationCount and noWritersGenerationCount are
initialized to zero when the DataReader first detects the
presence of a never-seen-before instance. |
ModifiableInstanceHandle |
getPublicationHandle() |
int |
getSampleRank()
The sampleRank and generationRank available in the Sample are computed
based solely on the actual samples in the ordered collection returned
by
DataReader.read() or DataReader.take() . |
SampleState |
getSampleState()
For each sample received, the middleware internally maintains a
sampleState relative to each
DataReader . |
Time |
getSourceTimestamp() |
ViewState |
getViewState()
For each instance (identified by the key), the middleware internally
maintains a viewState relative to each
DataReader . |
getEnvironment
TYPE getData()
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.SampleState getSampleState()
DataReader
. The sampleState can
either be SampleState.READ
or SampleState.NOT_READ
.
DataReader.read()
. (Had the sample
been accessed by DataReader.take()
, it would no longer
be available to the DataReader.)DataReader.read()
or
DataReader.take()
.ViewState getViewState()
DataReader
. The
viewState can either be ViewState.NEW
or
ViewState.NOT_NEW
.
DataReader.read()
or DataReader.take()
was called).
The viewState is therefore the same for all samples in the returned
collection that refer to the same instance.InstanceState getInstanceState()
InstanceState.ALIVE
,
InstanceState.NOT_ALIVE_DISPOSED
, or
InstanceState.NOT_ALIVE_NO_WRITERS
.
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).DataWriter.dispose(InstanceHandle)
.DataReader
because it detected
that there are no live DataWriter entities writing that
instance.
Ownership
:
Ownership.getKind()
is
Ownership.Kind.EXCLUSIVE
,
then the instanceState becomes NOT_ALIVE_DISPOSED only if the
DataWriter that "owns" the instance explicitly disposes it.
The instanceState becomes ALIVE again only if the DataWriter
that owns the instance writes it.Ownership.getKind()
is
Ownership.Kind.SHARED
,
then the instanceState
becomes NOT_ALIVE_DISPOSED if any DataWriter explicitly
disposes the instance. The instanceState becomes ALIVE as soon
as any DataWriter writes the instance again.DataReader.read()
or
DataReader.take()
was called). The instanceState is therefore
the same for all samples in the returned collection that refer to the
same instance.Time getSourceTimestamp()
ModifiableInstanceHandle getInstanceHandle()
ModifiableInstanceHandle getPublicationHandle()
int getDisposedGenerationCount()
DataReader
:
getNoWritersGenerationCount()
int getNoWritersGenerationCount()
DataReader
:
getDisposedGenerationCount()
int getSampleRank()
DataReader.read()
or DataReader.take()
.
int getGenerationRank()
DataReader.read()
or DataReader.take()
.
generationRank = (MRSIC.disposedGenerationCount
+ MRSIC.noWritersGenerationCount)
- (S.disposedGenerationCount
+ S.noWritersGenerationCount)
getAbsoluteGenerationRank()
,
getSampleRank()
int getAbsoluteGenerationRank()
DataReader.read()
or DataReader.take()
.
DataReader.read()
or DataReader.take()
was
called.
absoluteGenerationRank = (MRS.disposedGenerationCount
+ MRS.noWritersGenerationCount)
- (S.disposedGenerationCount
+ S.noWritersGenerationCount)
getGenerationRank()
,
getSampleRank()
Copyright © 2014. All rights reserved.