Esempio n. 1
0
        public ReturnCode SetListener(IDataReaderListener listener, StatusKind mask)
        {
            ReturnCode result = ReturnCode.Error;

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

            return(result);
        }
Esempio n. 2
0
        public ReturnCode SetListener(IDataReaderListener listener, StatusKind mask)
        {
            ReturnCode result = ReturnCode.Error;

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

            return result;
        }
Esempio n. 3
0
 internal void SetListener(DataReaderListenerHelper listenerHelper)
 {
     this.listenerHelper = listenerHelper;
 }
Esempio n. 4
0
        public IDataReader CreateDataReader(
            ITopicDescription topic,
            IDataReaderListener listener,
            StatusKind mask)
        {
            DataReader dataReader = null;

            if (topic != null)
            {
                SacsSuperClass superObj = (SacsSuperClass)topic;

                if (listener != null)
                {
                    OpenSplice.Gapi.gapi_dataReaderListener gapiListener;
                    DataReaderListenerHelper listenerHelper = new DataReaderListenerHelper();
                    listenerHelper.Listener = listener;
                    listenerHelper.CreateListener(out gapiListener);
                    using (DataReaderListenerMarshaler listenerMarshaler =
                               new DataReaderListenerMarshaler(ref gapiListener))
                    {
                        IntPtr gapiPtr = Gapi.Subscriber.create_datareader(
                            GapiPeer,
                            superObj.GapiPeer,
                            IntPtr.Zero,
                            listenerMarshaler.GapiPtr,
                            mask);
                        if (gapiPtr != IntPtr.Zero)
                        {
                            DDS.OpenSplice.DomainParticipant participantImpl;

                            participantImpl = topic.Participant as DDS.OpenSplice.DomainParticipant;
                            TypeSupportFactory tsFactory = participantImpl.GetTypeSupportFactory(topic.TypeName);
                            dataReader = tsFactory.CreateDataReader(gapiPtr);
                            dataReader.SetListener(listenerHelper);
                        }
                    }
                }
                else
                {
                    IntPtr gapiPtr = Gapi.Subscriber.create_datareader(
                        GapiPeer,
                        superObj.GapiPeer,
                        IntPtr.Zero,
                        IntPtr.Zero,
                        StatusKind.Any);
                    if (gapiPtr != IntPtr.Zero)
                    {
                        DDS.OpenSplice.DomainParticipant participantImpl;

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

            if (dataReader != null)
            {
                SubscriberQos subQos = null;
                ReturnCode    result = GetQos(ref subQos);
                if (result == ReturnCode.Ok)
                {
                    if (subQos.EntityFactory.AutoenableCreatedEntities)
                    {
                        dataReader.Enable();
                    }
                }
            }

            return(dataReader);
        }
Esempio n. 5
0
 internal void SetListener(DataReaderListenerHelper listenerHelper)
 {
     this.listenerHelper = listenerHelper;
 }
Esempio n. 6
0
        public IDataReader CreateDataReader(
                ITopicDescription topic, 
                DataReaderQos qos,
                IDataReaderListener listener, 
                StatusKind mask)
        {
            DataReader dataReader = null;

            if (topic != null)
            {
                SacsSuperClass superObj = (SacsSuperClass)topic;

                using (OpenSplice.CustomMarshalers.DataReaderQosMarshaler marshaler =
                        new OpenSplice.CustomMarshalers.DataReaderQosMarshaler())
                {
                    if (marshaler.CopyIn(qos) == ReturnCode.Ok)
                    {
                        if (listener != null)
                        {
                            OpenSplice.Gapi.gapi_dataReaderListener gapiListener;
                            DataReaderListenerHelper listenerHelper = new DataReaderListenerHelper();
                            listenerHelper.Listener = listener;
                            listenerHelper.CreateListener(out gapiListener);
                            using (DataReaderListenerMarshaler listenerMarshaler =
                                    new DataReaderListenerMarshaler(ref gapiListener))
                            {
                                IntPtr gapiPtr = Gapi.Subscriber.create_datareader(
                                        GapiPeer,
                                        superObj.GapiPeer,
                                        marshaler.GapiPtr,
                                        listenerMarshaler.GapiPtr,
                                        mask);
                                if (gapiPtr != IntPtr.Zero)
                                {
                                    TypeSupport typeSupport = topic.Participant.GetTypeSupport(topic.TypeName)
                                            as OpenSplice.TypeSupport;
                                    dataReader = typeSupport.CreateDataReader(gapiPtr);
                                    dataReader.SetListener(listenerHelper);
                                }
                            }
                        }
                        else
                        {
                            IntPtr gapiPtr = Gapi.Subscriber.create_datareader(
                                    GapiPeer,
                                    superObj.GapiPeer,
                                    marshaler.GapiPtr,
                                    IntPtr.Zero,
                                    mask);
                            if (gapiPtr != IntPtr.Zero)
                            {
                                TypeSupport typeSupport = topic.Participant.GetTypeSupport(topic.TypeName)
                                        as OpenSplice.TypeSupport;
                                dataReader = typeSupport.CreateDataReader(gapiPtr);
                            }
                        }
                    }
                }
            }

            if (dataReader != null)
            {
                SubscriberQos subQos = null;
                ReturnCode result = GetQos(ref subQos);
                if (result == ReturnCode.Ok)
                {
                    if (subQos.EntityFactory.AutoenableCreatedEntities)
                    {
                        dataReader.Enable();
                    }
                }
            }

            return dataReader;
        }
Esempio n. 7
0
        public IDataReader CreateDataReader(
                ITopicDescription topic,
                IDataReaderListener listener, 
                StatusKind mask)
        {

            DataReader dataReader = null;

            if (topic != null)
            {
                SacsSuperClass superObj = (SacsSuperClass)topic;

                if (listener != null)
                {
                    OpenSplice.Gapi.gapi_dataReaderListener gapiListener;
                    DataReaderListenerHelper listenerHelper = new DataReaderListenerHelper();
                    listenerHelper.Listener = listener;
                    listenerHelper.CreateListener(out gapiListener);
                    using (DataReaderListenerMarshaler listenerMarshaler =
                            new DataReaderListenerMarshaler(ref gapiListener))
                    {
                        IntPtr gapiPtr = Gapi.Subscriber.create_datareader(
                                GapiPeer,
                                superObj.GapiPeer,
                                IntPtr.Zero,
                                listenerMarshaler.GapiPtr,
                                mask);
                        if (gapiPtr != IntPtr.Zero)
                        {
                            DDS.OpenSplice.DomainParticipant participantImpl;
                    
                            participantImpl = topic.Participant as DDS.OpenSplice.DomainParticipant;
                            TypeSupportFactory tsFactory = participantImpl.GetTypeSupportFactory(topic.TypeName);
                            dataReader = tsFactory.CreateDataReader(gapiPtr);
                            dataReader.SetListener(listenerHelper);
                        }
                    }
                }
                else
                {
                    IntPtr gapiPtr = Gapi.Subscriber.create_datareader(
                            GapiPeer,
                            superObj.GapiPeer,
                            IntPtr.Zero,
                            IntPtr.Zero,
                            StatusKind.Any);
                    if (gapiPtr != IntPtr.Zero)
                    {
                        DDS.OpenSplice.DomainParticipant participantImpl;
                    
                        participantImpl = topic.Participant as DDS.OpenSplice.DomainParticipant;
                        TypeSupportFactory tsFactory = participantImpl.GetTypeSupportFactory(topic.TypeName);
                        dataReader = tsFactory.CreateDataReader(gapiPtr);
                    }
                }
            }

            if (dataReader != null)
            {
                SubscriberQos subQos = null;
                ReturnCode result = GetQos(ref subQos);
                if (result == ReturnCode.Ok)
                {
                    if (subQos.EntityFactory.AutoenableCreatedEntities)
                    {
                        dataReader.Enable();
                    }
                }
            }       
                
            return dataReader;
        }
Esempio n. 8
0
        public IDataReader CreateDataReader(
            ITopicDescription topic,
            DataReaderQos qos,
            IDataReaderListener listener,
            StatusKind mask)
        {
            DataReader dataReader = null;

            if (topic != null)
            {
                SacsSuperClass superObj = (SacsSuperClass)topic;

                using (OpenSplice.CustomMarshalers.DataReaderQosMarshaler marshaler =
                           new OpenSplice.CustomMarshalers.DataReaderQosMarshaler())
                {
                    if (marshaler.CopyIn(qos) == ReturnCode.Ok)
                    {
                        if (listener != null)
                        {
                            OpenSplice.Gapi.gapi_dataReaderListener gapiListener;
                            DataReaderListenerHelper listenerHelper = new DataReaderListenerHelper();
                            listenerHelper.Listener = listener;
                            listenerHelper.CreateListener(out gapiListener);
                            using (DataReaderListenerMarshaler listenerMarshaler =
                                       new DataReaderListenerMarshaler(ref gapiListener))
                            {
                                IntPtr gapiPtr = Gapi.Subscriber.create_datareader(
                                    GapiPeer,
                                    superObj.GapiPeer,
                                    marshaler.GapiPtr,
                                    listenerMarshaler.GapiPtr,
                                    mask);
                                if (gapiPtr != IntPtr.Zero)
                                {
                                    TypeSupport typeSupport = topic.Participant.GetTypeSupport(topic.TypeName)
                                                              as OpenSplice.TypeSupport;
                                    dataReader = typeSupport.CreateDataReader(gapiPtr);
                                    dataReader.SetListener(listenerHelper);
                                }
                            }
                        }
                        else
                        {
                            IntPtr gapiPtr = Gapi.Subscriber.create_datareader(
                                GapiPeer,
                                superObj.GapiPeer,
                                marshaler.GapiPtr,
                                IntPtr.Zero,
                                mask);
                            if (gapiPtr != IntPtr.Zero)
                            {
                                TypeSupport typeSupport = topic.Participant.GetTypeSupport(topic.TypeName)
                                                          as OpenSplice.TypeSupport;
                                dataReader = typeSupport.CreateDataReader(gapiPtr);
                            }
                        }
                    }
                }
            }

            if (dataReader != null)
            {
                SubscriberQos subQos = null;
                ReturnCode    result = GetQos(ref subQos);
                if (result == ReturnCode.Ok)
                {
                    if (subQos.EntityFactory.AutoenableCreatedEntities)
                    {
                        dataReader.Enable();
                    }
                }
            }

            return(dataReader);
        }