Example #1
0
        public IPublisher CreatePublisher(IPublisherListener listener, StatusKind mask)
        {
            IPublisher publisher = null;

            if (listener != null)
            {
                // Note: we use the same gapi lister as the DataWriter since the
                // publisher doesn't add anything unique
                OpenSplice.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,
                        Gapi.NativeConstants.GapiPublisherQosDefault,
                        listenerMarshaler.GapiPtr,
                        mask);
                    if (gapiPtr != IntPtr.Zero)
                    {
                        publisher = new Publisher(gapiPtr, listenerHelper);
                    }
                }
            }
            else
            {
                IntPtr gapiPtr = Gapi.DomainParticipant.create_publisher(
                    GapiPeer,
                    Gapi.NativeConstants.GapiPublisherQosDefault,
                    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);
        }
Example #2
0
        public ReturnCode SetListener(IDataWriterListener listener, StatusKind mask)
        {
            ReturnCode result = ReturnCode.Error;

            if (listener != null)
            {
                Gapi.gapi_publisherDataWriterListener gapiListener;
                if (listenerHelper == null)
                {
                    // Since the real DataWriter is created from the TypeSupport,
                    // the listenerHelper is not "readonly"
                    listenerHelper = new PublisherDataWriterListenerHelper();
                }
                listenerHelper.Listener = listener;
                listenerHelper.CreateListener(out gapiListener);
                lock (listener)
                {
                    using (PublisherDataWriterListenerMarshaler marshaler = 
                            new PublisherDataWriterListenerMarshaler(ref gapiListener))
                    {
                        result = Gapi.DataWriter.set_listener(
                            GapiPeer,
                            marshaler.GapiPtr,
                            mask);
                    }
                }
            }
            else
            {
                result = Gapi.DataWriter.set_listener(
                    GapiPeer,
                    IntPtr.Zero,
                    mask);
            }

            return result;
        }
Example #3
0
        public ReturnCode SetListener(IDataWriterListener listener, StatusKind mask)
        {
            ReturnCode result = ReturnCode.Error;

            if (listener != null)
            {
                Gapi.gapi_publisherDataWriterListener gapiListener;
                if (listenerHelper == null)
                {
                    // Since the real DataWriter is created from the TypeSupport,
                    // the listenerHelper is not "readonly"
                    listenerHelper = new PublisherDataWriterListenerHelper();
                }
                listenerHelper.Listener = listener;
                listenerHelper.CreateListener(out gapiListener);
                lock (listener)
                {
                    using (PublisherDataWriterListenerMarshaler marshaler =
                               new PublisherDataWriterListenerMarshaler(ref gapiListener))
                    {
                        result = Gapi.DataWriter.set_listener(
                            GapiPeer,
                            marshaler.GapiPtr,
                            mask);
                    }
                }
            }
            else
            {
                result = Gapi.DataWriter.set_listener(
                    GapiPeer,
                    IntPtr.Zero,
                    mask);
            }

            return(result);
        }
Example #4
0
 internal Publisher(IntPtr gapiPtr, PublisherDataWriterListenerHelper listenerHelper)
     : base(gapiPtr)
 {
     // Base class handles everything.
     this.listenerHelper = listenerHelper;
 }
Example #5
0
 internal Publisher(IntPtr gapiPtr)
     : base(gapiPtr)
 {
     // Base class handles everything.
     listenerHelper = new PublisherDataWriterListenerHelper();
 }
Example #6
0
        public IDataWriter CreateDataWriter(
                ITopic topic, 
                DataWriterQos qos,
                IDataWriterListener listener, 
                StatusKind mask)
        {
            DataWriter dataWriter = null;
            Topic topicObj = topic as Topic;

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

            if (dataWriter != null)
            {
                PublisherQos pubQos = null;
                ReturnCode result = GetQos(ref pubQos);
                if (result == ReturnCode.Ok)
                {
                    if (pubQos.EntityFactory.AutoenableCreatedEntities)
                    {
                        dataWriter.Enable();
                    }
                }
            }

            return dataWriter;
        }
Example #7
0
        public IDataWriter CreateDataWriter(
                ITopic topic,
                IDataWriterListener listener, 
                StatusKind mask)
        {
            DataWriter dataWriter = null;
            Topic topicObj = topic as Topic;

            if (listener != null)
            {
                // Note: we use the same gapi lister as the DataWriter since the
                // publisher doesn't add anything unique
                OpenSplice.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.Publisher.create_datawriter(
                            GapiPeer,
                            topicObj.GapiPeer,
                            Gapi.NativeConstants.GapiDataWriterQosDefault,
                            listenerMarshaler.GapiPtr,
                            mask);
                    if (gapiPtr != IntPtr.Zero)
                    {
                        DDS.OpenSplice.DomainParticipant participantImpl;
                    
                        participantImpl = topic.Participant as DDS.OpenSplice.DomainParticipant;
                        TypeSupportFactory tsFactory = participantImpl.GetTypeSupportFactory(topic.TypeName);
                        dataWriter = tsFactory.CreateDataWriter(gapiPtr);
                        dataWriter.SetListener(listenerHelper);
                    }
                }
            }
            else
            {
                IntPtr gapiPtr = Gapi.Publisher.create_datawriter(
                            GapiPeer,
                            topicObj.GapiPeer,
                            Gapi.NativeConstants.GapiDataWriterQosDefault,
                            IntPtr.Zero,
                            mask);
                if (gapiPtr != IntPtr.Zero)
                {
                    DDS.OpenSplice.DomainParticipant participantImpl;
                    
                    participantImpl = topic.Participant as DDS.OpenSplice.DomainParticipant;
                    TypeSupportFactory tsFactory = participantImpl.GetTypeSupportFactory(topic.TypeName);
                    dataWriter = tsFactory.CreateDataWriter(gapiPtr);
                }
            }

            if (dataWriter != null)
            {
                PublisherQos pubQos = null;
                ReturnCode result = GetQos(ref pubQos);
                if (result == ReturnCode.Ok)
                {
                    if (pubQos.EntityFactory.AutoenableCreatedEntities)
                    {
                        dataWriter.Enable();
                    }
                }
            }       
                
            return dataWriter;
        }
