Exemplo n.º 1
0
        public ReturnCode SetQos(PublisherQos qos)
        {
            ReturnCode result;

            using (OpenSplice.CustomMarshalers.PublisherQosMarshaler marshaler =
                    new OpenSplice.CustomMarshalers.PublisherQosMarshaler())
            {
                result = marshaler.CopyIn(qos);
                if (result == ReturnCode.Ok)
                {
                    // Invoke the corresponding gapi function.
                    result = Gapi.Publisher.set_qos(
                            GapiPeer,
                            marshaler.GapiPtr);
                }
            }
            return result;
        }
Exemplo n.º 2
0
        public ReturnCode GetDefaultPublisherQos(ref PublisherQos qos)
        {
            ReturnCode result;

            using (OpenSplice.CustomMarshalers.PublisherQosMarshaler marshaler =
                    new OpenSplice.CustomMarshalers.PublisherQosMarshaler())
            {
                result = Gapi.DomainParticipant.get_default_publisher_qos(
                        GapiPeer,
                        marshaler.GapiPtr);

                if (result == ReturnCode.Ok)
                {
                    marshaler.CopyOut(ref qos);
                }
            }

            return result;
        }
Exemplo n.º 3
0
        public ReturnCode GetQos(ref PublisherQos qos)
        {
            ReturnCode result;

            using (OpenSplice.CustomMarshalers.PublisherQosMarshaler marshaler =
                    new OpenSplice.CustomMarshalers.PublisherQosMarshaler())
            {
                result = Gapi.Publisher.get_qos(
                        GapiPeer,
                        marshaler.GapiPtr);

                if (result == ReturnCode.Ok)
                {
                    marshaler.CopyOut(ref qos);
                }
            }

            return result;
        }
Exemplo n.º 4
0
        /// <summary>
        /// This operation creates a Publisher with the desired QosPolicy settings and if applicable,
        /// attaches the optionally specified PublisherListener to it.
        /// </summary>
        /// <remarks>
        /// This operation creates a Publisher with the desired QosPolicy settings and if
        /// applicable, attaches the optionally specified PublisherListener to it. When the
        /// PublisherListener is not applicable, the NULL pointer must be supplied instead.
        /// To delete the Publisher the operation DeletePublisher or
        /// DeleteContainedEntities must be used.
        /// In case the specified QosPolicy settings are not consistent, no Publisher is
        /// created and the NULL pointer is returned.
        /// </remarks>
        /// <param name="qos">A collection of QosPolicy settings for the new Publisher.
        /// In case these settings are not self consistent, no Publisher is created.</param>
        /// <param name="listener">The PublisherListener instance which will be attached to the new Publisher.
        /// It is permitted to use null as the value of the listener: this behaves as a PublisherListener
        /// whose operations perform no action.</param>
        /// <param name="mask">A bit-mask in which each bit enables the invocation of the PublisherListener
        /// for a certain status.</param>
        /// <returns>The newly created Publisher. In case of an error, a null Publisher is returned.</returns>
        public IPublisher CreatePublisher(PublisherQos qos, IPublisherListener listener, StatusKind mask)
        {
            IPublisher publisher = null;

            using (OpenSplice.CustomMarshalers.PublisherQosMarshaler marshaler =
                    new OpenSplice.CustomMarshalers.PublisherQosMarshaler())
            {
                // Note: we use the same gapi lister as the DataWriter since the
                // publisher doesn't add anything unique
                if (marshaler.CopyIn(qos) == ReturnCode.Ok)
                {
                    if (listener != null)
                    {
                        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.DomainParticipant.create_publisher(
                                    GapiPeer,
                                    marshaler.GapiPtr,
                                    listenerMarshaler.GapiPtr,
                                    mask);
                            if (gapiPtr != IntPtr.Zero)
                            {
                                publisher = new Publisher(gapiPtr, listenerHelper);
                            }
                        }
                    }
                    else
                    {
                        // Invoke the corresponding gapi function.
                        IntPtr gapiPtr = Gapi.DomainParticipant.create_publisher(
                                GapiPeer,
                                marshaler.GapiPtr,
                                IntPtr.Zero,
                                mask);
                        if (gapiPtr != IntPtr.Zero)
                        {
                            publisher = new Publisher(gapiPtr);
                        }
                    }
                }
            }

            if (publisher != null)
            {
                DomainParticipantQos dpQos = null;
                ReturnCode result = GetQos(ref dpQos);
                if (result == ReturnCode.Ok)
                {
                    if (dpQos.EntityFactory.AutoenableCreatedEntities)
                    {
                        publisher.Enable();
                    }
                }
            }

            return publisher;
        }