示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        internal virtual ReturnCode init(Subscriber subscriber, DataReaderQos drQos, ITopicDescriptionImpl aTopic, string drName)
        {
            ReturnCode result = DDS.ReturnCode.Ok;

            MyDomainId = subscriber.MyDomainId;

            using (OpenSplice.CustomMarshalers.DataReaderQosMarshaler qosMarshaler =
                       new OpenSplice.CustomMarshalers.DataReaderQosMarshaler())
            {
                result = qosMarshaler.CopyIn(drQos);
                if (result == ReturnCode.Ok)
                {
                    using (SequenceStringToCValueArrMarshaler paramsMarshaler = new SequenceStringToCValueArrMarshaler())
                    {
                        string[] _params = aTopic.rlReq_TopicExpressionParameters;
                        result = paramsMarshaler.CopyIn(_params);
                        if (result == ReturnCode.Ok)
                        {
                            IntPtr uReader = User.DataReader.NewBySQL(
                                subscriber.rlReq_UserPeer,
                                drName,
                                aTopic.rlReq_TopicExpression,
                                paramsMarshaler.UserPtr,
                                _params == null ? 0 : Convert.ToUInt32(_params.Length),
                                qosMarshaler.UserPtr);
                            if (uReader != IntPtr.Zero)
                            {
                                result = base.init(uReader);
                            }
                            else
                            {
                                ReportStack.Report(result, "Could not allocate memory.");
                                result = DDS.ReturnCode.OutOfResources;
                            }
                        }
                        else
                        {
                            ReportStack.Report(result, "Could not create DataReader.");
                        }
                    }
                }
                else
                {
                    ReportStack.Report(result, "Could not copy DataReaderQos.");
                }
            }
            if (result == ReturnCode.Ok)
            {
                this.subscriber = subscriber;
                this.topic      = aTopic;
                aTopic.wlReq_IncrNrUsers();
            }

            return(result);
        }
示例#4
0
        internal ReturnCode init()
        {
            ReturnCode result;

            result = DDS.ReturnCode.Unsupported;
            // Try to obtain the list of related topics.
            //relatedTopics = getRelatedTopics();
            for (int i = 0; i < relatedTopics.Length && result == DDS.ReturnCode.Ok; i++)
            {
                ITopicDescriptionImpl t = relatedTopics[i];
                if (t != null)
                {
                    lock (t)
                    {
                        if ((t as SacsSuperClass).rlReq_isAlive)
                        {
                            t.wlReq_IncrNrUsers();
                        }
                        else
                        {
                            result = DDS.ReturnCode.PreconditionNotMet;
                            ReportStack.Report(result, "MultiTopic \"" + topicName + "\" is referring to topics that have already been deleted.");
                            break;
                        }
                    }
                }
                if (result != ReturnCode.Ok)
                {
                    for (int j = 0; j < i; j++)
                    {
                        relatedTopics[j].DecrNrUsers();
                    }
                }
                else
                {
                    result = DDS.ReturnCode.Error;
                }
            }
            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);
        }