Example #8
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;
        }
Example #9
0
        public IPublisher CreatePublisher(IPublisherListener listener, StatusKind mask)
        {
            IPublisher publisher = null;

            if (listener != null)
            {
                // Note: we use the same gapi lister as the DataWriter since the
                // publisher doesn't add anything unique
                OpenSplice.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,
                            Gapi.NativeConstants.GapiPublisherQosDefault,
                            listenerMarshaler.GapiPtr,
                            mask);
                    if (gapiPtr != IntPtr.Zero)
                    {
                        publisher = new Publisher(gapiPtr, listenerHelper);
                    }
                }
            }
            else
            {
                IntPtr gapiPtr = Gapi.DomainParticipant.create_publisher(
                            GapiPeer,
                            Gapi.NativeConstants.GapiPublisherQosDefault,
                            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;
        }
Example #10
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);
        }
Example #11
0
        public IDataWriter CreateDataWriter(
            ITopic topic,
            IDataWriterListener listener,
            StatusKind mask)
        {
            DataWriter dataWriter = null;
            Topic      topicObj   = topic as Topic;

            if (listener != null)
            {
                // Note: we use the same gapi lister as the DataWriter since the
                // publisher doesn't add anything unique
                OpenSplice.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.Publisher.create_datawriter(
                        GapiPeer,
                        topicObj.GapiPeer,
                        Gapi.NativeConstants.GapiDataWriterQosDefault,
                        listenerMarshaler.GapiPtr,
                        mask);
                    if (gapiPtr != IntPtr.Zero)
                    {
                        TypeSupport typeSupport = topic.Participant.GetTypeSupport(topic.TypeName)
                                                  as OpenSplice.TypeSupport;
                        dataWriter = typeSupport.CreateDataWriter(gapiPtr);
                        dataWriter.SetListener(listenerHelper);
                    }
                }
            }
            else
            {
                IntPtr gapiPtr = Gapi.Publisher.create_datawriter(
                    GapiPeer,
                    topicObj.GapiPeer,
                    Gapi.NativeConstants.GapiDataWriterQosDefault,
                    IntPtr.Zero,
                    mask);
                if (gapiPtr != IntPtr.Zero)
                {
                    TypeSupport typeSupport = topic.Participant.GetTypeSupport(topic.TypeName)
                                              as OpenSplice.TypeSupport;
                    dataWriter = typeSupport.CreateDataWriter(gapiPtr);
                }
            }

            if (dataWriter != null)
            {
                PublisherQos pubQos = null;
                ReturnCode   result = GetQos(ref pubQos);
                if (result == ReturnCode.Ok)
                {
                    if (pubQos.EntityFactory.AutoenableCreatedEntities)
                    {
                        dataWriter.Enable();
                    }
                }
            }

            return(dataWriter);
        }
Example #12
0
 internal Publisher(IntPtr gapiPtr, PublisherDataWriterListenerHelper listenerHelper)
     : base(gapiPtr)
 {
     // Base class handles everything.
     this.listenerHelper = listenerHelper;
 }
Example #13
0
 internal Publisher(IntPtr gapiPtr)
     : base(gapiPtr)
 {
     // Base class handles everything.
     listenerHelper = new PublisherDataWriterListenerHelper();
 }
Example #14
0
 internal void SetListener(PublisherDataWriterListenerHelper listenerHelper)
 {
     this.listenerHelper = listenerHelper;
 }
Example #15
0
 internal void SetListener(PublisherDataWriterListenerHelper listenerHelper)
 {
     this.listenerHelper = listenerHelper;
 }
Example #16
0
        public IDataWriter CreateDataWriter(
            ITopic topic,
            DataWriterQos qos,
            IDataWriterListener listener,
            StatusKind mask)
        {
            DataWriter dataWriter = null;
            Topic      topicObj   = topic as Topic;

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

                                participantImpl = topic.Participant as DDS.OpenSplice.DomainParticipant;
                                TypeSupportFactory tsFactory = participantImpl.GetTypeSupportFactory(topic.TypeName);
                                dataWriter = tsFactory.CreateDataWriter(gapiPtr);
                                dataWriter.SetListener(listenerHelper);
                            }
                        }
                    }
                    else
                    {
                        // Invoke the corresponding gapi function.
                        IntPtr gapiPtr = Gapi.Publisher.create_datawriter(
                            GapiPeer,
                            topicObj.GapiPeer,
                            marshaler.GapiPtr,
                            IntPtr.Zero,
                            mask);
                        if (gapiPtr != IntPtr.Zero)
                        {
                            DDS.OpenSplice.DomainParticipant participantImpl;

                            participantImpl = topic.Participant as DDS.OpenSplice.DomainParticipant;
                            TypeSupportFactory tsFactory = participantImpl.GetTypeSupportFactory(topic.TypeName);
                            dataWriter = tsFactory.CreateDataWriter(gapiPtr);
                        }
                    }
                }
            }

            if (dataWriter != null)
            {
                PublisherQos pubQos = null;
                ReturnCode   result = GetQos(ref pubQos);
                if (result == ReturnCode.Ok)
                {
                    if (pubQos.EntityFactory.AutoenableCreatedEntities)
                    {
                        dataWriter.Enable();
                    }
                }
            }

            return(dataWriter);
        }