OpenSplice Java 5 DCPS  v6.x
OpenSplice Java 5 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
DataReaderQosImpl.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 
24 import org.omg.dds.core.policy.Deadline;
27 import org.omg.dds.core.policy.History;
38 import org.omg.dds.core.policy.UserData;
39 import org.omg.dds.sub.DataReaderQos;
40 import org.omg.dds.topic.TopicQos;
62 
63 public class DataReaderQosImpl extends EntityQosImpl<ForDataReader> implements
64 org.opensplice.dds.sub.DataReaderQos {
65  private static final long serialVersionUID = 7226579387926252059L;
66  private final TypeConsistencyEnforcement typeConsistencyEnforcement;
67 
69  TypeConsistencyEnforcement typeConsistencyEnforcement,
71  super(environment, policies);
72  this.typeConsistencyEnforcement = typeConsistencyEnforcement;
73 
74  }
75 
77  super(environment);
78  this.typeConsistencyEnforcement = new TypeConsistencyEnforcementImpl(
79  environment, Kind.EXACT_TYPE_TYPE_CONSISTENCY);
80  }
81 
82  private DataReaderQosImpl(DataReaderQosImpl source, ForDataReader... policy) {
83  super(source.environment, source.policies.values());
84  this.typeConsistencyEnforcement = source.typeConsistencyEnforcement;
85  setupPolicies(policy);
86  }
87 
88  @Override
90  synchronized (this.policies) {
91  return (Durability) this.policies.get(Durability.class);
92  }
93  }
94 
95  @Override
96  public Deadline getDeadline() {
97  synchronized (this.policies) {
98  return (Deadline) this.policies.get(Deadline.class);
99  }
100  }
101 
102  @Override
104  synchronized (this.policies) {
105  return (LatencyBudget) this.policies.get(LatencyBudget.class);
106  }
107  }
108 
109  @Override
111  synchronized (this.policies) {
112  return (Liveliness) this.policies.get(Liveliness.class);
113  }
114  }
115 
116  @Override
118  synchronized (this.policies) {
119  return (Reliability) this.policies.get(Reliability.class);
120  }
121  }
122 
123  @Override
125  synchronized (this.policies) {
126  return (DestinationOrder) this.policies.get(DestinationOrder.class);
127  }
128  }
129 
130  @Override
131  public History getHistory() {
132  synchronized (this.policies) {
133  return (History) this.policies.get(History.class);
134  }
135  }
136 
137  @Override
139  synchronized (this.policies) {
140  return (ResourceLimits) this.policies.get(ResourceLimits.class);
141  }
142  }
143 
144  @Override
146  synchronized (this.policies) {
147  return (UserData) this.policies.get(UserData.class);
148  }
149  }
150 
151  @Override
153  synchronized (this.policies) {
154  return (Ownership) this.policies.get(Ownership.class);
155  }
156  }
157 
158  @Override
160  synchronized (this.policies) {
161  return (TimeBasedFilter) this.policies.get(TimeBasedFilter.class);
162  }
163  }
164 
165  @Override
167  synchronized (this.policies) {
168  return (ReaderDataLifecycle) this.policies
169  .get(ReaderDataLifecycle.class);
170  }
171  }
172 
173  @Override
175  synchronized (this.policies) {
176  return (DataRepresentation) this.policies.get(DataRepresentation.class);
177  }
178  }
179 
180  @Override
182  synchronized (this.policies) {
183  return (ReaderLifespan) this.policies.get(ReaderLifespan.class);
184  }
185  }
186 
187  @Override
188  public Share getShare() {
189  synchronized (this.policies) {
190  return (Share) this.policies.get(Share.class);
191  }
192  }
193 
194  @Override
196  synchronized (this.policies) {
197  return (SubscriptionKeys) this.policies.get(SubscriptionKeys.class);
198  }
199  }
200 
201  @Override
203  return this.typeConsistencyEnforcement;
204  }
205 
206  @Override
208  return this.withPolicies(policy);
209  }
210 
211  @Override
213  synchronized (this.policies) {
214  return new DataReaderQosImpl(this, policy);
215  }
216  }
217 
218  @Override
219  protected void setupMissingPolicies() {
220  synchronized (this.policies) {
221  if (!this.policies.containsKey(Durability.class)) {
222  this.policies.put(Durability.class, new DurabilityImpl(
223  this.environment));
224  }
225  if (!this.policies.containsKey(Deadline.class)) {
226  this.policies.put(Deadline.class,
227  new DeadlineImpl(this.environment));
228  }
229  if (!this.policies.containsKey(LatencyBudget.class)) {
230  this.policies.put(LatencyBudget.class, new LatencyBudgetImpl(
231  this.environment));
232  }
233  if (!this.policies.containsKey(Liveliness.class)) {
234  this.policies.put(Liveliness.class, new LivelinessImpl(
235  this.environment));
236  }
237  if (!this.policies.containsKey(Reliability.class)) {
238  this.policies.put(Reliability.class, new ReliabilityImpl(
239  this.environment));
240  }
241  if (!this.policies.containsKey(DestinationOrder.class)) {
242  this.policies.put(DestinationOrder.class, new DestinationOrderImpl(
243  this.environment));
244  }
245  if (!this.policies.containsKey(History.class)) {
246  this.policies.put(History.class, new HistoryImpl(this.environment));
247  }
248  if (!this.policies.containsKey(ResourceLimits.class)) {
249  this.policies.put(ResourceLimits.class, new ResourceLimitsImpl(
250  this.environment));
251  }
252  if (!this.policies.containsKey(TimeBasedFilter.class)) {
253  this.policies.put(TimeBasedFilter.class, new TimeBasedFilterImpl(
254  this.environment));
255  }
256  if (!this.policies.containsKey(Ownership.class)) {
257  this.policies.put(Ownership.class, new OwnershipImpl(
258  this.environment));
259  }
260  if (!this.policies.containsKey(DataRepresentation.class)) {
261  this.policies.put(DataRepresentation.class,
263  }
264  if (!this.policies.containsKey(UserData.class)) {
265  this.policies.put(UserData.class,
266  new UserDataImpl(this.environment));
267  }
268  if (!this.policies.containsKey(ReaderDataLifecycle.class)) {
269  this.policies.put(ReaderDataLifecycle.class,
271  }
272  }
273  }
274 
275  public DDS.DataReaderQos convert() {
276  DDS.DataReaderQos old = new DDS.DataReaderQos();
277 
278  synchronized (this.policies) {
279  old.deadline = PolicyConverter.convert(this.environment,
280  ((Deadline) this.policies.get(Deadline.class)));
281  old.destination_order = PolicyConverter.convert(this.environment,
282  ((DestinationOrder) this.policies
283  .get(DestinationOrder.class)));
284  old.durability = PolicyConverter.convert(this.environment,
285  ((Durability) this.policies.get(Durability.class)));
286  old.history = PolicyConverter.convert(this.environment,
287  ((History) this.policies.get(History.class)));
288  old.latency_budget = PolicyConverter.convert(this.environment,
289  ((LatencyBudget) this.policies.get(LatencyBudget.class)));
290  old.liveliness = PolicyConverter.convert(this.environment,
291  ((Liveliness) this.policies.get(Liveliness.class)));
292  old.ownership = PolicyConverter.convert(this.environment,
293  ((Ownership) this.policies.get(Ownership.class)));
294  old.reader_data_lifecycle = PolicyConverter.convert(
296  .get(ReaderDataLifecycle.class)));
297  old.reader_lifespan = PolicyConverter.convert(this.environment,
298  ((ReaderLifespan) this.policies.get(ReaderLifespan.class)));
299  old.reliability = PolicyConverter.convert(this.environment,
300  ((Reliability) this.policies.get(Reliability.class)));
301  old.resource_limits = PolicyConverter.convert(this.environment,
302  ((ResourceLimits) this.policies.get(ResourceLimits.class)));
303  old.share = PolicyConverter.convert(this.environment,
304  ((Share) this.policies.get(Share.class)));
305  old.subscription_keys = PolicyConverter.convert(this.environment,
306  ((SubscriptionKeys) this.policies
307  .get(SubscriptionKeys.class)));
308  ;
309  old.time_based_filter = PolicyConverter
311  .get(TimeBasedFilter.class)));
312  old.user_data = PolicyConverter.convert(this.environment,
313  ((UserData) this.policies.get(UserData.class)));
314  }
315  return old;
316  }
317 
319  DDS.DataReaderQos oldQos) {
320  if (oldQos == null) {
321  throw new IllegalArgumentExceptionImpl(env,
322  "oldQos parameter is null.");
323  }
324 
325  DataReaderQosImpl qos = new DataReaderQosImpl(env);
326 
327  qos.put(Deadline.class, PolicyConverter.convert(env, oldQos.deadline));
328  qos.put(DestinationOrder.class,
329  PolicyConverter.convert(env, oldQos.destination_order));
330  qos.put(Durability.class,
331  PolicyConverter.convert(env, oldQos.durability));
332  qos.put(History.class, PolicyConverter.convert(env, oldQos.history));
333  qos.put(LatencyBudget.class,
334  PolicyConverter.convert(env, oldQos.latency_budget));
335  qos.put(Liveliness.class,
336  PolicyConverter.convert(env, oldQos.liveliness));
337  qos.put(Ownership.class, PolicyConverter.convert(env, oldQos.ownership));
338  qos.put(ReaderDataLifecycle.class,
339  PolicyConverter.convert(env, oldQos.reader_data_lifecycle));
340  qos.put(Reliability.class,
341  PolicyConverter.convert(env, oldQos.reliability));
342  qos.put(ResourceLimits.class,
343  PolicyConverter.convert(env, oldQos.resource_limits));
344 
345  qos.put(TimeBasedFilter.class,
346  PolicyConverter.convert(env, oldQos.time_based_filter));
347  qos.put(UserData.class, PolicyConverter.convert(env, oldQos.user_data));
348 
349  Share share = PolicyConverter.convert(env, oldQos.share);
350 
351  if (share != null) {
352  qos.put(Share.class, share);
353  }
354 
355  ReaderLifespan readerLifespan = PolicyConverter.convert(env,
356  oldQos.reader_lifespan);
357 
358  if (readerLifespan != null) {
359  qos.put(ReaderLifespan.class, readerLifespan);
360  }
361  SubscriptionKeys subscriptionKeys = PolicyConverter.convert(env,
362  oldQos.subscription_keys);
363 
364  if (subscriptionKeys != null) {
365  qos.put(SubscriptionKeys.class, subscriptionKeys);
366  }
367  return qos;
368  }
369 
370  public void mergeTopicQos(TopicQos topicQos) {
371  synchronized (this.policies) {
372  this.policies.put(Deadline.class, topicQos.getDeadline());
373  this.policies.put(DestinationOrder.class,
374  topicQos.getDestinationOrder());
375  this.policies.put(Durability.class, topicQos.getDurability());
376  this.policies.put(History.class, topicQos.getHistory());
377  this.policies.put(LatencyBudget.class, topicQos.getLatencyBudget());
378  this.policies.put(Liveliness.class, topicQos.getLiveliness());
379  this.policies.put(Ownership.class, topicQos.getOwnership());
380  this.policies.put(Reliability.class, topicQos.getReliability());
381  this.policies.put(DataRepresentation.class,
382  topicQos.getRepresentation());
383  this.policies.put(ResourceLimits.class,
384  topicQos.getResourceLimits());
385  }
386  }
387 }
Specifies the behavior of the org.omg.dds.sub.DataReader with regards to the life cycle of the data i...
This org.omg.dds.core.policy.QosPolicy is similar to the org.omg.dds.core.policy.Lifespan (applicable...
Specifies the maximum acceptable delay from the time the data is written until the data is inserted i...
Filter that allows a org.omg.dds.sub.DataReader to specify that it is interested only in (potentially...
DataReaderQosImpl(OsplServiceEnvironment environment, TypeConsistencyEnforcement typeConsistencyEnforcement, ForDataReader... policies)
LatencyBudget getLatencyBudget()
User data not known by the middleware, but distributed by means of built-in topics.
Definition: UserData.java:48
static DataReaderQosImpl convert(OsplServiceEnvironment env, DDS.DataReaderQos oldQos)
DataRepresentation getRepresentation()
void setupPolicies(Collection< T > policies)
DestinationOrder getDestinationOrder()
This QosPolicy allows sharing of entities by multiple processes or threads.
Definition: Share.java:46
T put(Class<? extends T > arg0, T arg1)
Reliability getReliability()
DataReaderQos withPolicy(ForDataReader policy)
static DDS.UserDataQosPolicy convert(OsplServiceEnvironment env, UserData p)
TypeConsistencyEnforcement getTypeConsistency()
Determines the mechanism and parameters used by the application to determine whether an org...
By using the SubscriptionKey QosPolicy, a DataReader can force its own key-list definition on data sa...
This class is the abstract root for all the QoS policies.
Definition: QosPolicy.java:118
DataReaderQos withPolicies(ForDataReader... policy)
final OsplServiceEnvironment environment
Controls the criteria used to determine the logical order among changes made by org.omg.dds.pub.Publisher entities to the same instance of data (i.e., matching Topic and key).
HashMap< Class<? extends T >, T > policies
Specifies the resources that the Service can consume in order to meet the requested QoS...
This policy indicates the level of reliability requested by a org.omg.dds.sub.DataReader or offered b...
This policy expresses if the data should "outlive" their writing time.
A QosPolicy interface that implements this marker interface applies to org.omg.dds.sub.DataReader Entities.
Definition: QosPolicy.java:178
org.omg.dds.sub.DataReader expects a new sample updating the value of each instance at least once eve...
Definition: Deadline.java:92
DataReaderQosImpl(OsplServiceEnvironment environment)
This QosPolicy specifies whether a DataWriter exclusively may own an instance.
Definition: Ownership.java:63
ResourceLimits getResourceLimits()
Specifies the behavior of the Service in the case where the value of a sample changes (one or more ti...
Definition: History.java:76