Example #1
0
        // TODO: This operation is currently not thread-safe.
        public virtual ReturnCode RegisterType(
            IDomainParticipant participant,
            string typeName,
            DatabaseMarshaler marshaler)
        {
            ReturnCode result = ReturnCode.BadParameter;

            if (participant != null && marshaler != null)
            {
                // Now that a marshaler is present,
                result = AttachMarshalerDelegates(GapiPeer, marshaler);
                if (result == ReturnCode.Ok)
                {
                    IntPtr domainObj = (participant as DomainParticipant).GapiPeer;
                    result = Gapi.FooTypeSupport.register_type(
                        GapiPeer,
                        domainObj,
                        typeName);

                    if (result == ReturnCode.Ok)
                    {
                        DatabaseMarshaler.Add(participant, dataType, marshaler);
                        marshaler.InitEmbeddedMarshalers(participant);
                    }
                }
            }

            return(result);
        }
 public override void InitEmbeddedMarshalers(IDomainParticipant participant)
 {
     if (attr1Marshaler == null)
     {
         attr1Marshaler = DatabaseMarshaler.GetMarshaler(participant, typeof(DM.__l_WGS84)) as DM.__l_WGS84Marshaler;
         if (attr1Marshaler == null)
         {
             attr1Marshaler = new DM.__l_WGS84Marshaler();
             DatabaseMarshaler.Add(participant, typeof(DM.__l_WGS84), attr1Marshaler);
             attr1Marshaler.InitEmbeddedMarshalers(participant);
         }
     }
     if (attr4Marshaler == null)
     {
         attr4Marshaler = DatabaseMarshaler.GetMarshaler(participant, typeof(DM.__EGI_Data)) as DM.__EGI_DataMarshaler;
         if (attr4Marshaler == null)
         {
             attr4Marshaler = new DM.__EGI_DataMarshaler();
             DatabaseMarshaler.Add(participant, typeof(DM.__EGI_Data), attr4Marshaler);
             attr4Marshaler.InitEmbeddedMarshalers(participant);
         }
     }
     if (attr5Marshaler == null)
     {
         attr5Marshaler = DatabaseMarshaler.GetMarshaler(participant, typeof(__Aircraft)) as __AircraftMarshaler;
         if (attr5Marshaler == null)
         {
             attr5Marshaler = new __AircraftMarshaler();
             DatabaseMarshaler.Add(participant, typeof(__Aircraft), attr5Marshaler);
             attr5Marshaler.InitEmbeddedMarshalers(participant);
         }
     }
 }
Example #3
0
        private void loadQosInputAttr(
            OpenSplice.CustomMarshalers.DatabaseMarshaler qosMarshaler,
            Type dataType,
            ref OpenSplice.Common.cmn_qosInputAttr attr)
        {
            DatabaseMarshaler.Add(null, dataType, qosMarshaler);
            qosMarshaler.InitEmbeddedMarshalers(null);

            attr.copyOut = qosMarshaler.CopyOutDelegate;
        }
 public override void InitEmbeddedMarshalers(IDomainParticipant participant)
 {
     if (attr2Marshaler == null)
     {
         attr2Marshaler = DatabaseMarshaler.GetMarshaler(participant, typeof(DM.__l_WGS84)) as DM.__l_WGS84Marshaler;
         if (attr2Marshaler == null)
         {
             attr2Marshaler = new DM.__l_WGS84Marshaler();
             DatabaseMarshaler.Add(participant, typeof(DM.__l_WGS84), attr2Marshaler);
             attr2Marshaler.InitEmbeddedMarshalers(participant);
         }
     }
 }
        public virtual ReturnCode RegisterType(
            IDomainParticipant participant,
            string typeName,
            DatabaseMarshaler marshaler)
        {
            ReturnCode        result = ReturnCode.BadParameter;
            DomainParticipant dp;

            ReportStack.Start();
            if (participant == null)
            {
                ReportStack.Report(result, "domain '<NULL>' is invalid.");
            }
            else if (marshaler == null)
            {
                ReportStack.Report(result, "marshaler '<NULL>' is invalid.");
            }
            else
            {
                dp = participant as DomainParticipant;
                if (dp == null)
                {
                    ReportStack.Report(result, "domain is invalid, not of type " +
                                       "DDS::OpenSplice::DomainParticipant");
                }
                else
                {
                    if (typeName == null)
                    {
                        typeName = this.typeName;
                    }
                    result = dp.nlReq_LoadTypeSupport(this, typeName);
                    if (result == ReturnCode.AlreadyDeleted)
                    {
                        result = ReturnCode.BadParameter;
                    }
                    else
                    {
                        DatabaseMarshaler.Add(dp, dataType, marshaler);
                        marshaler.InitEmbeddedMarshalers(dp);
                    }
                }
            }
            ReportStack.Flush(null, result != ReturnCode.Ok);
            return(result);
        }
