Beispiel #1
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 static void Add(
            IDomainParticipant participant,
            Type t,
            DatabaseMarshaler marshaler)
        {
            DatabaseMarshaler tmp;

            // Check if a Marshaler for this type already exists, and if not, add it.
            if (!typeMarshalers.TryGetValue(new KeyValuePair <IDomainParticipant, Type>(participant, t), out tmp))
            {
                // Add the new marshaler to the list of known marshalers.
                typeMarshalers.Add(new KeyValuePair <IDomainParticipant, Type>(participant, t), marshaler);
            }
        }
Beispiel #3
0
        public static void Add(
                IDomainParticipant participant,
                Type t,
                DatabaseMarshaler marshaler)
        {
            DatabaseMarshaler tmp;

            // Check if a Marshaler for this type already exists, and if not, add it.
            if (!typeMarshalers.TryGetValue(new KeyValuePair<IDomainParticipant, Type>(participant, t), out tmp))
            {
                // Add the new marshaler to the list of known marshalers.
                typeMarshalers.Add(new KeyValuePair<IDomainParticipant, Type>(participant, t), marshaler);
            }
        }
Beispiel #4
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 = dummyOperationDelegate;

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

            return result;
        }
Beispiel #5
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;
        }