OpenSplice Java 5 DCPS  v6.x
OpenSplice Java 5 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
ReadConditionImpl.java
Go to the documentation of this file.
1 /*
2  * Vortex OpenSplice
3  *
4  * This software and documentation are Copyright 2006 to 2024 ADLINK
5  * Technology Limited, its affiliated companies and licensors. All rights
6  * reserved.
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21 package org.opensplice.dds.sub;
22 
23 import java.util.Collection;
24 import java.util.Set;
25 
27 import org.omg.dds.sub.DataReader;
28 import org.omg.dds.sub.InstanceState;
29 import org.omg.dds.sub.ReadCondition;
30 import org.omg.dds.sub.SampleState;
31 import org.omg.dds.sub.ViewState;
36 
37 public class ReadConditionImpl<TYPE> implements ReadCondition<TYPE>,
38  Condition<DDS.ReadCondition> {
40  protected DDS.ReadCondition old;
42  protected final DataStateImpl state;
43 
46  Collection<SampleState> sampleState,
47  Collection<ViewState> viewState,
48  Collection<InstanceState> instanceState) {
49  this(environment, parent, new DataStateImpl(environment, sampleState,
50  viewState, instanceState), true);
51  }
52 
55  this(environment, parent, state, true);
56  }
57 
59  AbstractDataReader<TYPE> parent) {
60  this(environment, parent, DataStateImpl.any(environment), true);
61  }
62 
64  AbstractDataReader<TYPE> parent, boolean setupCondition) {
65  this(environment, parent, DataStateImpl.any(environment),
66  setupCondition);
67  }
68 
71  boolean setupCondition) {
72  this.environment = environment;
73  this.parent = parent;
74  this.state = state;
75 
76  if (state == null) {
77  throw new IllegalArgumentExceptionImpl(environment,
78  "Illegal DataState (null) provided.");
79  }
80 
81  if (setupCondition) {
82  this.old = parent.getOld().create_readcondition(
83  this.state.getOldSampleState(),
84  this.state.getOldViewState(),
85  this.state.getOldInstanceState());
86 
87  if (this.old == null) {
88  Utilities.throwLastErrorException(this.environment);
89  }
90  }
91  }
92 
93  @Override
94  public boolean getTriggerValue() {
95  return this.old.get_trigger_value();
96  }
97 
98  @Override
100  return this.environment;
101  }
102 
103  @Override
104  public Set<SampleState> getSampleStates() {
105  return this.state.getSampleStates();
106  }
107 
108  @Override
109  public Set<ViewState> getViewStates() {
110  return this.state.getViewStates();
111  }
112 
113  @Override
114  public Set<InstanceState> getInstanceStates() {
115  return this.state.getInstanceStates();
116  }
117 
118  @Override
120  return this.parent;
121  }
122 
123  public DDS.ReadCondition getOld() {
124  return this.old;
125  }
126 
127  @Override
128  public void close() {
129  this.parent.destroyReadCondition(this);
130  }
131 
133  return this.state.clone();
134  }
135 
136  @Override
137  public DDS.ReadCondition getOldCondition() {
138  return this.old;
139  }
140 
141 }
ReadConditionImpl(OsplServiceEnvironment environment, AbstractDataReader< TYPE > parent, DataStateImpl state)
A DataReader allows the application (1) to declare the data it wishes to receive (i.e., make a subscription) and (2) to access the data received by the attached org.omg.dds.sub.Subscriber.
For each instance the Data Distribution Service internally maintains an InstanceState.
For each sample, the Data Distribution Service internally maintains a SampleState specific to each Da...
ReadConditionImpl(OsplServiceEnvironment environment, AbstractDataReader< TYPE > parent, DataStateImpl state, boolean setupCondition)
ReadConditionImpl(OsplServiceEnvironment environment, AbstractDataReader< TYPE > parent)
final OsplServiceEnvironment environment
void close()
Reclaim any resources associated with this condition.
ReadCondition objects are conditions specifically dedicated to read operations and attached to one or...
For each instance (identified by the key), the Data Distribution Service internally maintains a ViewS...
Definition: ViewState.java:26
Set< InstanceState > getInstanceStates()
This operation returns the set of instance states that are taken into account to determine the trigge...
final AbstractDataReader< TYPE > parent
void destroyReadCondition(ReadConditionImpl< TYPE > condition)
Set< InstanceState > getInstanceStates()
Set< ViewState > getViewStates()
This operation returns the set of view states that are taken into account to determine the triggerVal...
static DataStateImpl any(OsplServiceEnvironment environment)
DDS implementations are rooted in this class, a concrete subclass of which can be instantiated based ...
static void throwLastErrorException(OsplServiceEnvironment environment)
Definition: Utilities.java:182
Set< SampleState > getSampleStates()
This operation returns the set of sample states that are taken into account to determine the triggerV...
ReadConditionImpl(OsplServiceEnvironment environment, AbstractDataReader< TYPE > parent, boolean setupCondition)
ReadConditionImpl(OsplServiceEnvironment environment, AbstractDataReader< TYPE > parent, Collection< SampleState > sampleState, Collection< ViewState > viewState, Collection< InstanceState > instanceState)