Beispiel #1
0
        internal void FromNative(DataReaderQosWrapper wrapper)
        {
            Deadline            = wrapper.Deadline;
            DestinationOrder    = wrapper.DestinationOrder;
            Durability          = wrapper.Durability;
            LatencyBudget       = wrapper.LatencyBudget;
            Liveliness          = wrapper.Liveliness;
            Ownership           = wrapper.Ownership;
            Reliability         = wrapper.Reliability;
            History             = wrapper.History;
            ResourceLimits      = wrapper.ResourceLimits;
            TimeBasedFilter     = wrapper.TimeBasedFilter;
            ReaderDataLifecycle = wrapper.ReaderDataLifecycle;

            if (UserData == null)
            {
                UserData = new UserDataQosPolicy();
            }
            UserData.FromNative(wrapper.UserData);

            if (Representation == null)
            {
                Representation = new DataRepresentationQosPolicy();
            }
            Representation.FromNative(wrapper.Representation);
        }
Beispiel #2
0
        internal DataReaderQosWrapper ToNative()
        {
            var data = new DataReaderQosWrapper
            {
                Deadline            = Deadline,
                DestinationOrder    = DestinationOrder,
                Durability          = Durability,
                LatencyBudget       = LatencyBudget,
                Liveliness          = Liveliness,
                Ownership           = Ownership,
                Reliability         = Reliability,
                History             = History,
                ResourceLimits      = ResourceLimits,
                TimeBasedFilter     = TimeBasedFilter,
                ReaderDataLifecycle = ReaderDataLifecycle,
            };

            if (UserData != null)
            {
                data.UserData = UserData.ToNative();
            }

            if (Representation != null)
            {
                data.Representation = Representation.ToNative();
            }

            return(data);
        }
Beispiel #3
0
        /// <summary>
        /// Creates a new <see cref="DataReader" /> with the desired QoS policies and attaches to it the specified <see cref="DataReaderListener" />.
        /// </summary>
        /// <remarks>
        /// <para>The returned <see cref="DataReader" /> will be attached and belong to the <see cref="Subscriber" />.</para>
        /// <para>The <see cref="ITopicDescription"/> passed to this operation must have been created from the same <see cref="DomainParticipant" /> that was used to
        /// create this <see cref="Subscriber" />. If the <see cref="ITopicDescription"/> was created from a different <see cref="DomainParticipant" />, the operation will fail and
        /// return a <see langword="null"/> result.</para>
        /// </remarks>
        /// <param name="topicDescription">The <see cref="ITopicDescription" /> that the <see cref="DataReader" /> will be associated with.</param>
        /// <param name="qos">The <see cref="DataReaderQos" /> policies to be used for creating the new <see cref="DataReader" />.</param>
        /// <param name="listener">The <see cref="DataReaderListener" /> to be attached to the newly created <see cref="DataReader" />.</param>
        /// <param name="statusMask">The <see cref="StatusMask" /> of which status changes the listener should be notified.</param>
        /// <returns>The newly created <see cref="DataReader" /> on success, otherwise <see langword="null"/>.</returns>
        public DataReader CreateDataReader(ITopicDescription topicDescription, DataReaderQos qos, DataReaderListener listener, StatusMask statusMask)
        {
            if (topicDescription is null)
            {
                throw new ArgumentNullException(nameof(topicDescription));
            }

            DataReaderQosWrapper qosWrapper = default;

            if (qos is null)
            {
                qos = new DataReaderQos();
                var ret = GetDefaultDataReaderQos(qos);
                if (ret == ReturnCode.Ok)
                {
                    qosWrapper = qos.ToNative();
                }
            }
            else
            {
                qosWrapper = qos.ToNative();
            }

            IntPtr nativeListener = IntPtr.Zero;

            if (listener != null)
            {
                nativeListener = listener.ToNative();
            }

            IntPtr td     = topicDescription.ToNativeTopicDescription();
            IntPtr native = UnsafeNativeMethods.CreateDataReader(_native, td, qosWrapper, nativeListener, statusMask);

            qos.Release();

            if (native.Equals(IntPtr.Zero))
            {
                return(null);
            }

            var dr = new DataReader(native)
            {
                Listener = listener,
            };

            EntityManager.Instance.Add((dr as Entity).ToNative(), dr);
            ContainedEntities.Add(dr);

            return(dr);
        }
Beispiel #4
0
        /// <summary>
        /// Gets the <see cref="DataReader" /> QoS policies.
        /// </summary>
        /// <param name="qos">The <see cref="DataReaderQos" /> to be filled up.</param>
        /// <returns>The <see cref="ReturnCode" /> that indicates the operation result.</returns>
        public ReturnCode GetQos(DataReaderQos qos)
        {
            if (qos == null)
            {
                return(ReturnCode.BadParameter);
            }

            DataReaderQosWrapper qosWrapper = default;
            var ret = UnsafeNativeMethods.GetQos(_native, ref qosWrapper);

            if (ret == ReturnCode.Ok)
            {
                qos.FromNative(qosWrapper);
            }

            qos.Release();

            return(ret);
        }
Beispiel #5
0
 public static extern ReturnCode SetQos(IntPtr dr, [MarshalAs(UnmanagedType.Struct), In] DataReaderQosWrapper qos);
Beispiel #6
0
 public static extern ReturnCode GetDefaultDataReaderQos(IntPtr sub, [MarshalAs(UnmanagedType.Struct), In, Out] ref DataReaderQosWrapper qos);
Beispiel #7
0
 public static extern IntPtr CreateDataReader(IntPtr sub, IntPtr topic, [MarshalAs(UnmanagedType.Struct), In] DataReaderQosWrapper qos, IntPtr a_listener, uint mask);