21 package org.opensplice.dds.sub;
23 import java.util.Collection;
24 import java.util.Collections;
25 import java.util.HashSet;
40 private HashSet<SampleState> sampleState;
41 private HashSet<ViewState> viewState;
42 private HashSet<InstanceState> instanceState;
45 Collection<SampleState> sampleState,
46 Collection<ViewState> viewState,
47 Collection<InstanceState> instanceState) {
48 this.environment = environment;
49 this.sampleState =
new HashSet<SampleState>(sampleState);
50 this.viewState =
new HashSet<ViewState>(viewState);
51 this.instanceState =
new HashSet<InstanceState>(instanceState);
55 this.environment = environment;
56 this.sampleState =
new HashSet<SampleState>();
57 this.viewState =
new HashSet<ViewState>();
58 this.instanceState =
new HashSet<InstanceState>();
63 .withAnyViewState().withAnyInstanceState();
69 case DDS.READ_SAMPLE_STATE.
value:
71 case DDS.NOT_READ_SAMPLE_STATE.value:
81 case DDS.NEW_VIEW_STATE.
value:
83 case DDS.NOT_NEW_VIEW_STATE.value:
93 case DDS.ALIVE_INSTANCE_STATE.
value:
95 case DDS.NOT_ALIVE_DISPOSED_INSTANCE_STATE.value:
97 case DDS.NOT_ALIVE_NO_WRITERS_INSTANCE_STATE.value:
106 return this.environment;
111 return Collections.unmodifiableSet(this.sampleState);
116 return Collections.unmodifiableSet(this.viewState);
121 return Collections.unmodifiableSet(this.instanceState);
126 HashSet<SampleState> s =
new HashSet<SampleState>(this.sampleState);
129 return new DataStateImpl(this.environment, s, this.viewState,
135 HashSet<ViewState> s =
new HashSet<ViewState>(this.viewState);
138 return new DataStateImpl(this.environment, this.sampleState, s,
144 HashSet<InstanceState> s =
new HashSet<InstanceState>(
154 HashSet<SampleState> s =
new HashSet<SampleState>(this.sampleState);
159 return new DataStateImpl(this.environment, s, this.viewState,
165 HashSet<ViewState> s =
new HashSet<ViewState>(this.viewState);
170 return new DataStateImpl(this.environment, this.sampleState, s,
176 HashSet<InstanceState> s =
new HashSet<InstanceState>(
189 HashSet<InstanceState> s =
new HashSet<InstanceState>(
206 if (read && notRead) {
207 result = DDS.ANY_SAMPLE_STATE.value;
209 result = DDS.READ_SAMPLE_STATE.value;
210 }
else if (notRead) {
211 result = DDS.NOT_READ_SAMPLE_STATE.value;
214 "Incomplete DataState: no SampleState set.");
221 case DDS.ANY_INSTANCE_STATE.value:
225 case DDS.READ_SAMPLE_STATE.value:
228 case DDS.NOT_READ_SAMPLE_STATE.value:
233 "Invalid SampleState");
243 if (_new && notNew) {
244 result = DDS.ANY_VIEW_STATE.value;
246 result = DDS.NEW_VIEW_STATE.value;
248 result = DDS.NOT_NEW_VIEW_STATE.value;
251 "Incomplete DataState: no ViewState set.");
258 case DDS.ANY_VIEW_STATE.value:
262 case DDS.NEW_VIEW_STATE.value:
265 case DDS.NOT_NEW_VIEW_STATE.value:
270 "Invalid ViewState");
278 boolean disposed = this.instanceState
280 boolean noWriters = this.instanceState
284 result |= DDS.ALIVE_INSTANCE_STATE.value;
287 result |= DDS.NOT_ALIVE_DISPOSED_INSTANCE_STATE.value;
290 result |= DDS.NOT_ALIVE_NO_WRITERS_INSTANCE_STATE.value;
293 if (alive && disposed && noWriters) {
294 result = DDS.ANY_INSTANCE_STATE.value;
298 "Incomplete DataState: no InstanceState set.");
305 case DDS.ANY_INSTANCE_STATE.value:
310 case DDS.NOT_ALIVE_INSTANCE_STATE.value:
315 case DDS.ALIVE_INSTANCE_STATE.value:
318 case DDS.NOT_ALIVE_DISPOSED_INSTANCE_STATE.value:
321 case DDS.NOT_ALIVE_NO_WRITERS_INSTANCE_STATE.value:
326 "Invalid InstanceState");
332 .withAnySampleState().withAnyViewState().withAnyInstanceState();
335 @SuppressWarnings(
"unchecked")
341 cloned.environment = this.environment;
342 cloned.instanceState = (HashSet<InstanceState>) this.instanceState
344 cloned.sampleState = (HashSet<SampleState>) this.sampleState
346 cloned.viewState = (HashSet<ViewState>) this.viewState.clone();
349 }
catch (CloneNotSupportedException e) {
351 "Cloning of DataState not supported.");
365 if (this.instanceState.size() != d.instanceState.size()) {
368 if (!d.instanceState.containsAll(
this.instanceState)) {
371 if (this.sampleState.size() != d.sampleState.size()) {
374 if (!d.sampleState.containsAll(
this.sampleState)) {
377 if (this.viewState.size() != d.viewState.size()) {
380 if (!d.viewState.containsAll(
this.viewState)) {
388 final int prime = 31;
392 result = prime * result + s.hashCode();
395 result = prime * result + s.hashCode();
398 result = prime * result + s.hashCode();
Set< SampleState > getSampleStates()
Set< ViewState > getViewStates()
A Subscriber is the object responsible for the actual reception of the data resulting from its subscr...
For each instance the Data Distribution Service internally maintains an InstanceState.
int getOldInstanceState()
DataState withAnyViewState()
DataState withNotAliveInstanceStates()
DataState withAnyInstanceState()
For each sample, the Data Distribution Service internally maintains a SampleState specific to each Da...
static InstanceState getInstanceStateFromOld(OsplServiceEnvironment env, int state)
A DataState encapsulates sets of sample states, view states, and instance states as a convenience...
NOT_READ
NOT_READ indicates that the DataReader has not accessed that sample before.
DataStateImpl(OsplServiceEnvironment environment, Collection< SampleState > sampleState, Collection< ViewState > viewState, Collection< InstanceState > instanceState)
boolean equals(Object other)
void withOldViewState(int state)
DataStateImpl(OsplServiceEnvironment environment)
ALIVE
ALIVE indicates that:
ServiceEnvironment getEnvironment()
DataState withAnySampleState()
static SampleState getSampleStateFromOld(OsplServiceEnvironment env, int state)
NOT_ALIVE_NO_WRITERS
NOT_ALIVE_NO_WRITERS indicates the instance has been declared as not-alive by the DataReader because ...
DataState with(InstanceState state)
For each instance (identified by the key), the Data Distribution Service internally maintains a ViewS...
void withOldSampleState(int state)
NOT_NEW
NOT_NEW indicates that the DataReader has already accessed samples of the same instance and that the ...
Set< InstanceState > getInstanceStates()
static DataStateImpl any(OsplServiceEnvironment environment)
static DataStateImpl getAnyStateDataState(OsplServiceEnvironment env)
static ViewState getViewStateFromOld(OsplServiceEnvironment env, int state)
void withOldInstanceState(int state)
DDS implementations are rooted in this class, a concrete subclass of which can be instantiated based ...
NOT_ALIVE_DISPOSED
NOT_ALIVE_DISPOSED indicates the instance was disposed of by a DataWriter either explicitly by means ...
READ
READ indicates that the DataReader has already accessed that sample by means of org.omg.dds.sub.DataReader#read().
DataState with(SampleState state)
NEW
NEW indicates that either this is the first time that the DataReader has ever accessed samples of tha...
DataState with(ViewState state)