Example #6
0
        private ReturnCode AttachMarshalerDelegates(IntPtr ts, DatabaseMarshaler marshaler)
        {
            Gapi._TypeSupport typeSupport = null;
            IntPtr            tsPtr       = IntPtr.Zero;
            ReturnCode        result      = ReturnCode.Ok;

            typeSupport = Gapi.TypeSupport.Claim(ts, out tsPtr, ref result);
            if (result == ReturnCode.Ok)
            {
                typeSupport.copy_in = marshaler.CopyInDelegate;

                // HACK: This is a Mono workaround. Currently you cannot marshal a delegate
                // to a function pointer if the parameters include an "object" type. So we
                // will pass a fake delegate, and then internally use the real copyOut, this
                // may give better performance anyways, since we won't have to convert the
                // IntPtr to a Delegate for every ReaderCopy invocation.
                typeSupport.copy_out = marshaler.CopyOutDelegate;

                typeSupport.reader_copy = marshaler.ReaderCopyDelegate;
                Gapi.TypeSupport.Release(typeSupport, tsPtr);
            }

            return(result);
        }
Example #7
0
        public IDataWriter CreateDataWriter(
            ITopic topic,
            DataWriterQos qos,
            IDataWriterListener listener,
            StatusKind mask)
        {
            ReturnCode result     = DDS.ReturnCode.AlreadyDeleted;
            DataWriter dataWriter = null;
            Topic      topicObj   = topic as Topic;

            ReportStack.Start();
            lock (this)
            {
                if (this.rlReq_isAlive)
                {
                    if (topicObj == null)
                    {
                        result = DDS.ReturnCode.BadParameter;
                        ReportStack.Report(result, "topic is invalid (null), or not of type " +
                                           "DDS::OpenSplice::Topic.");
                    }
                    else
                    {
                        result = QosManager.checkQos(qos);
                    }

                    if (result == DDS.ReturnCode.Ok)
                    {
                        lock (topicObj)
                        {
                            if (topicObj.rlReq_isAlive)
                            {
                                TypeSupport       ts        = (topicObj as ITopicDescriptionImpl).rlReq_TypeSupport;
                                DatabaseMarshaler marshaler = DatabaseMarshaler.GetMarshaler(participant, ts.TypeSpec);
                                dataWriter = ts.CreateDataWriter(marshaler);
                                result     = dataWriter.init(this, qos, topicObj, "writer <" + topicObj.Name + ">");
                                if (result == ReturnCode.Ok)
                                {
                                    dataWriter.wlReq_ListenerDispatcher = this.wlReq_ListenerDispatcher;
                                    result = dataWriter.SetListener(listener, mask);
                                }
                                else
                                {
                                    dataWriter = null;
                                }

                                if (result == DDS.ReturnCode.Ok)
                                {
                                    writerList.Add(dataWriter);
                                    if (rlReq_AutoEnableCreatedEntities)
                                    {
                                        result = dataWriter.Enable();
                                    }
                                }
                            }
                            else
                            {
                                // ALREADY_DELETED may only apply to the Publisher in this context,
                                // so for a deleted topic use BAD_PARAMETER instead.
                                result = DDS.ReturnCode.BadParameter;
                            }
                        }
                    }

                    if (result != ReturnCode.Ok && dataWriter != null)
                    {
                        // Ignore result because we prefer the original error.
                        DeleteDataWriter(dataWriter);
                        dataWriter = null;
                    }
                }
            }
            ReportStack.Flush(this, result != ReturnCode.Ok);

            return(dataWriter);
        }
 public abstract DataReader CreateDataReader(DatabaseMarshaler marshaler);
 public abstract DataWriter CreateDataWriter(DatabaseMarshaler marshaler);
