internal ReturnCode init(Topic relatedTopic) { ReturnCode result; MyDomainId = relatedTopic.MyDomainId; this.relatedTopic = relatedTopic; lock (relatedTopic) { if (relatedTopic.rlReq_isAlive) { result = relatedTopic.ValidateFilter(filterExpression, filterParameters); if (result == DDS.ReturnCode.Ok) { ITopicDescriptionImpl relatedTopicDescr = relatedTopic as ITopicDescriptionImpl; relatedTopicDescr.wlReq_IncrNrUsers(); this.topicExpression = relatedTopicDescr.rlReq_TopicExpression + " where " + this.filterExpression; this.typeSupport = relatedTopicDescr.rlReq_TypeSupport; result = base.init(IntPtr.Zero, false); } } else { result = DDS.ReturnCode.BadParameter; ReportStack.Report(result, "ContentFilteredTopic \"" + topicName + "\" is referring to an already deleted topic."); } } return(result); }
internal override ReturnCode wlReq_deinit() { ReturnCode result = DDS.ReturnCode.Ok; if (nrUsers > 0) { result = DDS.ReturnCode.PreconditionNotMet; ReportStack.Report(result, "Topic \"" + topicName + "\" still in use by " + nrUsers + " Writers/Readers."); } else { ITopicListener tpListener = listener as ITopicListener; if (tpListener != null) { this.SetListener(tpListener, (DDS.StatusKind) 0); } this.DisableCallbacks(); result = base.wlReq_deinit(); if (result == DDS.ReturnCode.Ok) { this.domainParticipant = null; this.topicName = null; this.typeName = null; this.typeSupport = null; this.topicExpression = null; } } return(result); }
internal ReturnCode init( IntPtr uTopic, DomainParticipant participant, string topicName, string typeName, TypeSupport ts) { MyDomainId = participant.MyDomainId; ReturnCode result = base.init(uTopic); if (result == DDS.ReturnCode.Ok) { this.domainParticipant = participant; this.topicName = topicName; this.typeName = typeName; this.typeSupport = ts; this.topicExpression = "select * from " + topicName; } else { ReportStack.Report(result, "Could not create Topic" + topicName + "."); } return(result); }
internal MultiTopic( string typeName, string topicName, DomainParticipant domainParticipant, TypeSupport typeSupport, string subscriptionExpression, string[] subscriptionParameters) { this.typeName = typeName; this.topicName = topicName; this.domainParticipant = domainParticipant; this.typeSupport = typeSupport; this.subscriptionExpression = subscriptionExpression; this.subscriptionParameters = subscriptionParameters; MyDomainId = domainParticipant.MyDomainId; }
public IDataWriter CreateDataWriter( ITopic topic, DataWriterQos qos, IDataWriterListener listener, StatusKind mask) { ReturnCode result = DDS.ReturnCode.AlreadyDeleted; DataWriter dataWriter = null; Topic topicObj = topic as Topic; ReportStack.Start(); lock (this) { if (this.rlReq_isAlive) { if (topicObj == null) { result = DDS.ReturnCode.BadParameter; ReportStack.Report(result, "topic is invalid (null), or not of type " + "DDS::OpenSplice::Topic."); } else { result = QosManager.checkQos(qos); } if (result == DDS.ReturnCode.Ok) { lock (topicObj) { if (topicObj.rlReq_isAlive) { TypeSupport ts = (topicObj as ITopicDescriptionImpl).rlReq_TypeSupport; DatabaseMarshaler marshaler = DatabaseMarshaler.GetMarshaler(participant, ts.TypeSpec); dataWriter = ts.CreateDataWriter(marshaler); result = dataWriter.init(this, qos, topicObj, "writer <" + topicObj.Name + ">"); if (result == ReturnCode.Ok) { dataWriter.wlReq_ListenerDispatcher = this.wlReq_ListenerDispatcher; result = dataWriter.SetListener(listener, mask); } else { dataWriter = null; } if (result == DDS.ReturnCode.Ok) { writerList.Add(dataWriter); if (rlReq_AutoEnableCreatedEntities) { result = dataWriter.Enable(); } } } else { // ALREADY_DELETED may only apply to the Publisher in this context, // so for a deleted topic use BAD_PARAMETER instead. result = DDS.ReturnCode.BadParameter; } } } if (result != ReturnCode.Ok && dataWriter != null) { // Ignore result because we prefer the original error. DeleteDataWriter(dataWriter); dataWriter = null; } } } ReportStack.Flush(this, result != ReturnCode.Ok); return(dataWriter); }
public IDataWriter CreateDataWriter( ITopic topic, IDataWriterListener listener, StatusKind mask) { DataWriter dataWriter = null; Topic topicObj = topic as Topic; if (listener != null) { // Note: we use the same gapi lister as the DataWriter since the // publisher doesn't add anything unique OpenSplice.Gapi.gapi_publisherDataWriterListener gapiListener; PublisherDataWriterListenerHelper listenerHelper = new PublisherDataWriterListenerHelper(); listenerHelper.Listener = listener; listenerHelper.CreateListener(out gapiListener); using (PublisherDataWriterListenerMarshaler listenerMarshaler = new PublisherDataWriterListenerMarshaler(ref gapiListener)) { IntPtr gapiPtr = Gapi.Publisher.create_datawriter( GapiPeer, topicObj.GapiPeer, Gapi.NativeConstants.GapiDataWriterQosDefault, listenerMarshaler.GapiPtr, mask); if (gapiPtr != IntPtr.Zero) { TypeSupport typeSupport = topic.Participant.GetTypeSupport(topic.TypeName) as OpenSplice.TypeSupport; dataWriter = typeSupport.CreateDataWriter(gapiPtr); dataWriter.SetListener(listenerHelper); } } } else { IntPtr gapiPtr = Gapi.Publisher.create_datawriter( GapiPeer, topicObj.GapiPeer, Gapi.NativeConstants.GapiDataWriterQosDefault, IntPtr.Zero, mask); if (gapiPtr != IntPtr.Zero) { TypeSupport typeSupport = topic.Participant.GetTypeSupport(topic.TypeName) as OpenSplice.TypeSupport; dataWriter = typeSupport.CreateDataWriter(gapiPtr); } } if (dataWriter != null) { PublisherQos pubQos = null; ReturnCode result = GetQos(ref pubQos); if (result == ReturnCode.Ok) { if (pubQos.EntityFactory.AutoenableCreatedEntities) { dataWriter.Enable(); } } } return(dataWriter); }
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) { 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, IntPtr.Zero, IntPtr.Zero, StatusKind.Any); 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); }