internal void FromNative(DataWriterQosWrapper wrapper) { Durability = wrapper.Durability; DurabilityService = wrapper.DurabilityService; Deadline = wrapper.Deadline; LatencyBudget = wrapper.LatencyBudget; Liveliness = wrapper.Liveliness; Reliability = wrapper.Reliability; DestinationOrder = wrapper.DestinationOrder; History = wrapper.History; ResourceLimits = wrapper.ResourceLimits; TransportPriority = wrapper.TransportPriority; Lifespan = wrapper.Lifespan; Ownership = wrapper.Ownership; OwnershipStrength = wrapper.OwnershipStrength; WriterDataLifecycle = wrapper.WriterDataLifecycle; if (UserData == null) { UserData = new UserDataQosPolicy(); } UserData.FromNative(wrapper.UserData); if (Representation == null) { Representation = new DataRepresentationQosPolicy(); } Representation.FromNative(wrapper.Representation); }
internal DataWriterQosWrapper ToNative() { var data = new DataWriterQosWrapper { Durability = Durability, DurabilityService = DurabilityService, Deadline = Deadline, LatencyBudget = LatencyBudget, Liveliness = Liveliness, Reliability = Reliability, DestinationOrder = DestinationOrder, History = History, ResourceLimits = ResourceLimits, TransportPriority = TransportPriority, Lifespan = Lifespan, Ownership = Ownership, OwnershipStrength = OwnershipStrength, WriterDataLifecycle = WriterDataLifecycle, }; if (UserData != null) { data.UserData = UserData.ToNative(); } if (Representation != null) { data.Representation = Representation.ToNative(); } return(data); }
/// <summary> /// Creates a new <see cref="DataWriter" /> with the desired QoS policies and attaches to it the specified <see cref="DataWriterListener" /> /// </summary> /// <remarks> /// <para>The created <see cref="DataWriter" /> will be attached and belongs to the <see cref="Publisher" /> that is its factory.</para> /// <para>The <see cref="Topic" /> passed to this operation must have been created from the same <see cref="DomainParticipant" /> that was used to create this /// <see cref="Publisher" />. If the <see cref="Topic" /> was created from a different <see cref="DomainParticipant" />, /// the operation will fail and return a <see langword="null"/> result.</para> /// </remarks> /// <param name="topic">The <see cref="Topic" /> that the <see cref="DataWriter" /> will be associated with.</param> /// <param name="qos">The <see cref="DataWriterQos" /> policies to be used for creating the new <see cref="DataWriter" />.</param> /// <param name="listener">The <see cref="DataWriterListener" /> to be attached to the newly created <see cref="DataWriter" />.</param> /// <param name="statusMask">The <see cref="StatusMask" /> of which status changes the listener should be notified.</param> /// <returns>The newly created <see cref="DataWriter" /> on success, otherwise <see langword="null"/>.</returns> public DataWriter CreateDataWriter(Topic topic, DataWriterQos qos, DataWriterListener listener, StatusMask statusMask) { if (topic is null) { throw new ArgumentNullException(nameof(topic)); } DataWriterQosWrapper qosWrapper = default; if (qos is null) { qos = new DataWriterQos(); var ret = GetDefaultDataWriterQos(qos); if (ret == ReturnCode.Ok) { qosWrapper = qos.ToNative(); } } else { qosWrapper = qos.ToNative(); } IntPtr nativeListener = IntPtr.Zero; if (listener != null) { nativeListener = listener.ToNative(); } IntPtr native = UnsafeNativeMethods.CreateDataWriter(_native, topic.ToNative(), qosWrapper, nativeListener, statusMask); if (native.Equals(IntPtr.Zero)) { return(null); } qos.Release(); var dw = new DataWriter(native) { Listener = listener, }; EntityManager.Instance.Add((dw as Entity).ToNative(), dw); ContainedEntities.Add(dw); return(dw); }
/// <summary> /// Gets the <see cref="DataWriter" /> QoS policies. /// </summary> /// <param name="qos">The <see cref="DataWriterQos" /> to be filled up.</param> /// <returns>The <see cref="ReturnCode" /> that indicates the operation result.</returns> public ReturnCode GetQos(DataWriterQos qos) { if (qos == null) { return(ReturnCode.BadParameter); } DataWriterQosWrapper qosWrapper = default; var ret = UnsafeNativeMethods.GetQos64(_native, ref qosWrapper); if (ret == ReturnCode.Ok) { qos.FromNative(qosWrapper); } qos.Release(); return(ret); }
public static extern ReturnCode SetQos(IntPtr dw, [MarshalAs(UnmanagedType.Struct), In] DataWriterQosWrapper qos);
public static extern ReturnCode GetQos64(IntPtr dw, [MarshalAs(UnmanagedType.Struct), In, Out] ref DataWriterQosWrapper qos);
public static extern IntPtr CreateDataWriter(IntPtr pub, IntPtr topic, [MarshalAs(UnmanagedType.Struct), In] DataWriterQosWrapper qos, IntPtr a_listener, uint mask);