OpenSplice Java 5 DCPS  v6.x
OpenSplice Java 5 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
PresentationImpl.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.core.policy;
22 
27 
28 public class PresentationImpl extends QosPolicyImpl implements Presentation {
29  private static final long serialVersionUID = 2403290580864742451L;
30  private final boolean coherentAccess;
31  private final boolean orderedAccess;
32  private final AccessScopeKind accessScope;
33 
35  super(environment);
36  this.coherentAccess = false;
37  this.orderedAccess = false;
38  this.accessScope = AccessScopeKind.INSTANCE;
39  }
40 
42  AccessScopeKind accessScope, boolean coherentAccess,
43  boolean orderedAccess) {
44  super(environment);
45 
46  if (accessScope == null) {
47  throw new IllegalArgumentExceptionImpl(environment,
48  "Supplied access scope is invalid.");
49  }
50  this.accessScope = accessScope;
51  this.coherentAccess = coherentAccess;
52  this.orderedAccess = orderedAccess;
53  }
54 
55  @Override
56  public Comparable<Presentation> requestedOfferedContract() {
57  return this;
58  }
59 
60  @Override
61  public int compareTo(Presentation o) {
62  AccessScopeKind other = o.getAccessScope();
63 
64  /* INSTANCE < TOPIC < GROUP */
65  /* offered access_scope >= requested access_scope */
66  if (other.equals(this.accessScope)) {
67  if (this.coherentAccess == o.isCoherentAccess()) {
68  if (this.orderedAccess == o.isOrderedAccess()) {
69  return 0;
70  } else if (this.orderedAccess) {
71  return 1;
72  }
73  return -1;
74  } else if (this.orderedAccess == o.isOrderedAccess()) {
75  if (this.coherentAccess) {
76  return 1;
77  }
78  return -1;
79  } else if (this.coherentAccess) {
80  return 1;
81  }
82  return -1;
83  } else if (this.accessScope.equals(AccessScopeKind.INSTANCE)) {
84  return -1;
85  } else if (this.accessScope.equals(AccessScopeKind.TOPIC)) {
86  if (other.equals(AccessScopeKind.INSTANCE)) {
87  return 1;
88  }
89  return -1;
90  }
91  return 1;
92  }
93 
94  @Override
95  public boolean equals(Object other) {
96  if (!(other instanceof PresentationImpl)) {
97  return false;
98  }
99  PresentationImpl p = (PresentationImpl) other;
100 
101  if (p.coherentAccess != this.coherentAccess) {
102  return false;
103  }
104  if (p.orderedAccess != this.orderedAccess) {
105  return false;
106  }
107  if (p.accessScope != this.accessScope) {
108  return false;
109  }
110  return true;
111  }
112 
113  @Override
115  return this.accessScope;
116  }
117 
118  @Override
119  public boolean isCoherentAccess() {
120  return this.coherentAccess;
121  }
122 
123  @Override
124  public boolean isOrderedAccess() {
125  return this.orderedAccess;
126  }
127 
128  @Override
130  return new PresentationImpl(this.environment, accessScope,
131  this.coherentAccess, this.orderedAccess);
132  }
133 
134  @Override
135  public Presentation withCoherentAccess(boolean coherentAccess) {
136  return new PresentationImpl(this.environment, this.accessScope,
137  coherentAccess, this.orderedAccess);
138  }
139 
140  @Override
141  public Presentation withOrderedAccess(boolean orderedAccess) {
142  return new PresentationImpl(this.environment, this.accessScope,
143  this.coherentAccess, orderedAccess);
144  }
145 
146  @Override
149  this.coherentAccess, this.orderedAccess);
150  }
151 
152  @Override
155  this.coherentAccess, this.orderedAccess);
156  }
157 
158  @Override
161  this.coherentAccess, this.orderedAccess);
162  }
163 
164  @Override
165  public Class<? extends QosPolicy> getPolicyClass() {
166  return Presentation.class;
167  }
168 
169  @Override
170  public int hashCode() {
171  final int prime = 31;
172  int result = 17;
173 
174  result = prime * result + this.accessScope.hashCode();
175  result = prime * result + (this.coherentAccess ? 1 : 0);
176 
177  return prime * result + (this.orderedAccess ? 1 : 0);
178  }
179 }
boolean isCoherentAccess()
If coherentAccess is set, then the accessScope controls the maximum extent of coherent changes...
boolean isCoherentAccess()
If coherentAccess is set, then the accessScope controls the maximum extent of coherent changes...
Presentation withAccessScope(AccessScopeKind accessScope)
Copy this policy and override the value of the property.
PresentationImpl(OsplServiceEnvironment environment, AccessScopeKind accessScope, boolean coherentAccess, boolean orderedAccess)
Comparable< Presentation > requestedOfferedContract()
Presentation withCoherentAccess(boolean coherentAccess)
Copy this policy and override the value of the property.
Specifies how the samples representing changes to data instances are presented to the subscribing app...
INSTANCE
Scope spans only a single instance.
This class is the abstract root for all the QoS policies.
Definition: QosPolicy.java:118
boolean isOrderedAccess()
If orderedAccess is set, then the accessScope controls the maximum extent for which order will be pre...
boolean isOrderedAccess()
If orderedAccess is set, then the accessScope controls the maximum extent for which order will be pre...
PresentationImpl(OsplServiceEnvironment environment)
TOPIC
Scope spans to all instances within the same org.omg.dds.pub.DataWriter (or org.omg.dds.sub.DataReader), but not across instances in different DataWriter (or DataReader).
GROUP
[optional] Scope spans to all instances belonging to org.omg.dds.pub.DataWriter (or org...
Presentation withOrderedAccess(boolean orderedAccess)
Copy this policy and override the value of the property.