OpenSplice Java 5 DCPS  v6.x
OpenSplice Java 5 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
DataWriterQosImpl.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.pub;
22 
24 import org.omg.dds.core.policy.Deadline;
28 import org.omg.dds.core.policy.History;
30 import org.omg.dds.core.policy.Lifespan;
40 import org.omg.dds.core.policy.UserData;
42 import org.omg.dds.pub.DataWriterQos;
43 import org.omg.dds.topic.TopicQos;
65 
66 public class DataWriterQosImpl extends EntityQosImpl<ForDataWriter> implements
68  private static final long serialVersionUID = -3612002704263154280L;
69  private final TypeConsistencyEnforcement typeConsistencyEnforcement;
70 
72  TypeConsistencyEnforcement typeConsistencyEnforcement,
74  super(environment, policies);
75  this.typeConsistencyEnforcement = typeConsistencyEnforcement;
76 
77  }
78 
80  super(environment);
81  this.typeConsistencyEnforcement = new TypeConsistencyEnforcementImpl(
82  environment, Kind.EXACT_TYPE_TYPE_CONSISTENCY);
83  }
84 
85  private DataWriterQosImpl(DataWriterQosImpl source, ForDataWriter... policy) {
86  super(source.environment, source.policies.values());
87  this.typeConsistencyEnforcement = source.typeConsistencyEnforcement;
88  setupPolicies(policy);
89  }
90 
91  @Override
93  synchronized (this.policies) {
94  return (Durability) this.policies.get(Durability.class);
95  }
96  }
97 
98  @Override
100  // TODO: Fix Java 5 PSM; DurabilityService is NOT part of DataWriterQos
102  "DurabilityService is only part of the TopicQos, not of the DataWriterQos");
103  }
104 
105  @Override
107  synchronized (this.policies) {
108  return (Deadline) this.policies.get(Deadline.class);
109  }
110  }
111 
112  @Override
114  synchronized (this.policies) {
115  return (LatencyBudget) this.policies.get(LatencyBudget.class);
116  }
117  }
118 
119  @Override
121  synchronized (this.policies) {
122  return (Liveliness) this.policies.get(Liveliness.class);
123  }
124  }
125 
126  @Override
128  synchronized (this.policies) {
129  return (Reliability) this.policies.get(Reliability.class);
130  }
131  }
132 
133  @Override
135  synchronized (this.policies) {
136  return (DestinationOrder) this.policies.get(DestinationOrder.class);
137  }
138  }
139 
140  @Override
141  public History getHistory() {
142  synchronized (this.policies) {
143  return (History) this.policies.get(History.class);
144  }
145  }
146 
147  @Override
149  synchronized (this.policies) {
150  return (ResourceLimits) this.policies.get(ResourceLimits.class);
151  }
152  }
153 
154  @Override
156  synchronized (this.policies) {
157  return (TransportPriority) this.policies.get(TransportPriority.class);
158  }
159  }
160 
161  @Override
163  synchronized (this.policies) {
164  return (Lifespan) this.policies.get(Lifespan.class);
165  }
166  }
167 
168  @Override
170  synchronized (this.policies) {
171  return (UserData) this.policies.get(UserData.class);
172  }
173  }
174 
175  @Override
177  synchronized (this.policies) {
178  return (Ownership) this.policies.get(Ownership.class);
179  }
180  }
181 
182  @Override
184  synchronized (this.policies) {
185  return (OwnershipStrength) this.policies.get(OwnershipStrength.class);
186  }
187  }
188 
189  @Override
191  synchronized (this.policies) {
192  return (WriterDataLifecycle) this.policies
193  .get(WriterDataLifecycle.class);
194  }
195  }
196 
197  @Override
199  synchronized (this.policies) {
200  return (DataRepresentation) this.policies.get(DataRepresentation.class);
201  }
202  }
203 
204  @Override
206  return this.typeConsistencyEnforcement;
207  }
208 
209  @Override
211  return this.withPolicies(policy);
212  }
213 
214  @Override
216  synchronized (this.policies) {
217  return new DataWriterQosImpl(this, policy);
218  }
219  }
220 
221  public void mergeTopicQos(TopicQos topicQos) {
222  synchronized (this.policies) {
223  this.policies.put(Deadline.class, topicQos.getDeadline());
224  this.policies.put(DestinationOrder.class,
225  topicQos.getDestinationOrder());
226  this.policies.put(Durability.class, topicQos.getDurability());
227  this.policies.put(History.class, topicQos.getHistory());
228  this.policies.put(LatencyBudget.class, topicQos.getLatencyBudget());
229  this.policies.put(Lifespan.class, topicQos.getLifespan());
230  this.policies.put(Liveliness.class, topicQos.getLiveliness());
231  this.policies.put(Ownership.class, topicQos.getOwnership());
232  this.policies.put(Reliability.class, topicQos.getReliability());
233  this.policies.put(DataRepresentation.class,
234  topicQos.getRepresentation());
235  this.policies.put(ResourceLimits.class,
236  topicQos.getResourceLimits());
237  this.policies.put(TransportPriority.class,
238  topicQos.getTransportPriority());
239  }
240  }
241 
242  @Override
243  protected void setupMissingPolicies() {
244  synchronized (this.policies) {
245  if (!this.policies.containsKey(Durability.class)) {
246  this.policies.put(Durability.class, new DurabilityImpl(
247  this.environment));
248  }
249  if (!this.policies.containsKey(Deadline.class)) {
250  this.policies.put(Deadline.class,
251  new DeadlineImpl(this.environment));
252  }
253  if (!this.policies.containsKey(LatencyBudget.class)) {
254  this.policies.put(LatencyBudget.class, new LatencyBudgetImpl(
255  this.environment));
256  }
257  if (!this.policies.containsKey(Liveliness.class)) {
258  this.policies.put(Liveliness.class, new LivelinessImpl(
259  this.environment));
260  }
261  if (!this.policies.containsKey(Reliability.class)) {
262  this.policies.put(Reliability.class, new ReliabilityImpl(
263  this.environment).withReliable());
264  }
265  if (!this.policies.containsKey(DestinationOrder.class)) {
266  this.policies.put(DestinationOrder.class, new DestinationOrderImpl(
267  this.environment));
268  }
269  if (!this.policies.containsKey(History.class)) {
270  this.policies.put(History.class, new HistoryImpl(this.environment));
271  }
272  if (!this.policies.containsKey(ResourceLimits.class)) {
273  this.policies.put(ResourceLimits.class, new ResourceLimitsImpl(
274  this.environment));
275  }
276  if (!this.policies.containsKey(TransportPriority.class)) {
277  this.policies.put(TransportPriority.class,
279  }
280  if (!this.policies.containsKey(Lifespan.class)) {
281  this.policies.put(Lifespan.class,
282  new LifespanImpl(this.environment));
283  }
284  if (!this.policies.containsKey(Ownership.class)) {
285  this.policies.put(Ownership.class, new OwnershipImpl(
286  this.environment));
287  }
288  if (!this.policies.containsKey(OwnershipStrength.class)) {
289  this.policies.put(OwnershipStrength.class,
291  }
292  if (!this.policies.containsKey(DataRepresentation.class)) {
293  this.policies.put(DataRepresentation.class,
295  }
296  if (!this.policies.containsKey(UserData.class)) {
297  this.policies.put(UserData.class,
298  new UserDataImpl(this.environment));
299  }
300  if (!this.policies.containsKey(WriterDataLifecycle.class)) {
301  this.policies.put(WriterDataLifecycle.class,
303  }
304  }
305  }
306 
308  DDS.DataWriterQos oldQos) {
309 
310  if (oldQos == null) {
311  throw new IllegalArgumentExceptionImpl(env,
312  "oldQos parameter is null.");
313  }
314 
315  DataWriterQosImpl qos = new DataWriterQosImpl(env);
316 
317  qos.put(Deadline.class, PolicyConverter.convert(env, oldQos.deadline));
318  qos.put(DestinationOrder.class,
319  PolicyConverter.convert(env, oldQos.destination_order));
320  qos.put(Durability.class,
321  PolicyConverter.convert(env, oldQos.durability));
322  qos.put(History.class, PolicyConverter.convert(env, oldQos.history));
323  qos.put(LatencyBudget.class,
324  PolicyConverter.convert(env, oldQos.latency_budget));
325  qos.put(Lifespan.class, PolicyConverter.convert(env, oldQos.lifespan));
326  qos.put(Liveliness.class,
327  PolicyConverter.convert(env, oldQos.liveliness));
328  qos.put(Ownership.class, PolicyConverter.convert(env, oldQos.ownership));
329  qos.put(OwnershipStrength.class,
330  PolicyConverter.convert(env, oldQos.ownership_strength));
331  qos.put(Reliability.class,
332  PolicyConverter.convert(env, oldQos.reliability));
333  qos.put(ResourceLimits.class,
334  PolicyConverter.convert(env, oldQos.resource_limits));
335  qos.put(TransportPriority.class,
336  PolicyConverter.convert(env, oldQos.transport_priority));
337  qos.put(UserData.class, PolicyConverter.convert(env, oldQos.user_data));
338  qos.put(WriterDataLifecycle.class,
339  PolicyConverter.convert(env, oldQos.writer_data_lifecycle));
340 
341  return qos;
342  }
343 
344  public DDS.DataWriterQos convert() {
345  DDS.DataWriterQos old = new DDS.DataWriterQos();
346  synchronized (this.policies) {
347  old.deadline = PolicyConverter.convert(this.environment,
348  ((Deadline) this.policies.get(Deadline.class)));
349  old.destination_order = PolicyConverter.convert(this.environment,
350  ((DestinationOrder) this.policies
351  .get(DestinationOrder.class)));
352  old.durability = PolicyConverter.convert(this.environment,
353  ((Durability) this.policies.get(Durability.class)));
354  old.history = PolicyConverter.convert(this.environment,
355  ((History) this.policies.get(History.class)));
356  old.latency_budget = PolicyConverter.convert(this.environment,
357  ((LatencyBudget) this.policies.get(LatencyBudget.class)));
358  old.lifespan = PolicyConverter.convert(this.environment,
359  ((Lifespan) this.policies.get(Lifespan.class)));
360  old.liveliness = PolicyConverter.convert(this.environment,
361  ((Liveliness) this.policies.get(Liveliness.class)));
362  old.ownership = PolicyConverter.convert(this.environment,
363  ((Ownership) this.policies.get(Ownership.class)));
364  old.ownership_strength = PolicyConverter.convert(this.environment,
366  .get(OwnershipStrength.class)));
367  old.reliability = PolicyConverter.convert(this.environment,
368  ((Reliability) this.policies.get(Reliability.class)));
369  old.resource_limits = PolicyConverter.convert(this.environment,
370  ((ResourceLimits) this.policies.get(ResourceLimits.class)));
371  old.transport_priority = PolicyConverter.convert(this.environment,
373  .get(TransportPriority.class)));
374  old.user_data = PolicyConverter.convert(this.environment,
375  ((UserData) this.policies
376  .get(UserData.class)));
377  old.writer_data_lifecycle = PolicyConverter.convert(
379  .get(WriterDataLifecycle.class)));
380  }
381 
382 
383  return old;
384  }
385 
386 }
Specifies the configuration of the durability service.
[optional] Specifies the value of the "strength" used to arbitrate among multiple org...
Specifies the behavior of the org.omg.dds.pub.DataWriter with regards to the life cycle of the data i...
Specifies the maximum acceptable delay from the time the data is written until the data is inserted i...
LatencyBudget getLatencyBudget()
User data not known by the middleware, but distributed by means of built-in topics.
Definition: UserData.java:48
DataRepresentation getRepresentation()
TypeConsistencyEnforcement getTypeConsistency()
void setupPolicies(Collection< T > policies)
TransportPriority getTransportPriority()
DataWriterQosImpl(OsplServiceEnvironment environment, TypeConsistencyEnforcement typeConsistencyEnforcement, ForDataWriter... policies)
DestinationOrder getDestinationOrder()
static DataWriterQosImpl convert(OsplServiceEnvironment env, DDS.DataWriterQos oldQos)
T put(Class<? extends T > arg0, T arg1)
Reliability getReliability()
A QosPolicy interface that implements this marker interface applies to org.omg.dds.pub.DataWriter Entities.
Definition: QosPolicy.java:169
DataWriterQos withPolicy(ForDataWriter policy)
static DDS.UserDataQosPolicy convert(OsplServiceEnvironment env, UserData p)
Determines the mechanism and parameters used by the application to determine whether an org...
DataWriterQosImpl(OsplServiceEnvironment environment)
This policy is a hint to the infrastructure as to how to set the priority of the underlying transport...
This class is the abstract root for all the QoS policies.
Definition: QosPolicy.java:118
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).
DataWriterQos withPolicies(ForDataWriter... policy)
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.
org.omg.dds.sub.DataReader expects a new sample updating the value of each instance at least once eve...
Definition: Deadline.java:92
This QosPolicy specifies whether a DataWriter exclusively may own an instance.
Definition: Ownership.java:63
ResourceLimits getResourceLimits()
Specifies the maximum duration of validity of the data written by the org.omg.dds.pub.DataWriter.
Definition: Lifespan.java:57
Specifies the behavior of the Service in the case where the value of a sample changes (one or more ti...
Definition: History.java:76