1. --  (c) Copyright, Real-Time Innovations, $Date:: 2012-02-16 #$ 
  2. --  All rights reserved. 
  3. -- 
  4. --  No duplications, whole or partial, manual or electronic, may be made 
  5. --  without express written permission.  Any such copies, or 
  6. --  revisions thereof, must display this notice unaltered. 
  7. --  This code contains trade secrets of Real-Time Innovations, Inc. 
  8.  
  9. with DDS.DataWriter; 
  10. with DDS.DataWriter_Impl; 
  11. with DDS.Treats_Generic; 
  12. generic 
  13.    with package Treats is new DDS.Treats_Generic (<>); 
  14.    use Treats; 
  15. package DDS.Typed_DataWriter_Generic is 
  16.  
  17.    type Ref is new Standard.DDS.DataWriter_Impl.Ref with null record; 
  18.    type Ref_Access is access all Ref'Class; 
  19.  
  20.    function Register_Instance 
  21.      (Self          : not null access Ref; 
  22.       Instance_Data : not null Data_Type_Access) 
  23.       return Standard.DDS.InstanceHandle_T; 
  24.    --  <dref>FooDataWriter_register_instance</dref> 
  25.    --  <internal> 
  26.    --  Informs Data Distribution Service that the application will be modifying a 
  27.    --  particular instance. 
  28.    --  This operation is only useful for keyed data types. Using it for non-keyed 
  29.    --  types causes no effect and returns HANDLE_NIL. The operation takes as a parameter 
  30.    --  an instance (of which only the key value is examined) and returns a handle that 
  31.    --  can be used in successive write() or dispose() operations. 
  32.    --  The operation gives Data Distribution Service an opportunity to pre-configure 
  33.    --  itself to improve performance. 
  34.    --  The use of this operation by an application is optional even for keyed types. 
  35.    --  If an instance has not been pre-registered, the application can use the special 
  36.    --  value HANDLE_NIL as the InstanceHandle_t paramater to the write or dispose 
  37.    --  operation and Data Distribution Service will auto-register the instance. 
  38.    --  For best performance, the operation should be invoked prior to calling any 
  39.    --  operation that modifies the instance, such as write, write_w_timestamp, 
  40.    --  dispose and dispose_w_timestamp and the handle used in conjunction with 
  41.    --  the data for those calls. 
  42.    --  When this operation is used, Data Distribution Service will automatically supply 
  43.    --  the value of the source_timestamp that is used. 
  44.    --  This operation may fail and return HANDLE_NIL if ResourceLimitsQosPolicy::max_instances 
  45.    --  limit has been exceeded. 
  46.    --  The operation is idempotent. If it is called for an already registered instance, 
  47.    --  it just returns the already allocated handle. This may be used to lookup and retrieve 
  48.    --  the handle allocated to a given instance. 
  49.    --  This operation can only be called after DataWriter has been enabled. 
  50.    --  Otherwise, HANDLE_NIL will be returned. 
  51.    --  </internal> 
  52.  
  53.  
  54.    function Register_Instance_W_Timestamp 
  55.      (Self             : not null access Ref; 
  56.       Instance_Data    : not null Data_Type_Access; 
  57.       Source_Timestamp : in Standard.DDS.Time_T) 
  58.       return Standard.DDS.InstanceHandle_T; 
  59.    --  <dref>FooDataWriter_register_instance_w_timestamp</dref> 
  60.    --  <internal> 
  61.    --  Performs the same functions as register_instance except that the application 
  62.    --  provides the value for the source_timestamp. 
  63.    --  The provided source_timestamp potentially affects the relative order in which 
  64.    --  readers observe events from multiple writers. Refer to DESTINATION_ORDER QoS policy for details. 
  65.    --  This operation may fail and return DDS_HANDLE_NIL if ResourceLimitsQosPolicy::max_instances 
  66.    --  limit has been exceeded. 
  67.    --  This operation can only be called after DataWriter has been enabled. 
  68.    --  Otherwise, HANDLE_NIL will be returned. 
  69.    --  </internal> 
  70.  
  71.  
  72.    procedure Unregister_Instance 
  73.      (Self          : not null access Ref; 
  74.       Instance_Data : not null Data_Type_Access; 
  75.       Handle        : in Standard.DDS.InstanceHandle_T); 
  76.    --  <dref>FooDataWriter_unregister_instance</dref> 
  77.    --  <internal> 
  78.    --  Reverses the action of register_instance. 
  79.    --  This operation is useful only for keyed data types. Using it for non-keyed types 
  80.    --  causes no effect and reports no error. The operation takes as a parameter an 
  81.    --  instance (of which only the key value is examined) and a handle. 
  82.    --  This operation should only be called on an instance that is currently registered. 
  83.    --  This includes instances that have been auto-registered by calling operations such 
  84.    --  as write or dispose as described in register_instance. Otherwise, this operation may 
  85.    --  fail with exception BAD_PARAMETER. 
  86.    --  This only need be called just once per instance, regardless of how many times 
  87.    --  register_instance was called for that instance. 
  88.    --  When this operation is used, DDS will automatically supply 
  89.    --  the value of the source_timestamp that is used. 
  90.    --  This operation informs DDS that the DataWriter is no longer 
  91.    --  going to provide any information about the instance. This operation also indicates 
  92.    --  that DDS can locally remove all information regarding that instance. 
  93.    --  The application should not attempt to use the handle previously allocated to 
  94.    --  that instance after calling unregister_instance(). 
  95.    --  The special value HANDLE_NIL can be used for the parameter handle. 
  96.    --  This indicates that the identity of the instance should be automatically deduced 
  97.    --  from the instance_data (by means of the key). 
  98.    --  If handle is any value other than HANDLE_NIL, then it must correspond to an instance 
  99.    --  that has been registered. If there is no correspondence, the operation will fail with 
  100.    --  exception BAD_PARAMETER. 
  101.    --  DDS will not detect the error when the handle is any value other than HANDLE_NIL, 
  102.    --  corresponds to an instance that has been registered, but does not correspond to the 
  103.    --  instance deduced from the instance_data (by means of the key). DDS will treat as if 
  104.    --  the unregister_instance() operation is for the instance as indicated by the handle. 
  105.    --  If after a unregister_instance, the application wants to modify (write or dispose) 
  106.    --  an instance, it has to register it again, or else use the special handle value HANDLE_NIL. 
  107.    --  This operation does not indicate that the instance is deleted 
  108.    --  (that is the purpose of dispose). The operation unregister_instance just indicates 
  109.    --  that the DataWriter no longer has anything to say about the instance. DataReader 
  110.    --  entities that are reading the instance may receive a sample with 
  111.    --  NOT_ALIVE_NO_WRITERS_INSTANCE_STATE for the instance, unless there are other 
  112.    --  DataWriter objects writing that same instance. 
  113.    --  This operation can affect the ownership of the data instance (see OWNERSHIP). 
  114.    --  If the DataWriter was the exclusive owner of the instance, then calling 
  115.    --  unregister_instance() will relinquish that ownership. 
  116.    --  If ReliabilityQosPolicy::kind is set to RELIABLE_RELIABILITY_QOS and the unregistration 
  117.    --  would overflow the resource limits of this writer or of a reader, this operation 
  118.    --  may block for up to ReliabilityQosPolicy::max_blocking_time; if this writer is 
  119.    --  still unable to unregister after that period, this function will fail with exception TIMEOUT. 
  120.    --  </internal> 
  121.  
  122.  
  123.    procedure Unregister_Instance_W_Timestamp 
  124.      (Self              : not null access Ref; 
  125.       Instance_Data    : not null Data_Type_Access; 
  126.       Handle           : in Standard.DDS.InstanceHandle_T; 
  127.       Source_Timestamp : in Standard.DDS.Time_T); 
  128.    --  <dref>FooDataWriter_unregister_instance_w_timestamp</dref> 
  129.    --  <internal> 
  130.    --  Performs the same function as unregister_instance except that it also provides 
  131.    --  the value for the source_timestamp. 
  132.    --  The provided source_timestamp potentially affects the relative order in which 
  133.    --  readers observe events from multiple writers. Refer to DESTINATION_ORDER QoS policy for details. 
  134.    --  The constraints on the values of the handle parameter and the corresponding error 
  135.    --  behavior are the same specified for the unregister_instance operation. 
  136.    --  This operation may block and may time out (exception RETCODE_TIMEOUT) under 
  137.    --  the same circumtances described for the unregister_instance operation. 
  138.    --  </internal> 
  139.  
  140.  
  141.    procedure Write 
  142.      (Self           : not null access Ref; 
  143.       Instance_Data : not null Data_Type_Access; 
  144.       Handle        : in Standard.DDS.InstanceHandle_T_Access); 
  145.    --  <dref>FooDataWriter_write</dref> 
  146.    --  <internal> 
  147.    --  Modifies the value of a data instance. 
  148.    --  When this operation is used, DDS will automatically supply the value of the 
  149.    --  source_timestamp that is made available to DataReader objects by means of the 
  150.    --  source_timestamp attribute inside the SampleInfo. 
  151.    --  (Refer to SampleInfo and DESTINATION_ORDER QoS policy for details). 
  152.    --  As a side effect, this operation asserts liveliness on the DataWriter itself, 
  153.    --  the Publisher and the DomainParticipant. 
  154.    --  Note that the special value HANDLE_NIL can be used for the parameter handle. 
  155.    --  This indicates the identity of the instance should be automatically deduced 
  156.    --  from the instance_data (by means of the key). 
  157.    --  If handle is any value other than HANDLE_NIL, then it must correspond to an instance 
  158.    --  that has been registered. If there is no correspondence, the operation will fail 
  159.    --  with exception BAD_PARAMETER. 
  160.    --  DDS will not detect the error when the handle is any value other than HANDLE_NIL, 
  161.    --  corresponds to an instance that has been registered, but does not correspond 
  162.    --  to the instance deduced from the instance_data (by means of the key). 
  163.    --  DDS will treat as if the write() operation is for the instance as indicated by the handle. 
  164.    --  This operation may block if the RELIABILITY kind is set to RELIABLE_RELIABILITY_QOS 
  165.    --  and the modification would cause data to be lost or else cause one of the limits 
  166.    --  specified in the RESOURCE_LIMITS to be exceeded. 
  167.    --  Specifically, this operation may block in the following situations 
  168.    --  (note that the list may not be exhaustive), 
  169.    --   even if its HistoryQosPolicyKind is KEEP_LAST_HISTORY_QOS: 
  170.    --   * If (ResourceLimitsQosPolicy::max_samples < 
  171.    --            ResourceLimitsQosPolicy::max_instances * HistoryQosPolicy::depth), 
  172.    --     then in the situation where the max_samples resource limit is exhausted, 
  173.    --     DDS is allowed to discard samples of some other instance, as long as at 
  174.    --     least one sample remains for such an instance. If it is still not possible 
  175.    --     to make space available to store the modification, the writer is allowed to block. 
  176.    --   * If (ResourceLimitsQosPolicy::max_samples < ResourceLimitsQosPolicy::max_instances), 
  177.    --     then the DataWriter may block regardless of the HistoryQosPolicy::depth. 
  178.    --  This operation may also block when using BEST_EFFORT_RELIABILITY_QOS and 
  179.    --  ASYNCHRONOUS_PUBLISH_MODE_QOS. In this case, the DataWriter will queue samples 
  180.    --  until they are sent by the asynchronous publishing thread. 
  181.    --  The number of samples that can be stored is determined by the HistoryQosPolicy. 
  182.    --  If the asynchronous thread does not send samples fast enough 
  183.    --  (e.g., when using a slow FlowController), the queue may fill up. In that case, 
  184.    --  subsequent write calls will block. 
  185.    --  If this operation does block for any of the above reasons, the RELIABILITY 
  186.    --  max_blocking_time configures the maximum time the write operation may block 
  187.    --  (waiting for space to become available). If max_blocking_time elapses before 
  188.    --  the DataWriter is able to store the modification without exceeding the limits, 
  189.    --  the operation will time out (exception TIMEOUT). 
  190.    --  If there are no instance resources left, this operation may fail with exception 
  191.    --  OUT_OF_RESOURCES. Calling DataWriter.unregister_instance may help 
  192.    --  freeing up some resources. 
  193.    --  </internal> 
  194.  
  195.  
  196.    procedure Write_W_Timestamp 
  197.      (Self           : not null access Ref; 
  198.       Instance_Data    : not null Data_Type_Access; 
  199.       Handle           : in Standard.DDS.InstanceHandle_T_Access; 
  200.       Source_Timestamp : in Standard.DDS.Time_T); 
  201.    --  <dref>FooDataWriter_write_w_timestamp</dref> 
  202.    --  <internal> 
  203.    --  Performs the same function as write except that it also provides the value 
  204.    --  for the source_timestamp. 
  205.    --  Explicitly provides the timestamp that will be available to the DataReader objects 
  206.    --  by means of the source_timestamp attribute inside the SampleInfo. 
  207.    --  (Refer to SampleInfo and DESTINATION_ORDER QoS policy for details) 
  208.    --  The constraints on the values of the handle parameter and the corresponding 
  209.    --  error behavior are the same specified for the write operation. 
  210.    --  This operation may block and time out (exception TIMEOUT) 
  211.    --  under the same circumtances described for write. 
  212.    --  If there are no instance resources left, this operation may fail with 
  213.    --  exception OUT_OF_RESOURCES. Calling unregister_instance may help free up some resources. 
  214.    --  This operation may fail with exception BAD_PARAMETER under the same circumstances 
  215.    --  described for the write operation. 
  216.    --  </internal> 
  217.  
  218.  
  219.    procedure Dispose 
  220.      (Self            : not null access Ref; 
  221.       Instance_Data   : not null Data_Type_Access; 
  222.       Instance_Handle : in Standard.DDS.InstanceHandle_T); 
  223.    --  <dref>FooDataWriter_dispose</dref> 
  224.    --  <internal> 
  225.    --  Requests the middleware to delete the data. 
  226.    --  This operation is useful only for keyed data types. Using it for non-keyed types 
  227.    --  has no effect and reports no error. 
  228.    --  The actual deletion is postponed until there is no more use for that data in the whole system. 
  229.    --  Applications are made aware of the deletion by means of operations on the DataReader 
  230.    --  objects that already knew that instance. DataReader objects that didn't know 
  231.    --  the instance will never see it. 
  232.    --  This operation does not modify the value of the instance. 
  233.    --  The instance_data parameter is passed just for the purposes of identifying the instance. 
  234.    --  When this operation is used, DDS will automatically 
  235.    --  supply the value of the source_timestamp that is made available to DataReader 
  236.    --  objects by means of the source_timestamp attribute inside the SampleInfo. 
  237.    --  The constraints on the values of the handle parameter and the corresponding 
  238.    --  error behavior are the same specified for the DataWriter.unregister_instance operation. 
  239.    --  The special value HANDLE_NIL can be used for the parameter instance_handle. 
  240.    --  This indicates the identity of the instance should be automatically deduced 
  241.    --  from the instance_data (by means of the key). 
  242.    --  If handle is any value other than HANDLE_NIL, then it must correspond to an 
  243.    --  instance that has been registered. If there is no correspondence, the operation 
  244.    --  will fail with exception BAD_PARAMETER. 
  245.    --  DDS will not detect the error when the handle is any 
  246.    --  value other than HANDLE_NIL, corresponds to an instance that has been registered, 
  247.    --  but does not correspond to the instance deduced from the instance_data (by means of the key). 
  248.    --  DDS will treat as if the dispose() operation is for the instance as indicated by the handle. 
  249.    --  This operation may block and time out (exception TIMEOUT) under the same 
  250.    --  circumtances described for write(). 
  251.    --  If there are no instance resources left, this operation may fail with exception OUT_OF_RESOURCES. 
  252.    --  Calling unregister_instance may help freeing up some resources. 
  253.    --  </internal> 
  254.  
  255.  
  256.    procedure Dispose_W_Timestamp 
  257.      (Self             : not null access Ref; 
  258.       Instance_Data    : not null Data_Type_Access; 
  259.       Instance_Handle  : in Standard.DDS.InstanceHandle_T; 
  260.       Source_Timestamp : in Standard.DDS.Time_T); 
  261.    --  <dref>FooDataWriter_dispose_w_timestamp</dref> 
  262.    --  <internal> 
  263.    --  Performs the same functions as dispose except that the application provides 
  264.    --  the value for the source_timestamp that is made available to DataReader objects 
  265.    --  by means of the source_timestamp attribute inside the SampleInfo. 
  266.    --  The constraints on the values of the handle parameter and the corresponding 
  267.    --  error behavior are the same specified for the dispose operation. 
  268.    --  This operation may block and time out (exception TIMEOUT) under the same 
  269.    --  circumtances described for write. 
  270.    --  If there are no instance resources left, this operation may fail 
  271.    --  with exception OUT_OF_RESOURCES. 
  272.    --  Calling unregister_instance may help freeing up some resources. 
  273.    --  </internal> 
  274.  
  275.  
  276.    procedure Get_Key_Value 
  277.      (Self       : not null access Ref; 
  278.       Key_Holder : not null Data_Type_Access; 
  279.       Handle     : in Standard.DDS.InstanceHandle_T); 
  280.    --  <dref>FooDataWriter_get_key_value</dref> 
  281.    --  <internal> 
  282.    --  Retrieve the instance key that corresponds to an instance handle. 
  283.    --  Useful for keyed data types. 
  284.    --  The operation will only fill the fields that form the key inside the key_holder instance. 
  285.    --  If the data has no key, this function has no effect and exit with no error. 
  286.    --  For keyed data types, this operation may fail with exception BAD_PARAMETER 
  287.    --  if the handle does not correspond to an existing data-object known to the DataWriter. 
  288.    --  </internal> 
  289.  
  290.  
  291.    function Lookup_Instance 
  292.      (Self        : not null access Ref; 
  293.       Key_Holder : not null Data_Type_Access) return Standard.DDS.InstanceHandle_T; 
  294.    --  <dref>FooDataWriter_lookup_instance</dref> 
  295.    --  <internal> 
  296.    --  Retrieve the instance handle that corresponds to an instance key_holder. 
  297.    --  Useful for keyed data types. 
  298.    --  This operation takes as a parameter an instance and returns a handle that can be 
  299.    --  used in subsequent operations that accept an instance handle as an argument. 
  300.    --  The instance parameter is only used for the purpose of examining the fields 
  301.    --  that define the key. 
  302.    --  This operation does not register the instance in question. 
  303.    --  If the instance has not been previously registered, or if for any other reason 
  304.    --  DDS is unable to provide an instance handle, DDS will return the special value HANDLE_NIL. 
  305.    --  </internal> 
  306.  
  307.  
  308.    function Narrow 
  309.      (Self        : access DDS.DataWriter.Ref'Class) return not null access Ref; 
  310.  
  311.    --  ========================================================================= 
  312.    -- 
  313.    --  Internal Routines not to be used by the application 
  314.    -- 
  315.    --  ========================================================================= 
  316.  
  317.    function CreateTypedI return Standard.DDS.DataWriter.Ref_Access; 
  318.  
  319.    procedure DestroyTypedI 
  320.      (Writer : in out Standard.DDS.DataWriter.Ref_Access); 
  321.  
  322. end DDS.Typed_DataWriter_Generic;