コード例 #1
0
        /// <summary>
        /// Retrieves the list of attached conditions.
        /// </summary>
        /// <param name="attachedConditions">The collection of <see cref="Condition" />s to be filled up.</param>
        /// <returns>The <see cref="ReturnCode" /> that indicates the operation result.</returns>
        public ReturnCode GetConditions(ICollection <Condition> attachedConditions)
        {
            if (attachedConditions == null)
            {
                return(ReturnCode.BadParameter);
            }
            attachedConditions.Clear();

            IntPtr     seq = IntPtr.Zero;
            ReturnCode ret = UnsafeNativeMethods.GetConditions(_native, ref seq);

            if (ret == ReturnCode.Ok && !seq.Equals(IntPtr.Zero))
            {
                IList <IntPtr> lst = new List <IntPtr>();
                MarshalHelper.PtrToSequence(seq, ref lst);
                if (lst != null)
                {
                    foreach (IntPtr ptrCondition in lst)
                    {
                        if (_conditions.TryGetValue(ptrCondition, out var condition))
                        {
                            attachedConditions.Add(condition);
                        }
                    }
                }
            }

            return(ret);
        }
コード例 #2
0
        /// <summary>
        /// Gets the collection of subscriptions currently "associated" with the <see cref="DataWriter" />; that is, subscriptions that have a
        /// matching <see cref="Topic" /> and compatible QoS that the application has not indicated should be "ignored" by means of the
        /// <see cref="DomainParticipant" /> IgnoreSubscription operation.
        /// </summary>
        /// <remarks>
        /// The handles returned in the 'subscriptionHandles' collection are the ones that are used by the DDS implementation to locally
        /// identify the corresponding matched <see cref="DataReader" /> entities. These handles match the ones that appear in the <see cref="SampleInfo.InstanceState" />
        /// property of the <see cref="SampleInfo" /> when reading the "DCPSSubscriptions" builtin topic.
        /// </remarks>
        /// <param name="subscriptionHandles">The collection of subscription <see cref="InstanceHandle" />s to be filled up.</param>
        /// <returns>The <see cref="ReturnCode" /> that indicates the operation result.</returns>
        public ReturnCode GetMatchedSubscriptions(ICollection <InstanceHandle> subscriptionHandles)
        {
            if (subscriptionHandles == null)
            {
                return(ReturnCode.BadParameter);
            }

            subscriptionHandles.Clear();

            IntPtr     seq = IntPtr.Zero;
            ReturnCode ret = UnsafeNativeMethods.GetMatchedSubscriptions64(_native, ref seq);

            if (ret == ReturnCode.Ok && !seq.Equals(IntPtr.Zero))
            {
                MarshalHelper.PtrToSequence(seq, ref subscriptionHandles);
                MarshalHelper.ReleaseNativePointer(seq);
            }

            return(ret);
        }
コード例 #3
0
        /// <summary>
        /// Allows the application to access the <see cref="DataReader" /> objects that contain samples with the specified sampleStates,
        /// viewStates, and instanceStates.
        /// </summary>
        /// <remarks>
        /// <para>If the <see cref="PresentationQosPolicy" /> of the <see cref="Subscriber" /> to which the <see cref="DataReader" /> belongs has the
        /// <see cref="PresentationQosPolicy.AccessScope" /> set to <see cref="PresentationQosPolicyAccessScopeKind.GroupPresentationQos" />,
        /// this operation should only be invoked inside a <see cref="BeginAccess" />/<see cref="EndAccess" /> block. Otherwise it will return the error
        /// <see cref="ReturnCode.PreconditionNotMet" />.</para>
        /// <para>Depending on the setting of the <see cref="PresentationQosPolicy" />, the returned collection of <see cref="DataReader" /> objects may
        /// be a 'set' containing each <see cref="DataReader" /> at most once in no specified order, or a 'list' containing each <see cref="DataReader" /> one or more
        /// times in a specific order.
        /// <list type="number">
        /// <item><description>If <see cref="PresentationQosPolicy.AccessScope" /> is <see cref="PresentationQosPolicyAccessScopeKind.InstancePresentationQos" /> or
        /// <see cref="PresentationQosPolicyAccessScopeKind.TopicPresentationQos" /> the returned collection behaves as a 'set'.</description></item>
        /// <item><description>If <see cref="PresentationQosPolicy.AccessScope" /> is <see cref="PresentationQosPolicyAccessScopeKind.GroupPresentationQos" /> and
        /// <see cref="PresentationQosPolicy.OrderedAccess" /> is set to <see langword="true"/>, then the returned collection behaves as a 'list'.</description></item>
        /// </list></para>
        /// <para>This difference is due to the fact that, in the second situation it is required to access samples belonging to different <see cref="DataReader" />
        /// objects in a particular order. In this case, the application should process each <see cref="DataReader" /> in the same order it appears in the
        /// 'list' and Read or Take exactly one sample from each <see cref="DataReader" />.</para>
        /// </remarks>
        /// <param name="readers">The <see cref="DataReader" /> collection to be filled up.</param>
        /// <param name="sampleStates">The returned <see cref="DataReader" /> in the collection must contain samples that have one of the sample states.</param>
        /// <param name="viewStates">The returned <see cref="DataReader" /> in the collection must contain samples that have one of the view states.</param>
        /// <param name="instanceStates">The returned <see cref="DataReader" /> in the collection must contain samples that have one of the instance states.</param>
        /// <returns>The <see cref="ReturnCode" /> that indicates the operation result.</returns>
        public ReturnCode GetDataReaders(IList <DataReader> readers, SampleStateMask sampleStates, ViewStateMask viewStates, InstanceStateMask instanceStates)
        {
            if (readers == null)
            {
                return(ReturnCode.BadParameter);
            }

            readers.Clear();

            IntPtr     ptr = IntPtr.Zero;
            ReturnCode ret = UnsafeNativeMethods.GetDataReaders(_native, ref ptr, sampleStates, viewStates, instanceStates);

            if (ret == ReturnCode.Ok && !ptr.Equals(IntPtr.Zero))
            {
                IList <IntPtr> lst = new List <IntPtr>();
                MarshalHelper.PtrToSequence(ptr, ref lst);
                if (lst != null)
                {
                    foreach (IntPtr ptrReader in lst)
                    {
                        IntPtr ptrEnity = DataReader.NarrowBase(ptrReader);

                        var entity = EntityManager.Instance.Find(ptrEnity);
                        if (entity is DataReader dataReader)
                        {
                            readers.Add(dataReader);
                        }
                        else
                        {
                            readers.Add(new DataReader(ptrReader));
                        }
                    }
                }
            }

            return(ret);
        }