OpenSplice Java 5 DCPS  v6.x
OpenSplice Java 5 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
QosProviderImpl.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;
22 
23 import org.omg.dds.core.QosProvider;
27 import org.omg.dds.pub.DataWriterQos;
28 import org.omg.dds.pub.PublisherQos;
29 import org.omg.dds.sub.DataReaderQos;
30 import org.omg.dds.sub.SubscriberQos;
31 import org.omg.dds.topic.TopicQos;
38 
39 import DDS.DataReaderQosHolder;
40 import DDS.DataWriterQosHolder;
41 import DDS.PublisherQosHolder;
42 import DDS.SubscriberQosHolder;
43 
44 public class QosProviderImpl extends QosProvider {
45  private final OsplServiceEnvironment environment;
46  private DDS.QosProvider old;
47 
48  public QosProviderImpl(OsplServiceEnvironment environment, String uri,
49  String profile) {
50  if (uri == null) {
51  throw new IllegalArgumentExceptionImpl(environment, "Invalid uri provided");
52  }
53  this.environment = environment;
54  try {
55  this.old = new DDS.QosProvider(uri, profile);
56  } catch (NullPointerException npe) {
57  Utilities.throwLastErrorException(this.environment);
58  }
59  }
60 
61  @Override
63  return this.environment;
64  }
65 
66  @Override
68  return this.getDomainParticipantFactoryQos(null);
69  }
70 
71  @Override
73  throw new UnsupportedOperationExceptionImpl(this.environment,
74  "QosProvider.getDomainParticipantFactoryQos() not supported.");
75  }
76 
77  @Override
79  return this.getDomainParticipantQos(null);
80  }
81 
82  @Override
84  DDS.DomainParticipantQosHolder holder = new DDS.DomainParticipantQosHolder();
85  int rc = old.get_participant_qos(holder, id);
86  Utilities.checkReturnCode(rc, this.environment,
87  "QosProvider.getDomainParticipantQos() failed.");
88  if (rc == DDS.RETCODE_NO_DATA.value) {
89  return null;
90  }
91  return DomainParticipantQosImpl.convert(this.environment, holder.value);
92  }
93 
94  @Override
95  public TopicQos getTopicQos() {
96  return this.getTopicQos(null);
97  }
98 
99  @Override
100  public TopicQos getTopicQos(String id) {
101  DDS.TopicQosHolder holder = new DDS.TopicQosHolder();
102  int rc = old.get_topic_qos(holder, id);
103  Utilities.checkReturnCode(rc, this.environment,
104  "QosProvider.getTopicQos() failed.");
105  if (rc == DDS.RETCODE_NO_DATA.value) {
106  return null;
107  }
108  return TopicQosImpl.convert(this.environment, holder.value);
109  }
110 
111  @Override
113  return this.getSubscriberQos(null);
114  }
115 
116  @Override
117  public SubscriberQos getSubscriberQos(String id) {
118  SubscriberQosHolder holder = new SubscriberQosHolder();
119  int rc = this.old.get_subscriber_qos(holder, id);
120  Utilities.checkReturnCode(rc, this.environment,
121  "QosProvider.getSubscriberQos() failed.");
122  if (rc == DDS.RETCODE_NO_DATA.value) {
123  return null;
124  }
125  return SubscriberQosImpl.convert(this.environment, holder.value);
126  }
127 
128  @Override
130  return this.getPublisherQos(null);
131  }
132 
133  @Override
134  public PublisherQos getPublisherQos(String id) {
135  PublisherQosHolder holder = new PublisherQosHolder();
136  int rc = this.old.get_publisher_qos(holder, id);
137  Utilities.checkReturnCode(rc, this.environment,
138  "QosProvider.getPublisherQos() failed.");
139  if (rc == DDS.RETCODE_NO_DATA.value) {
140  return null;
141  }
142  return PublisherQosImpl.convert(this.environment, holder.value);
143  }
144 
145  @Override
147  return this.getDataReaderQos(null);
148  }
149 
150  @Override
151  public DataReaderQos getDataReaderQos(String id) {
152  DataReaderQosHolder holder = new DataReaderQosHolder();
153  int rc = this.old.get_datareader_qos(holder, id);
154  Utilities.checkReturnCode(rc, this.environment,
155  "QosProvider.getDataReaderQos() failed.");
156  if (rc == DDS.RETCODE_NO_DATA.value) {
157  return null;
158  }
159  return DataReaderQosImpl.convert(this.environment, holder.value);
160  }
161 
162  @Override
164  return this.getDataWriterQos(null);
165  }
166 
167  @Override
168  public DataWriterQos getDataWriterQos(String id) {
169  DataWriterQosHolder holder = new DataWriterQosHolder();
170  int rc = this.old.get_datawriter_qos(holder, id);
171  Utilities.checkReturnCode(rc, this.environment,
172  "QosProvider.getDataWriterQos() failed.");
173  if (rc == DDS.RETCODE_NO_DATA.value) {
174  return null;
175  }
176  return DataWriterQosImpl.convert(this.environment, holder.value);
177  }
178 
179 }
static PublisherQosImpl convert(OsplServiceEnvironment env, DDS.PublisherQos oldQos)
DomainParticipantFactoryQos getDomainParticipantFactoryQos(String id)
DomainParticipantQos getDomainParticipantQos()
static SubscriberQosImpl convert(OsplServiceEnvironment env, DDS.SubscriberQos oldQos)
static TopicQosImpl convert(OsplServiceEnvironment env, DDS.TopicQos oldQos)
static DomainParticipantQosImpl convert(OsplServiceEnvironment env, DDS.DomainParticipantQos oldQos)
static DataWriterQosImpl convert(OsplServiceEnvironment env, DDS.DataWriterQos oldQos)
QosProviderImpl(OsplServiceEnvironment environment, String uri, String profile)
DomainParticipantQos getDomainParticipantQos(String id)
static void checkReturnCode(int retCode, OsplServiceEnvironment environment, String message)
Definition: Utilities.java:33
The QoS provider API allows users to specify the QoS settings of their DCPS entities outside of appli...
DomainParticipantFactoryQos getDomainParticipantFactoryQos()
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