コード例 #1
0
        internal static void CopyIn(ref OpenSplice.Gapi.gapi_subscriberListener from, IntPtr to, int offset)
        {
            DataReaderListenerMarshaler.CopyIn(ref from.dataReader, to, offset_dataReader);

            // set on_data_on_readers field
            BaseMarshaler.Write(to, offset + offset_on_data_on_readers, MarshalHelper.GetIntPtrForDelegate(from.on_data_on_readers));
        }
コード例 #2
0
ファイル: DataReader.cs プロジェクト: shizhexu/opensplice
        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;
        }
コード例 #3
0
ファイル: Subscriber.cs プロジェクト: xrl/opensplice
        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;
        }
コード例 #4
0
ファイル: Subscriber.cs プロジェクト: shizhexu/opensplice
        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;
        }