21 package org.opensplice.dds.sub;
23 import java.util.ArrayList;
24 import java.util.Arrays;
25 import java.util.Collection;
26 import java.util.HashMap;
27 import java.util.HashSet;
28 import java.util.List;
56 DomainEntityImpl<DDS.Subscriber, DomainParticipantImpl, DDS.DomainParticipant, SubscriberQos, SubscriberListener, SubscriberListenerImpl>
64 Collection<Class<? extends Status>> statuses) {
65 super(environment, parent, parent.
getOld());
66 DDS.SubscriberQos oldQos;
70 "Supplied SubscriberQos is null.");
75 }
catch (ClassCastException e) {
77 "Cannot create Subscribe with non-OpenSplice qos");
80 if (listener != null) {
86 DDS.Subscriber old = this.parent.
getOld().create_subscriber(oldQos,
95 this.isBuiltin =
false;
97 if (this.listener != null) {
98 this.listener.setInitialised();
104 super(environment, parent, parent.
getOld());
106 if (oldSubscriber == null) {
108 "Supplied Subscriber is invalid (null).");
111 this.
setOld(oldSubscriber);
113 this.isBuiltin =
true;
124 if (listener != null) {
128 wrapperListener = null;
130 rc = this.
getOld().set_listener(wrapperListener, mask);
132 "Subscriber.setListener() failed.");
134 this.listener = wrapperListener;
144 Collection<Class<? extends Status>> statuses) {
145 this.setListener(listener,
151 Class<? extends Status>... statuses) {
152 this.setListener(listener,
158 DDS.SubscriberQosHolder holder =
new DDS.SubscriberQosHolder();
159 int rc = this.
getOld().get_qos(holder);
161 "Subscriber.getQos() failed.");
172 "Supplied SubscriberQos is null.");
176 }
catch (ClassCastException e) {
178 "Setting non-OpenSplice Qos not supported.");
182 "Subscriber.setQos() failed.");
189 null,
new HashSet<Class<? extends Status>>());
196 Collection<Class<? extends Status>> statuses) {
202 "Supplied Topic is null.");
204 synchronized (this.readers) {
211 this.readers.put(reader.
getOld(), reader);
212 }
catch (ClassCastException e) {
214 "Cannot create DataReader with non-OpenSplice Topic");
224 Class<? extends Status>... statuses) {
225 return this.createDataReader(topic, qos, listener,
226 Arrays.asList(statuses));
232 return this.createDataReader(topic, qos, null,
233 new HashSet<Class<? extends Status>>());
238 if (topicName == null) {
240 "Supplied topicName is null.");
242 synchronized (this.readers) {
244 if (topicName.equals(reader.getTopicDescription().getName())) {
246 return reader.cast();
247 }
catch (ClassCastException e) {
250 "Cannot cast DataReader to desired type.");
254 DDS.DataReader builtinReader = this.
getOld()
255 .lookup_datareader(topicName);
257 if (builtinReader != null) {
258 return this.initBuiltinReader(builtinReader);
267 if (topicDescription == null) {
269 "Supplied topicName is null.");
271 synchronized (this.readers) {
273 if (topicDescription.equals(reader.getTopicDescription())) {
275 return reader.cast();
276 }
catch (ClassCastException e) {
279 "Cannot cast DataReader to desired type.");
283 DDS.DataReader builtinReader = this.
getOld()
284 .lookup_datareader(topicDescription.
getName());
286 if (builtinReader != null) {
287 return this.initBuiltinReader(builtinReader, topicDescription);
294 DDS.DataReader oldBuiltin) {
297 if (oldBuiltin != null) {
298 DDS.TopicDescription classicTopicDescription = oldBuiltin
299 .get_topicdescription();
301 if (classicTopicDescription != null) {
303 .lookupTopicDescription(
304 classicTopicDescription.get_name());
307 result = this.initBuiltinReader(oldBuiltin, td);
311 "Classic DataReader has no TopicDescription.");
321 if (oldBuiltin != null) {
324 synchronized (this.readers) {
325 this.readers.put(result.
getOld(), result);
334 synchronized (this.readers) {
338 result = found.cast();
339 }
else if (this.isBuiltin) {
340 result = this.initBuiltinReader(old);
350 synchronized (this.readers) {
364 DDS.DataReaderSeqHolder oldReaders =
new DDS.DataReaderSeqHolder();
366 synchronized (this.readers) {
367 int rc = this.
getOld().get_datareaders(oldReaders,
368 DDS.ANY_SAMPLE_STATE.value, DDS.ANY_VIEW_STATE.value,
369 DDS.ANY_INSTANCE_STATE.value);
371 "Subscriber.getDataReaders() failed.");
373 for (DDS.DataReader oldReader : oldReaders.value) {
374 readers.add(this.readers.get(oldReader));
382 List<DataReader<?>> readers =
new ArrayList<DataReader<?>>();
383 DDS.DataReaderSeqHolder oldReaders =
new DDS.DataReaderSeqHolder();
385 synchronized (this.readers) {
386 int rc = this.
getOld().get_datareaders(oldReaders,
387 DDS.ANY_SAMPLE_STATE.value, DDS.ANY_VIEW_STATE.value,
388 DDS.ANY_INSTANCE_STATE.value);
390 "Subscriber.getDataReaders() failed.");
392 for (DDS.DataReader oldReader : oldReaders.value) {
393 readers.add(this.readers.get(oldReader));
400 if (dataState == null) {
402 "Supplied DataState is null.");
404 List<DataReader<?>> readers =
new ArrayList<DataReader<?>>();
405 DDS.DataReaderSeqHolder oldReaders =
new DDS.DataReaderSeqHolder();
410 synchronized (this.readers) {
411 int rc = this.
getOld().get_datareaders(oldReaders,
415 "Subscriber.getDataReaders() failed.");
417 for (DDS.DataReader oldReader : oldReaders.value) {
418 readers.add(this.readers.get(oldReader));
421 }
catch (ClassCastException e) {
423 "Non-OpenSplice DataState implementation not supported.");
430 int rc = this.
getOld().notify_datareaders();
432 "Subscriber.notifyDataReaders() failed.");
438 int rc = this.
getOld().begin_access();
440 "Subscriber.beginAccess() failed.");
445 int rc = this.
getOld().end_access();
447 "Subscriber.endAccess() failed.");
452 DDS.DataReaderQosHolder holder =
new DDS.DataReaderQosHolder();
453 int rc = this.
getOld().get_default_datareader_qos(holder);
455 "Subscriber.getDefaultDataReaderQos() failed.");
463 "Supplied DataReaderQoS is null.");
466 this.
getOld().set_default_datareader_qos(
469 }
catch (ClassCastException e) {
471 "Non-OpenSplice DataReaderQos not supported.");
481 "Supplied TopicQos is null.");
485 "Supplied DataReaderQos is null.");
489 }
catch (ClassCastException e) {
491 "Non-OpenSplice DataReaderQos not supported.");
500 DDS.StatusCondition oldCondition = this.
getOld().get_statuscondition();
502 if (oldCondition == null) {
522 this.
parent.destroySubscriber(
this);
526 DDS.DataReader old = dataReader.
getOld();
527 old.delete_contained_entities();
528 int rc = this.
getOld().delete_datareader(old);
529 synchronized (this.readers) {
530 this.readers.remove(old);
533 "DataReader.close() failed.");
Since a org.omg.dds.sub.DataReader is a kind of org.omg.dds.core.Entity, it has the ability to have a...
A DataReader allows the application (1) to declare the data it wishes to receive (i.e., make a subscription) and (2) to access the data received by the attached org.omg.dds.sub.Subscriber.
SubscriberImpl(OsplServiceEnvironment environment, DomainParticipantImpl parent, SubscriberQos qos, SubscriberListener listener, Collection< Class<? extends Status >> statuses)
A Subscriber is the object responsible for the actual reception of the data resulting from its subscr...
The DomainParticipant object plays several roles:
A StatusCondition object is an immutable object that specifies Condition that is associated with each...
int getOldInstanceState()
StatusCondition< Subscriber > getStatusCondition()
static SubscriberQosImpl convert(OsplServiceEnvironment env, DDS.SubscriberQos oldQos)
org.omg.dds.domain.DomainParticipant getParent()
Collection< DataReader<?> > getDataReaders()
This operation is equivalent to calling getDataReaders(DataState) with any sample state ( Subscriber...
A DataState encapsulates sets of sample states, view states, and instance states as a convenience...
void closeContainedEntities()
This operation closes all the entities that were created by means of the "create" operations on the S...
DataReaderQos getDefaultDataReaderQos()
This operation retrieves the default value of the DataReader QoS, that is, the QoS policies which wil...
SubscriberImpl(OsplServiceEnvironment environment, DomainParticipantImpl parent, DDS.Subscriber oldSubscriber)
void mergeTopicQos(TopicQos topicQos)
DataWriter allows the application to set the value of the data to be published under a given org...
void beginAccess()
This operation indicates that the application is about to access the data samples in any of the org...
void setListener(SubscriberListener listener, Class<? extends Status >... statuses)
void setDefaultDataReaderQos(DataReaderQos qos)
This operation sets a default value of the DataReader QoS policies, which will be used for newly crea...
static Set< Class<? extends Status > > convertMask(OsplServiceEnvironment environment, int state)
void notifyDataReaders()
This operation invokes the operation org.omg.dds.sub.DataReaderListener#onDataAvailable(org.omg.dds.core.event.DataAvailableEvent) on the DataReaderListener objects attached to contained DataReader entities with a org.omg.dds.core.event.DataAvailableEvent that is considered changed.
DDS.DataReaderQos convert()
Since a org.omg.dds.sub.Subscriber is a kind of org.omg.dds.core.Entity, it has the ability to have a...
static void checkReturnCode(int retCode, OsplServiceEnvironment environment, String message)
void endAccess()
Indicates that the application has finished accessing the data samples in org.omg.dds.sub.DataReader objects managed by the Subscriber.
void destroyDataReader(AbstractDataReader<?> dataReader)
void setListener(SubscriberListener listener, Collection< Class<? extends Status >> statuses)
The target object was previously closed and therefore cannot process the operation.
Collection< DataReader<?> > getDataReaders(Collection< DataReader<?>> readers)
void setListener(SubscriberListener listener)
String getName()
Returns the name used to create the TopicDescription.
DataReaderQos copyFromTopicQos(DataReaderQos drQos, TopicQos tQos)
This operation copies the policies in the org.omg.dds.topic.TopicQos to the corresponding policies in...
void setQos(SubscriberQos qos)
final transient OsplServiceEnvironment environment
static void throwLastErrorException(OsplServiceEnvironment environment)
This interface is the base for org.omg.dds.topic.Topic, org.omg.dds.topic.ContentFilteredTopic, and org.omg.dds.topic.MultiTopic.
Collection< DataReader<?> > getDataReaders(DataState dataState)
This operation allows the application to access the org.omg.dds.sub.DataReader objects that contain s...
Status is the abstract root class for all communication status objects.
abstract AbstractDataReader< TYPE > createDataReader(SubscriberImpl subscriber, TopicDescriptionExt< TYPE > topicDescription, DataReaderQos qos, DataReaderListener< TYPE > listener, Collection< Class<? extends Status >> statuses)
DataState createDataState()
Create and return a new modifiable DataState object.