public IDataReader CreateDataReader( ITopicDescription topic, IDataReaderListener listener, StatusKind mask) { return(CreateDataReader(topic, defaultDataReaderQos, listener, mask)); }
internal override ReturnCode wlReq_deinit() { ReturnCode result = DDS.ReturnCode.Ok; if (conditionList.Count == 0) { IDataReaderListener drListener = listener as IDataReaderListener; if (drListener != null) { this.SetListener(drListener, (DDS.StatusKind) 0); } this.DisableCallbacks(); result = base.wlReq_deinit(); if (result == DDS.ReturnCode.Ok) { if (this.topic != null) { result = this.topic.DecrNrUsers(); if (result == DDS.ReturnCode.Ok) { this.topic = null; } this.subscriber = null; } } } else { result = DDS.ReturnCode.PreconditionNotMet; ReportStack.Report(result, "DataReader " + this + " cannot be deleted since it still contains " + conditionList.Count + " Read/QueryConditions."); } return(result); }
internal override void NotifyListener(Entity source, V_EVENT triggerMask, DDS.OpenSplice.Common.EntityStatus status) { ReturnCode result; IDataReaderListener drListener = listener as IDataReaderListener; if (drListener != null) { DDS.OpenSplice.Common.ReaderStatus readerStatus = status as DDS.OpenSplice.Common.ReaderStatus; if ((triggerMask & V_EVENT.DATA_AVAILABLE) == V_EVENT.DATA_AVAILABLE) { result = ResetDataAvailableStatus(); if (result == DDS.ReturnCode.Ok) { drListener.OnDataAvailable(source as IDataReader); } } if ((triggerMask & V_EVENT.SAMPLE_REJECTED) == V_EVENT.SAMPLE_REJECTED) { drListener.OnSampleRejected(source as IDataReader, readerStatus.SampleRejected); } if ((triggerMask & V_EVENT.LIVELINESS_CHANGED) == V_EVENT.LIVELINESS_CHANGED) { drListener.OnLivelinessChanged(source as IDataReader, readerStatus.LivelinessChanged); } if ((triggerMask & V_EVENT.SAMPLE_LOST) == V_EVENT.SAMPLE_LOST) { drListener.OnSampleLost(source as IDataReader, readerStatus.SampleLost); } if ((triggerMask & V_EVENT.REQUESTED_DEADLINE_MISSED) == V_EVENT.REQUESTED_DEADLINE_MISSED) { drListener.OnRequestedDeadlineMissed(source as IDataReader, readerStatus.DeadlineMissed); } if ((triggerMask & V_EVENT.REQUESTED_INCOMPATIBLE_QOS) == V_EVENT.REQUESTED_INCOMPATIBLE_QOS) { drListener.OnRequestedIncompatibleQos(source as IDataReader, readerStatus.IncompatibleQos); } if ((triggerMask & V_EVENT.SUBSCRIPTION_MATCHED) == V_EVENT.SUBSCRIPTION_MATCHED) { drListener.OnSubscriptionMatched(source as IDataReader, readerStatus.SubscriptionMatch); } } }
public ReturnCode SetListener(IDataReaderListener listener, StatusKind mask) { ReturnCode result = DDS.ReturnCode.AlreadyDeleted; ReportStack.Start(); lock (this) { if (this.rlReq_isAlive) { result = wlReq_SetListener(listener, mask); } } ReportStack.Flush(this, result != ReturnCode.Ok); return(result); }
internal void CreateListener(out OpenSplice.Gapi.gapi_dataReaderListener listener) { onRequestedDeadlineMissedDelegate = PrivateRequestedDeadlineMissed; onRequestedIncompatibleQosDelegate = PrivateRequestedIncompatibleQos; onSampleRejectedDelegate = PrivateSampleRejected; onLivelinessChangedDelegate = PrivateLivelinessChanged; onDataAvailableDelegate = PrivateDataAvailable; onSubscriptionMatchDelegate = PrivateSubscriptionMatched; onSampleLostDelegate = PrivateSampleLost; listener = new DDS.OpenSplice.Gapi.gapi_dataReaderListener(); listener.listener_data = IntPtr.Zero; listener.on_requested_deadline_missed = onRequestedDeadlineMissedDelegate; listener.on_requested_incompatible_qos = onRequestedIncompatibleQosDelegate; listener.on_sample_rejected = onSampleRejectedDelegate; listener.on_liveliness_changed = onLivelinessChangedDelegate; listener.on_data_available = onDataAvailableDelegate; listener.on_subscription_match = onSubscriptionMatchDelegate; listener.on_sample_lost = onSampleLostDelegate; }
public ReturnCode SetListener(IDataReaderListener listener, StatusKind mask) { ReturnCode result = ReturnCode.Error; if (listener != null) { Gapi.gapi_dataReaderListener gapiListener; if (listenerHelper == null) { // Since the real DataReader is created from the TypeSupport, // the listenerHelper is not "readonly" listenerHelper = new DataReaderListenerHelper(); } listenerHelper.Listener = listener; listenerHelper.CreateListener(out gapiListener); lock (listener) { using (DataReaderListenerMarshaler marshaler = new DataReaderListenerMarshaler(ref gapiListener)) { result = Gapi.DataReader.set_listener( GapiPeer, marshaler.GapiPtr, mask); } } } else { result = Gapi.DataReader.set_listener( GapiPeer, IntPtr.Zero, mask); } return(result); }
public ReturnCode SetListener(IDataReaderListener listener, StatusKind mask) { ReturnCode result = ReturnCode.Error; if (listener != null) { Gapi.gapi_dataReaderListener gapiListener; if (listenerHelper == null) { // Since the real DataReader is created from the TypeSupport, // the listenerHelper is not "readonly" listenerHelper = new DataReaderListenerHelper(); } listenerHelper.Listener = listener; listenerHelper.CreateListener(out gapiListener); lock (listener) { using (DataReaderListenerMarshaler marshaler = new DataReaderListenerMarshaler(ref gapiListener)) { result = Gapi.DataReader.set_listener( GapiPeer, marshaler.GapiPtr, mask); } } } else { result = Gapi.DataReader.set_listener( GapiPeer, IntPtr.Zero, mask); } return result; }
public IDataReader CreateDataReader( ITopicDescription topic, DataReaderQos qos, IDataReaderListener listener, StatusKind mask) { ReturnCode result = DDS.ReturnCode.AlreadyDeleted; DataReader dataReader = null; ITopicDescriptionImpl topicObj = topic as ITopicDescriptionImpl; ReportStack.Start(); lock (this) { if (this.rlReq_isAlive) { if (topicObj == null) { result = DDS.ReturnCode.BadParameter; ReportStack.Report(result, "TopicDescription is invalid (null), or not of type " + "DDS::OpenSplice::TopicDescription."); } else { result = QosManager.checkQos(qos); } if (result == DDS.ReturnCode.Ok) { lock (topicObj) { if ((topicObj as SacsSuperClass).rlReq_isAlive) { TypeSupport ts = topicObj.rlReq_TypeSupport; if (ts != null) { DatabaseMarshaler marshaler = DatabaseMarshaler.GetMarshaler(participant, ts.TypeSpec); dataReader = ts.CreateDataReader(marshaler); result = dataReader.init(this, qos, topicObj, "reader <" + topicObj.Name + ">"); if (result == ReturnCode.Ok) { dataReader.wlReq_ListenerDispatcher = this.wlReq_ListenerDispatcher; result = dataReader.SetListener(listener, mask); } else { dataReader = null; } if (result == DDS.ReturnCode.Ok) { readerList.Add(dataReader); if (rlReq_AutoEnableCreatedEntities && this.IsEnabled()) { result = dataReader.Enable(); } } } else { ReportStack.Report(DDS.ReturnCode.PreconditionNotMet, "Were not able to locate TypeSupport belonging to topic " + topic.Name + "."); } } else { // ALREADY_DELETED may only apply to the Subscriber in this context, // so for a deleted TopicDescription use BAD_PARAMETER instead. result = DDS.ReturnCode.BadParameter; } } if (result != ReturnCode.Ok && dataReader != null) { // Ignore result because we prefer the original error. DeleteDataReader(dataReader); dataReader = null; } } } } ReportStack.Flush(this, result != ReturnCode.Ok); return(dataReader); }
public IDataReader CreateDataReader( ITopicDescription topic, IDataReaderListener listener, StatusKind mask) { DataReader dataReader = null; if (topic != null) { SacsSuperClass superObj = (SacsSuperClass)topic; if (listener != null) { OpenSplice.Gapi.gapi_dataReaderListener gapiListener; DataReaderListenerHelper listenerHelper = new DataReaderListenerHelper(); listenerHelper.Listener = listener; listenerHelper.CreateListener(out gapiListener); using (DataReaderListenerMarshaler listenerMarshaler = new DataReaderListenerMarshaler(ref gapiListener)) { IntPtr gapiPtr = Gapi.Subscriber.create_datareader( GapiPeer, superObj.GapiPeer, IntPtr.Zero, listenerMarshaler.GapiPtr, mask); if (gapiPtr != IntPtr.Zero) { DDS.OpenSplice.DomainParticipant participantImpl; participantImpl = topic.Participant as DDS.OpenSplice.DomainParticipant; TypeSupportFactory tsFactory = participantImpl.GetTypeSupportFactory(topic.TypeName); dataReader = tsFactory.CreateDataReader(gapiPtr); dataReader.SetListener(listenerHelper); } } } else { IntPtr gapiPtr = Gapi.Subscriber.create_datareader( GapiPeer, superObj.GapiPeer, IntPtr.Zero, IntPtr.Zero, StatusKind.Any); if (gapiPtr != IntPtr.Zero) { DDS.OpenSplice.DomainParticipant participantImpl; participantImpl = topic.Participant as DDS.OpenSplice.DomainParticipant; TypeSupportFactory tsFactory = participantImpl.GetTypeSupportFactory(topic.TypeName); dataReader = tsFactory.CreateDataReader(gapiPtr); } } } if (dataReader != null) { SubscriberQos subQos = null; ReturnCode result = GetQos(ref subQos); if (result == ReturnCode.Ok) { if (subQos.EntityFactory.AutoenableCreatedEntities) { dataReader.Enable(); } } } return(dataReader); }
public IDataReader CreateDataReader( ITopicDescription topic, DataReaderQos qos, IDataReaderListener listener, StatusKind mask) { DataReader dataReader = null; if (topic != null) { SacsSuperClass superObj = (SacsSuperClass)topic; using (OpenSplice.CustomMarshalers.DataReaderQosMarshaler marshaler = new OpenSplice.CustomMarshalers.DataReaderQosMarshaler()) { if (marshaler.CopyIn(qos) == ReturnCode.Ok) { if (listener != null) { OpenSplice.Gapi.gapi_dataReaderListener gapiListener; DataReaderListenerHelper listenerHelper = new DataReaderListenerHelper(); listenerHelper.Listener = listener; listenerHelper.CreateListener(out gapiListener); using (DataReaderListenerMarshaler listenerMarshaler = new DataReaderListenerMarshaler(ref gapiListener)) { IntPtr gapiPtr = Gapi.Subscriber.create_datareader( GapiPeer, superObj.GapiPeer, marshaler.GapiPtr, listenerMarshaler.GapiPtr, mask); if (gapiPtr != IntPtr.Zero) { TypeSupport typeSupport = topic.Participant.GetTypeSupport(topic.TypeName) as OpenSplice.TypeSupport; dataReader = typeSupport.CreateDataReader(gapiPtr); dataReader.SetListener(listenerHelper); } } } else { IntPtr gapiPtr = Gapi.Subscriber.create_datareader( GapiPeer, superObj.GapiPeer, marshaler.GapiPtr, IntPtr.Zero, mask); if (gapiPtr != IntPtr.Zero) { TypeSupport typeSupport = topic.Participant.GetTypeSupport(topic.TypeName) as OpenSplice.TypeSupport; dataReader = typeSupport.CreateDataReader(gapiPtr); } } } } } if (dataReader != null) { SubscriberQos subQos = null; ReturnCode result = GetQos(ref subQos); if (result == ReturnCode.Ok) { if (subQos.EntityFactory.AutoenableCreatedEntities) { dataReader.Enable(); } } } return dataReader; }
public IDataReader CreateDataReader( ITopicDescription topic, IDataReaderListener listener, StatusKind mask) { DataReader dataReader = null; if (topic != null) { SacsSuperClass superObj = (SacsSuperClass)topic; if (listener != null) { OpenSplice.Gapi.gapi_dataReaderListener gapiListener; DataReaderListenerHelper listenerHelper = new DataReaderListenerHelper(); listenerHelper.Listener = listener; listenerHelper.CreateListener(out gapiListener); using (DataReaderListenerMarshaler listenerMarshaler = new DataReaderListenerMarshaler(ref gapiListener)) { IntPtr gapiPtr = Gapi.Subscriber.create_datareader( GapiPeer, superObj.GapiPeer, IntPtr.Zero, listenerMarshaler.GapiPtr, mask); if (gapiPtr != IntPtr.Zero) { DDS.OpenSplice.DomainParticipant participantImpl; participantImpl = topic.Participant as DDS.OpenSplice.DomainParticipant; TypeSupportFactory tsFactory = participantImpl.GetTypeSupportFactory(topic.TypeName); dataReader = tsFactory.CreateDataReader(gapiPtr); dataReader.SetListener(listenerHelper); } } } else { IntPtr gapiPtr = Gapi.Subscriber.create_datareader( GapiPeer, superObj.GapiPeer, IntPtr.Zero, IntPtr.Zero, StatusKind.Any); if (gapiPtr != IntPtr.Zero) { DDS.OpenSplice.DomainParticipant participantImpl; participantImpl = topic.Participant as DDS.OpenSplice.DomainParticipant; TypeSupportFactory tsFactory = participantImpl.GetTypeSupportFactory(topic.TypeName); dataReader = tsFactory.CreateDataReader(gapiPtr); } } } if (dataReader != null) { SubscriberQos subQos = null; ReturnCode result = GetQos(ref subQos); if (result == ReturnCode.Ok) { if (subQos.EntityFactory.AutoenableCreatedEntities) { dataReader.Enable(); } } } return dataReader; }
public IDataReader CreateDataReader( ITopicDescription topic, DataReaderQos qos, IDataReaderListener listener, StatusKind mask) { DataReader dataReader = null; if (topic != null) { SacsSuperClass superObj = (SacsSuperClass)topic; using (OpenSplice.CustomMarshalers.DataReaderQosMarshaler marshaler = new OpenSplice.CustomMarshalers.DataReaderQosMarshaler()) { if (marshaler.CopyIn(qos) == ReturnCode.Ok) { if (listener != null) { OpenSplice.Gapi.gapi_dataReaderListener gapiListener; DataReaderListenerHelper listenerHelper = new DataReaderListenerHelper(); listenerHelper.Listener = listener; listenerHelper.CreateListener(out gapiListener); using (DataReaderListenerMarshaler listenerMarshaler = new DataReaderListenerMarshaler(ref gapiListener)) { IntPtr gapiPtr = Gapi.Subscriber.create_datareader( GapiPeer, superObj.GapiPeer, marshaler.GapiPtr, listenerMarshaler.GapiPtr, mask); if (gapiPtr != IntPtr.Zero) { TypeSupport typeSupport = topic.Participant.GetTypeSupport(topic.TypeName) as OpenSplice.TypeSupport; dataReader = typeSupport.CreateDataReader(gapiPtr); dataReader.SetListener(listenerHelper); } } } else { IntPtr gapiPtr = Gapi.Subscriber.create_datareader( GapiPeer, superObj.GapiPeer, marshaler.GapiPtr, IntPtr.Zero, mask); if (gapiPtr != IntPtr.Zero) { TypeSupport typeSupport = topic.Participant.GetTypeSupport(topic.TypeName) as OpenSplice.TypeSupport; dataReader = typeSupport.CreateDataReader(gapiPtr); } } } } } if (dataReader != null) { SubscriberQos subQos = null; ReturnCode result = GetQos(ref subQos); if (result == ReturnCode.Ok) { if (subQos.EntityFactory.AutoenableCreatedEntities) { dataReader.Enable(); } } } return(dataReader); }