OpenSplice Java 5 DCPS  v6.x
OpenSplice Java 5 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
TopicQosImpl.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.topic;
22 
24 import org.omg.dds.core.policy.Deadline;
30 import org.omg.dds.core.policy.History;
32 import org.omg.dds.core.policy.Lifespan;
46 import org.omg.dds.core.policy.UserData;
48 import org.omg.dds.topic.TopicQos;
75 
76 public class TopicQosImpl extends EntityQosImpl<ForTopic> implements TopicQos {
77  private static final long serialVersionUID = -1401988185243587729L;
78  private final TypeConsistencyEnforcement typeConsistencyEnforcement;
79 
81  TypeConsistencyEnforcement typeConsistencyEnforcement,
82  ForTopic... policies) {
83  super(environment, policies);
84  this.typeConsistencyEnforcement = typeConsistencyEnforcement;
85  }
86 
88  super(environment);
89  this.typeConsistencyEnforcement = new TypeConsistencyEnforcementImpl(
90  environment, Kind.EXACT_TYPE_TYPE_CONSISTENCY);
91  }
92 
93  private TopicQosImpl(TopicQosImpl source, ForTopic... policy) {
94  super(source.environment, source.policies.values());
95  this.typeConsistencyEnforcement = source.typeConsistencyEnforcement;
96  setupPolicies(policy);
97  }
98 
99  @Override
101  synchronized (this.policies) {
102  return (TopicData) this.policies.get(TopicData.class);
103  }
104  }
105 
106  @Override
108  synchronized (this.policies) {
109  return (Durability) this.policies.get(Durability.class);
110  }
111  }
112 
113  @Override
115  synchronized (this.policies) {
116  return (DurabilityService) this.policies.get(DurabilityService.class);
117  }
118  }
119 
120  @Override
122  synchronized (this.policies) {
123  return (Deadline) this.policies.get(Deadline.class);
124  }
125  }
126 
127  @Override
129  synchronized (this.policies) {
130  return (LatencyBudget) this.policies.get(LatencyBudget.class);
131  }
132  }
133 
134  @Override
136  synchronized (this.policies) {
137  return (Liveliness) this.policies.get(Liveliness.class);
138  }
139  }
140 
141  @Override
143  synchronized (this.policies) {
144  return (Reliability) this.policies.get(Reliability.class);
145  }
146  }
147 
148  @Override
150  synchronized (this.policies) {
151  return (DestinationOrder) this.policies.get(DestinationOrder.class);
152  }
153  }
154 
155  @Override
156  public History getHistory() {
157  synchronized (this.policies) {
158  return (History) this.policies.get(History.class);
159  }
160  }
161 
162  @Override
164  synchronized (this.policies) {
165  return (ResourceLimits) this.policies.get(ResourceLimits.class);
166  }
167  }
168 
169  @Override
171  synchronized (this.policies) {
172  return (TransportPriority) this.policies.get(TransportPriority.class);
173  }
174  }
175 
176  @Override
178  synchronized (this.policies) {
179  return (Lifespan) this.policies.get(Lifespan.class);
180  }
181  }
182 
183  @Override
185  synchronized (this.policies) {
186  return (Ownership) this.policies.get(Ownership.class);
187  }
188  }
189 
190  @Override
192  synchronized (this.policies) {
193  return (DataRepresentation) this.policies.get(DataRepresentation.class);
194  }
195  }
196 
197  @Override
199  return this.typeConsistencyEnforcement;
200  }
201 
202  @Override
203  protected void setupMissingPolicies() {
204  synchronized (this.policies) {
205  if (!this.policies.containsKey(TopicData.class)) {
206  this.policies.put(TopicData.class, new TopicDataImpl(
207  environment));
208  }
209  if (!this.policies.containsKey(Durability.class)) {
210  this.policies.put(Durability.class, new DurabilityImpl(
211  this.environment));
212  }
213  if (!this.policies.containsKey(DurabilityService.class)) {
214  this.policies.put(DurabilityService.class,
216  }
217  if (!this.policies.containsKey(Deadline.class)) {
218  this.policies.put(Deadline.class,
219  new DeadlineImpl(this.environment));
220  }
221  if (!this.policies.containsKey(LatencyBudget.class)) {
222  this.policies.put(LatencyBudget.class, new LatencyBudgetImpl(
223  this.environment));
224  }
225  if (!this.policies.containsKey(Liveliness.class)) {
226  this.policies.put(Liveliness.class, new LivelinessImpl(
227  this.environment));
228  }
229  if (!this.policies.containsKey(Reliability.class)) {
230  this.policies.put(Reliability.class, new ReliabilityImpl(
231  this.environment));
232  }
233  if (!this.policies.containsKey(DestinationOrder.class)) {
234  this.policies.put(DestinationOrder.class, new DestinationOrderImpl(
235  this.environment));
236  }
237  if (!this.policies.containsKey(History.class)) {
238  this.policies.put(History.class, new HistoryImpl(this.environment));
239  }
240  if (!this.policies.containsKey(ResourceLimits.class)) {
241  this.policies.put(ResourceLimits.class, new ResourceLimitsImpl(
242  this.environment));
243  }
244  if (!this.policies.containsKey(TransportPriority.class)) {
246  this.environment));
247  }
248  if (!this.policies.containsKey(Lifespan.class)) {
249  this.policies.put(Lifespan.class,
250  new LifespanImpl(this.environment));
251  }
252  if (!this.policies.containsKey(Ownership.class)) {
253  this.policies.put(Ownership.class, new OwnershipImpl(
254  this.environment));
255  }
256  if (!this.policies.containsKey(DataRepresentation.class)) {
258  this.environment));
259  }
260  }
261  }
262 
263  @Override
265  return this.withPolicies(policy);
266  }
267 
268  @Override
270  synchronized (this.policies) {
271  return new TopicQosImpl(this, policy);
272  }
273  }
274 
276  DDS.TopicQos oldQos) {
277 
278  if (oldQos == null) {
279  throw new IllegalArgumentExceptionImpl(env,
280  "oldQos parameter is null.");
281  }
282 
283  TopicQosImpl qos = new TopicQosImpl(env);
284 
285  qos.put(Deadline.class, PolicyConverter.convert(env, oldQos.deadline));
286  qos.put(DestinationOrder.class,
287  PolicyConverter.convert(env, oldQos.destination_order));
288  qos.put(Durability.class,
289  PolicyConverter.convert(env, oldQos.durability));
290  qos.put(DurabilityService.class,
291  PolicyConverter.convert(env, oldQos.durability_service));
292  qos.put(History.class, PolicyConverter.convert(env, oldQos.history));
293  qos.put(LatencyBudget.class,
294  PolicyConverter.convert(env, oldQos.latency_budget));
295  qos.put(Lifespan.class, PolicyConverter.convert(env, oldQos.lifespan));
296  qos.put(Liveliness.class,
297  PolicyConverter.convert(env, oldQos.liveliness));
298  qos.put(Ownership.class, PolicyConverter.convert(env, oldQos.ownership));
299  qos.put(Reliability.class,
300  PolicyConverter.convert(env, oldQos.reliability));
301  qos.put(ResourceLimits.class,
302  PolicyConverter.convert(env, oldQos.resource_limits));
303  qos.put(TopicData.class,
304  PolicyConverter.convert(env, oldQos.topic_data));
305  qos.put(TransportPriority.class,
306  PolicyConverter.convert(env, oldQos.transport_priority));
307 
308  return qos;
309  }
310 
311  public DDS.TopicQos convert() {
312  DDS.TopicQos old = new DDS.TopicQos();
313 
314  synchronized (this.policies) {
315  old.deadline = PolicyConverter.convert(this.environment,
316  ((Deadline) this.policies
317  .get(Deadline.class)));
318  old.destination_order = PolicyConverter
319 .convert(this.environment,
320  ((DestinationOrder) this.policies
321  .get(DestinationOrder.class)));
322  old.durability = PolicyConverter
323 .convert(this.environment,
324  ((Durability) this.policies.get(Durability.class)));
325  old.durability_service = PolicyConverter
326 .convert(this.environment,
328  .get(DurabilityService.class)));
329  old.history = PolicyConverter.convert(this.environment,
330  ((History) this.policies
331  .get(History.class)));
332  old.latency_budget = PolicyConverter
333 .convert(this.environment,
334  ((LatencyBudget) this.policies
335  .get(LatencyBudget.class)));
336  old.lifespan = PolicyConverter.convert(this.environment,
337  ((Lifespan) this.policies
338  .get(Lifespan.class)));
339  old.liveliness = PolicyConverter
340 .convert(this.environment,
341  ((Liveliness) this.policies.get(Liveliness.class)));
342  old.ownership = PolicyConverter.convert(this.environment,
343  ((Ownership) this.policies
344  .get(Ownership.class)));
345  old.reliability = PolicyConverter
346 .convert(this.environment,
347  ((Reliability) this.policies
348  .get(Reliability.class)));
349  old.resource_limits = PolicyConverter
350 .convert(this.environment,
351  ((ResourceLimits) this.policies
352  .get(ResourceLimits.class)));
353  old.topic_data = PolicyConverter.convert(this.environment,
354  ((TopicData) this.policies
355  .get(TopicData.class)));
356  old.transport_priority = PolicyConverter
357 .convert(this.environment,
359  .get(TransportPriority.class)));
360  }
361 
362  return old;
363  }
364 
365 }
Specifies the configuration of the durability service.
TopicQos withPolicies(QosPolicy.ForTopic... policy)
TypeConsistencyEnforcement getTypeConsistency()
Specifies the behavior of the org.omg.dds.sub.DataReader 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...
Filter that allows a org.omg.dds.sub.DataReader to specify that it is interested only in (potentially...
User data not known by the middleware, but distributed by means of built-in topics.
Definition: UserData.java:48
This policy allows the introduction of a logical partition concept inside the "physical" partition in...
Definition: Partition.java:86
TopicQosImpl(OsplServiceEnvironment environment, TypeConsistencyEnforcement typeConsistencyEnforcement, ForTopic... policies)
void setupPolicies(Collection< T > policies)
static TopicQosImpl convert(OsplServiceEnvironment env, DDS.TopicQos oldQos)
T put(Class<? extends T > arg0, T arg1)
TopicQosImpl(OsplServiceEnvironment environment)
Specifies how the samples representing changes to data instances are presented to the subscribing app...
User data not known by the middleware, but distributed by means of built-in topics.
Definition: GroupData.java:44
TopicQos withPolicy(QosPolicy.ForTopic policy)
static DDS.UserDataQosPolicy convert(OsplServiceEnvironment env, UserData p)
Determines the mechanism and parameters used by the application to determine whether an org...
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).
A QosPolicy interface that implements this marker interface applies to org.omg.dds.topic.Topic Entities.
Definition: QosPolicy.java:160
HashMap< Class<? extends T >, T > policies
Specifies the resources that the Service can consume in order to meet the requested QoS...
Controls the behavior of the org.omg.dds.core.Entity when acting as a factory for other entities...
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
Specifies the maximum duration of validity of the data written by the org.omg.dds.pub.DataWriter.
Definition: Lifespan.java:57
User data not known by the middleware, but distributed by means of built-in topics.
Definition: TopicData.java:42
Specifies the behavior of the Service in the case where the value of a sample changes (one or more ti...
Definition: History.java:76