Ejemplo n.º 1
0
        /// <summary>
        /// Sets a default value of the <see cref="DomainParticipant" /> QoS policies which will be used for newly created
        /// <see cref="DomainParticipant" /> entities in the case where the QoS policies are defaulted in the CreateParticipant operation.
        /// </summary>
        /// <remarks>
        /// This operation will check that the resulting policies are self consistent; if they are not,
        /// the operation will have no effect and return <see cref="ReturnCode.InconsistentPolicy" />.
        /// </remarks>
        /// <param name="qos">The default <see cref="DomainParticipantQos" /> to be set.</param>
        /// <returns>The <see cref="ReturnCode" /> that indicates the operation result.</returns>
        public ReturnCode SetDefaultDomainParticipantQos(DomainParticipantQos qos)
        {
            if (qos is null)
            {
                return(ReturnCode.BadParameter);
            }

            var qosNative = qos.ToNative();
            var ret       = UnsafeNativeMethods.SetDefaultDomainParticipantQos(_native, qosNative);

            qos.Release();

            return(ret);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new <see cref="DomainParticipant" /> with the desired QoS policies and attaches to it the specified <see cref="DomainParticipantListener" />.
        /// </summary>
        /// <remarks>
        /// If the specified QoS policies are not consistent, the operation will fail and no <see cref="DomainParticipant" /> will be created.
        /// </remarks>
        /// <param name="domainId">Domain ID that the application intends to join.</param>
        /// <param name="qos">The <see cref="DomainParticipantQos" /> policies to be used for creating the new <see cref="DomainParticipant" />.</param>
        /// <param name="listener">The <see cref="DomainParticipantListener" /> to be attached to the newly created <see cref="DomainParticipant" />.</param>
        /// <param name="statusMask">The <see cref="StatusMask" /> of which status changes the listener should be notified.</param>
        /// <returns> The newly created <see cref="DomainParticipant" /> on success, otherwise <see langword="null"/>.</returns>
        public DomainParticipant CreateParticipant(int domainId, DomainParticipantQos qos, DomainParticipantListener listener, StatusMask statusMask)
        {
            DomainParticipantQosWrapper qosWrapper = default;

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

            IntPtr nativeListener = IntPtr.Zero;

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

            IntPtr native = UnsafeNativeMethods.CreateParticipant(_native, domainId, qosWrapper, nativeListener, statusMask);

            qos.Release();

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

            var p = new DomainParticipant(native)
            {
                Listener = listener,
            };

            EntityManager.Instance.Add((p as Entity).ToNative(), p);

            return(p);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the default value of the <see cref="DomainParticipant" /> QoS, that is, the QoS policies which will be used for
        /// newly created <see cref="DomainParticipant" /> entities in the case where the QoS policies are defaulted in the CreateParticipant operation.
        /// </summary>
        /// <remarks>
        /// The values retrieved <see cref="GetDefaultDomainParticipantQos(DomainParticipantQos)" /> will match the set of values specified on the last successful call to
        /// <see cref="SetDefaultDomainParticipantQos(DomainParticipantQos)" />, or else, if the call was never made, the default values defined by the DDS standard.
        /// </remarks>
        /// <param name="qos">The <see cref="DomainParticipantQos" /> to be filled up.</param>
        /// <returns>The <see cref="ReturnCode" /> that indicates the operation result.</returns>
        public ReturnCode GetDefaultDomainParticipantQos(DomainParticipantQos qos)
        {
            if (qos is null)
            {
                return(ReturnCode.BadParameter);
            }

            DomainParticipantQosWrapper qosWrapper = default;
            var ret = UnsafeNativeMethods.GetDefaultDomainParticipantQos(_native, ref qosWrapper);

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

            qos.Release();

            return(ret);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates a new <see cref="DomainParticipant" /> with the desired QoS policies and attaches to it the specified <see cref="DomainParticipantListener" />.
 /// The specified <see cref="DomainParticipantListener" /> will be attached with the default <see cref="StatusMask" />.
 /// </summary>
 /// <remarks>
 /// If the specified QoS policies are not consistent, the operation will fail and no <see cref="DomainParticipant" /> will be created.
 /// </remarks>
 /// <param name="domainId">Domain ID that the application intends to join.</param>
 /// <param name="qos">The <see cref="DomainParticipantQos" /> policies to be used for creating the new <see cref="DomainParticipant" />.</param>
 /// <param name="listener">The <see cref="DomainParticipantListener" /> to be attached to the newly created <see cref="DomainParticipant" />.</param>
 /// <returns> The newly created <see cref="DomainParticipant" /> on success, otherwise <see langword="null"/>.</returns>
 public DomainParticipant CreateParticipant(int domainId, DomainParticipantQos qos, DomainParticipantListener listener)
 {
     return(CreateParticipant(domainId, qos, listener, StatusMask.DefaultStatusMask));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Creates a <see cref="DomainParticipant" /> with the desired QoS policies and without listener attached.
 /// </summary>
 /// <remarks>
 /// If the specified QoS policies are not consistent, the operation will fail and no <see cref="DomainParticipant" /> will be created.
 /// </remarks>
 /// <param name="domainId">Domain ID that the application intends to join.</param>
 /// <param name="qos">The <see cref="DomainParticipantQos" /> policies to be used for creating the new <see cref="DomainParticipant" />.</param>
 /// <returns> The newly created <see cref="DomainParticipant" /> on success, otherwise <see langword="null"/>.</returns>
 public DomainParticipant CreateParticipant(int domainId, DomainParticipantQos qos)
 {
     return(CreateParticipant(domainId, qos, null, StatusMask.DefaultStatusMask));
 }