Example #10
0
        /**
         * Register the four builtin topics:
         *     "DDS::ParticipantBuiltinTopicData"
         *     "DDS::TopicBuiltinTopicData"
         *     "DDS::PublicationBuiltinTopicData"
         *     "DDS::SubscriptionBuiltinTopicData"
         */
        internal static ReturnCode BuiltinTopicRegisterTypeSupport(DomainParticipant participant)
        {
            ReturnCode result;

            DDS.ParticipantBuiltinTopicDataTypeSupport DDSParticipant =
                new DDS.ParticipantBuiltinTopicDataTypeSupport();
            result = DDSParticipant.RegisterType(participant, DDSParticipant.TypeName);
            if (result != ReturnCode.Ok)
            {
                DDS.OpenSplice.OS.Report(
                    DDS.OpenSplice.ReportType.OS_ERROR,
                    "DDS.OpenSplice.DomainParticipant.builtinTopicRegisterTypeSupport",
                    "DDS/OpenSplice/DomainParticipant.cs",
                    DDS.ErrorCode.Error,
                    "Failed to register builtin topic: DCPSParticipant");
            }
            else
            {
                participant.ParticipantDataMarshaler = DatabaseMarshaler.GetMarshaler(
                    participant, DDSParticipant.TypeSpec);
            }

            DDS.TopicBuiltinTopicDataTypeSupport DDSTopic =
                new DDS.TopicBuiltinTopicDataTypeSupport();
            result = DDSTopic.RegisterType(participant, DDSTopic.TypeName);
            if (result != ReturnCode.Ok)
            {
                DDS.OpenSplice.OS.Report(
                    DDS.OpenSplice.ReportType.OS_ERROR,
                    "DDS.OpenSplice.DomainParticipant.builtinTopicRegisterTypeSupport",
                    "DDS/OpenSplice/DomainParticipant.cs",
                    DDS.ErrorCode.Error,
                    "Failed to register builtin topic: DCPSTopic");
            }
            else
            {
                participant.TopicDataMarshaler = DatabaseMarshaler.GetMarshaler(
                    participant, DDSTopic.TypeSpec);
            }

            DDS.PublicationBuiltinTopicDataTypeSupport DDSPublication =
                new DDS.PublicationBuiltinTopicDataTypeSupport();
            result = DDSPublication.RegisterType(participant, DDSPublication.TypeName);
            if (result != ReturnCode.Ok)
            {
                DDS.OpenSplice.OS.Report(
                    DDS.OpenSplice.ReportType.OS_ERROR,
                    "DDS.OpenSplice.DomainParticipant.builtinTopicRegisterTypeSupport",
                    "DDS/OpenSplice/DomainParticipant.cs",
                    DDS.ErrorCode.Error,
                    "Failed to register builtin topic: DCPSPublication");
            }

            DDS.SubscriptionBuiltinTopicDataTypeSupport DDSSubscription =
                new DDS.SubscriptionBuiltinTopicDataTypeSupport();
            result = DDSSubscription.RegisterType(participant, DDSSubscription.TypeName);
            if (result != ReturnCode.Ok)
            {
                DDS.OpenSplice.OS.Report(
                    DDS.OpenSplice.ReportType.OS_ERROR,
                    "DDS.OpenSplice.DomainParticipant.builtinTopicRegisterTypeSupport",
                    "DDS/OpenSplice/DomainParticipant.cs",
                    DDS.ErrorCode.Error,
                    "Failed to register builtin topic: DCPSSubscription");
            }
            return(result);
        }
Example #11
0
 public FooDataWriter(DatabaseMarshaler marshaler)
 {
     sampleMarshaler = marshaler as TMarshaler;
 }