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.  
  10. with DDS.DataReader; 
  11. with DDS.DataReader_Impl; 
  12. with DDS.ReadCondition; 
  13.  
  14. with RTIDDS.Low_Level.ndds_dds_c_dds_c_infrastructure_h;    use RTIDDS.Low_Level.ndds_dds_c_dds_c_infrastructure_h; 
  15. with Ada.Unchecked_Conversion; 
  16. with DDS.Treats_Generic; pragma Elaborate (DDS.Treats_Generic); 
  17. generic 
  18.    with package Treats is new DDS.Treats_Generic (<>); 
  19.    use Treats; 
  20. package DDS.Typed_DataReader_Generic is 
  21.    pragma Suppress (Elaboration_Check); 
  22.  
  23.    type Ref is new DDS.DataReader_Impl.Ref with null record; 
  24.    type Ref_Access is access all Ref'Class; 
  25.  
  26.  
  27.    type Element_Type is record 
  28.       Data        : Data_Type_Access; 
  29.       Sample_Info : SampleInfo_Access; 
  30.    end record; 
  31.    type Cursor is new DDS.Natural; 
  32.  
  33.    --  <<experimental>> <<extension>> Allows for creating an iterator of received_data sequence 
  34.    --  and info_seq 
  35.    type Container (<>) is limited new Ada.Finalization.Limited_Controlled with private with 
  36.      Iterable => (First        => I_First_Element, 
  37.                   Element      => I_Get_Element, 
  38.                   Has_Element  => I_Has_Element, 
  39.                   Next         => I_Advance); 
  40.  
  41.    --  <<experimental>> <<extension>> 
  42.    function I_First_Element (Self : Container) return Cursor; 
  43.  
  44.    --  <<experimental>> <<extension>> 
  45.    function I_Advance (Self : Container; C : Cursor) return Cursor; 
  46.  
  47.    --  <<experimental>> <<extension>> 
  48.    function I_Has_Element (Self : Container; C : Cursor) return Standard.Boolean; 
  49.  
  50.    --  <<experimental>> <<extension>> 
  51.    function I_Get_Element (Self : Container; C : Cursor) return Element_Type; 
  52.  
  53.    --  This is only to simplify the iteration over the read data 
  54.    --   procedure On_Data_Available 
  55.    --      (Self       : not null access Ref; 
  56.    --       The_Reader : in DataReader_Access is 
  57.    --   begin 
  58.    --      for E of Ref (The_Reader).{Read|Take|..} do 
  59.    --         Process (E.Data, E.Sample_Info); 
  60.    --      end loop; 
  61.    --   end; 
  62.  
  63.    procedure Read 
  64.      (Self            : not null access constant Ref; 
  65.       Received_Data   : not null access Data_Sequences.Sequence; 
  66.       Info_Seq        : not null access DDS.SampleInfo_Seq.Sequence; 
  67.       Max_Samples     : in DDS.Long := DDS.LENGTH_UNLIMITED; 
  68.       Sample_States   : in DDS.SampleStateMask := DDS.ANY_SAMPLE_STATE; 
  69.       View_States     : in DDS.ViewStateMask := DDS.ANY_VIEW_STATE; 
  70.       Instance_States : in DDS.InstanceStateMask := DDS.ANY_INSTANCE_STATE); 
  71.    --  <dref>FooDataReader_read</dref> 
  72.  
  73.    procedure Read 
  74.      (Self            : not null access constant Ref; 
  75.       Received_Data   : in out  Data_Sequences.Sequence; 
  76.       Info_Seq        : in out  DDS.SampleInfo_Seq.Sequence; 
  77.       Max_Samples     : in DDS.Long := DDS.LENGTH_UNLIMITED; 
  78.       Sample_States   : in DDS.SampleStateMask := DDS.ANY_SAMPLE_STATE; 
  79.       View_States     : in DDS.ViewStateMask := DDS.ANY_VIEW_STATE; 
  80.       Instance_States : in DDS.InstanceStateMask := DDS.ANY_INSTANCE_STATE); 
  81.    --  <dref>FooDataReader_read</dref> 
  82.  
  83.    function Read 
  84.      (Self            : not null access Ref; 
  85.       Max_Samples     : in DDS.Long := DDS.LENGTH_UNLIMITED; 
  86.       Sample_States   : in DDS.SampleStateMask := DDS.ANY_SAMPLE_STATE; 
  87.       View_States     : in DDS.ViewStateMask := DDS.ANY_VIEW_STATE; 
  88.       Instance_States : in DDS.InstanceStateMask := DDS.ANY_INSTANCE_STATE) return Container'Class; 
  89.    --  <<experimental>> <<extension>> Returns a container which allows for easier iteration through 
  90.    --  samples. See procedure Read 
  91.  
  92.    --  <internal> 
  93.    --  Access a collection of data samples from the DDS_DataReader. 
  94.    --  This operation offers the same functionality and API as take except that the 
  95.    --  samples returned remain in the DDS_DataReader such that they can be retrieved 
  96.    --  again by means of a read or take operation. 
  97.    --  Please refer to the documentation of take for details on the number of samples 
  98.    --  returned within the received_data and info_seq as well as the order in which 
  99.    --  the samples appear in these sequences. 
  100.    --  The act of reading a sample changes its sample_state to DDS_READ_SAMPLE_STATE. 
  101.    --  If the sample belongs to the most recent generation of the instance, 
  102.    --  it will also set the view_state of the instance to be DDS_NOT_NEW_VIEW_STATE. 
  103.    --  It will not affect the instance_state of the instance. 
  104.    --  Important: If the samples "returned" by this function are loaned from 
  105.    --  RTI Data Distribution Service (see take for more information on memory loaning), 
  106.    --  it is important that their contents not be changed. 
  107.    --  Because the memory in which the data is stored belongs to the middleware, 
  108.    --  any modifications made to the data will be seen the next time the same samples 
  109.    --  are read or taken; 
  110.    --  the samples will no longer reflect the state that was received from the network. 
  111.    --  </internal> 
  112.  
  113.    procedure Take 
  114.      (Self            : not null access constant Ref; 
  115.       Received_Data   : not null access Data_Sequences.Sequence; 
  116.       Info_Seq        : not null access DDS.SampleInfo_Seq.Sequence; 
  117.       Max_Samples     : in DDS.Long := DDS.LENGTH_UNLIMITED; 
  118.       Sample_States   : in DDS.SampleStateMask := DDS.ANY_SAMPLE_STATE; 
  119.       View_States     : in DDS.ViewStateMask := DDS.ANY_VIEW_STATE; 
  120.       Instance_States : in DDS.InstanceStateMask := DDS.ANY_INSTANCE_STATE); 
  121.    --  <dref>FooDataReader_take</dref> 
  122.  
  123.    procedure Take 
  124.      (Self            : not null access constant Ref; 
  125.       Received_Data   : out Data_Sequences.Sequence; 
  126.       Info_Seq        : out DDS.SampleInfo_Seq.Sequence; 
  127.       Max_Samples     : in DDS.Long := DDS.LENGTH_UNLIMITED; 
  128.       Sample_States   : in DDS.SampleStateMask := DDS.ANY_SAMPLE_STATE; 
  129.       View_States     : in DDS.ViewStateMask := DDS.ANY_VIEW_STATE; 
  130.       Instance_States : in DDS.InstanceStateMask := DDS.ANY_INSTANCE_STATE); 
  131.    --  <dref>FooDataReader_take</dref> 
  132.  
  133.    function Take 
  134.      (Self            : not null access Ref; 
  135.       Max_Samples     : in DDS.Long := DDS.LENGTH_UNLIMITED; 
  136.       Sample_States   : in DDS.SampleStateMask := DDS.ANY_SAMPLE_STATE; 
  137.       View_States     : in DDS.ViewStateMask := DDS.ANY_VIEW_STATE; 
  138.       Instance_States : in DDS.InstanceStateMask := DDS.ANY_INSTANCE_STATE) return Container'Class; 
  139.    --  <<experimental>> <<extension>> Returns a container which allows for easier iteration through 
  140.    --  samples. See procedure Take 
  141.  
  142.    --  <internal> 
  143.    --  Access a collection of data-samples from the DataReader. 
  144.    --  The operation will return the list of samples received by the 
  145.    --  DataReader since the last DataReader.take operation that match the 
  146.    --  specified SampleStateMask, ViewStateMask and InstanceStateMask. 
  147.    --  This operation may fail with an exception if 
  148.    --  DataReaderResourceLimitsQosPolicy::max_outstanding_reads limit 
  149.    --  has been exceeded. 
  150.    --  The actual number of samples returned depends on the information that has 
  151.    --  been received by the middleware as well as the HistoryQosPolicy, 
  152.    --  ResourceLimitsQosPolicy, DataReaderResourceLimitsQosPolicy and the 
  153.    --  characteristics of the data-type that is associated with the DataReader: 
  154.    --    * In the case where the HistoryQosPolicy::kind is KEEP_LAST_HISTORY_QOS, 
  155.    --      the call will return at most HistoryQosPolicy::depth samples per instance. 
  156.    --    * The maximum number of samples returned is limited by 
  157.    --       ResourceLimitsQosPolicy::max_samples, and by 
  158.    --       DataReaderResourceLimitsQosPolicy::max_samples_per_read. 
  159.    --    * For multiple instances, the number of samples returned is additionally 
  160.    --      limited by the product 
  161.    --       (ResourceLimitsQosPolicy::max_samples_per_instance * 
  162.    --        ResourceLimitsQosPolicy::max_instances) 
  163.    --    * If DataReaderResourceLimitsQosPolicy::max_infos is limited, 
  164.    --      the number of samples returned may also be limited if insufficient 
  165.    --  SampleInfo resources are available. 
  166.    --  If the read or take succeeds and the number of samples returned has been 
  167.    --  limited (by means of a maximum limit, as listed above, or insufficient 
  168.    --  SampleInfo resources), 
  169.    --  the call will complete successfully and provide those samples the reader 
  170.    --  is able to return. The user may need to make additional calls, 
  171.    --  or return outstanding loaned buffers in the case of insuffificient resources, 
  172.    --  in order to access remaining samples. 
  173.    --  Note that in the case where the Topic associated with the DataReader 
  174.    --  is bound to a data-type that has no key definition, 
  175.    --  then there will be at most one instance in the DataReader. 
  176.    --  So the per-sample limits will apply. 
  177.    --  The act of taking a sample removes it from Data Distribution Service 
  178.    --  so it cannot be read or taken again. 
  179.    --  If the sample belongs to the most recent generation of the instance, 
  180.    --  it will also set the view_state of the sample's instance to NOT_NEW_VIEW_STATE. 
  181.    --  It will not affect the instance_state of the sample's instance. 
  182.    --  After DataReader.take completes, received_data and info_seq will be of 
  183.    --  the same length and contain the received data. 
  184.    --  If the sequences are empty (maximum size equal 0) when the take is called, 
  185.    --  the samples returned in the received_data and the corresponding 
  186.    --  info_seq are 'loaned' to the application from buffers provided by the DataReader. 
  187.    --  The application can use them as desired and has guaranteed exclusive access to them. 
  188.    --  Once the application completes its use of the samples it must 'return the loan' 
  189.    --  to the DataReader by calling the DataReader.return_loan operation. 
  190.    --  Note: 
  191.    --   While you must call Return_Loan at some point, you do not have to do so 
  192.    --   before the next take call. 
  193.    --  However, failure to return the loan will eventually deplete the DataReader 
  194.    --  of the buffers it needs to receive new samples and eventually samples will 
  195.    --  start to be lost. The total number of buffers available to the DataReader 
  196.    --  is specified by the ResourceLimitsQosPolicy and the DataReaderResourceLimitsQosPolicy. 
  197.    --  If the sequences are not empty (maximum size not equal 0) when the take is called, 
  198.    --  samples are copied to received_data and info_seq. The application will not 
  199.    --  need to call return_loan. 
  200.    --  The order of the samples returned to the caller depends on the PresentationQosPolicy. 
  201.    --      * If PresentationQosPolicy::access_scope is INSTANCE_PRESENTATION_QOS, 
  202.    --        the returned collection is a list where samples belonging to the 
  203.    --        same data instance are consecutive. 
  204.    --      * If PresentationQosPolicy::access_scope is TOPIC_PRESENTATION_QOS and 
  205.    --        PresentationQosPolicy::ordered_access is set to BOOLEAN_FALSE, 
  206.    --        then returned collection is a list where samples belonging to 
  207.    --        the same data instance are consecutive. 
  208.    --      * If PresentationQosPolicy::access_scope is TOPIC_PRESENTATION_QOS and 
  209.    --        PresentationQosPolicy::ordered_access is set to TRUE, then the 
  210.    --        returned collection is a list were the relative order of samples is 
  211.    --        preserved also accross different instances. Note that samples belonging 
  212.    --        to the same instance may or may not be consecutive. This is because 
  213.    --        to preserve order it may be necessary to mix samples from different instances. 
  214.    --      * If PresentationQosPolicy::access_scope is GROUP_PRESENTATION_QOS and 
  215.    --           PresentationQosPolicy::ordered_access is set to FALSE, then returned 
  216.    --        collection is a list where samples belonging to the same data instance 
  217.    --        are consecutive. [Not supported (optional)] 
  218.    --      * If PresentationQosPolicy::access_scope is GROUP_PRESENTATION_QOS and 
  219.    --           PresentationQosPolicy::ordered_access is set to TRUE, 
  220.    --        then the returned collection contains at most one sample. 
  221.    --        The difference in this case is due to the fact that is required that 
  222.    --        the application is able to read samples belonging to different DataReader 
  223.    --        objects in a specific order. [Not supported (optional)] 
  224.    --  In any case, the relative order between the samples of one instance is consistent 
  225.    --  with the DESTINATION_ORDER policy: 
  226.    --    * If DestinationOrderQosPolicy::kind is BY_RECEPTION_TIMESTAMP_DESTINATIONORDER_QOS, 
  227.    --      samples belonging to the same instances will appear in the relative order 
  228.    --     in which there were received (FIFO, earlier samples ahead of the later samples). 
  229.    --    * If DestinationOrderQosPolicy::kind is BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS, 
  230.    --      samples belonging to the same instances will appear in the relative order 
  231.    --      implied by the source_timestamp (FIFO, smaller values of source_timestamp 
  232.    --      ahead of the larger values). 
  233.    --  If the DataReader has no samples that meet the constraints, the function 
  234.    --  will fail with exception NO_DATA. 
  235.    --  In addition to the collection of samples, the read and take operations also 
  236.    --   use a collection of SampleInfo structures. 
  237.    --  SEQUENCES USAGE IN TAKE AND READ 
  238.    --  The initial (input) properties of the received_data and info_seq collections 
  239.    --  will determine the precise behavior of the read or take operation. 
  240.    --  For the purposes of this description, the collections are modeled as having 
  241.    --  these properties: 
  242.    --      * whether the collection container owns the memory of the elements 
  243.    --        within (owns, see Seq_has_ownership) 
  244.    --      * the current-length (len, see Seq_get_length) 
  245.    --      * the maximum length (max_len, see Seq_get_maximum) 
  246.    -- 
  247.    --  The initial values of the owns, len and max_len properties for the received_data 
  248.    --  and info_seq collections govern the behavior of the read and take operations 
  249.    --  as specified by the following rules : 
  250.    --   1. The values of owns, len and max_len properties for the two collections must be identical. 
  251.    --      Otherwise read/take will fail with PRECONDITION_NOT_MET. 
  252.    --   2. On successful output, the values of owns, len and max_len 
  253.    --      will be the same for both collections. 
  254.    --   3. If the initial max_len==0, then the received_data and info_seq 
  255.    --      collections will be filled with elements that are loaned by the DataReader. 
  256.    --      On output, owns will be FALSE, len will be set to the number of values returned, 
  257.    --      and max_len will be set to a value verifying max_len >= len. 
  258.    --      The use of this variant allows for zero-copy access to the data and 
  259.    --      the application will need to return the loan to the DataWriter using return_loan. 
  260.    --   4. If the initial max_len>0 and owns==FALSE, then the read or take operation 
  261.    --      will fail with exception PRECONDITION_NOT_MET. 
  262.    --      This avoids the potential hard-to-detect memory leaks caused by an 
  263.    --      application forgetting to return the loan. 
  264.    --   5. If initial max_len>0 and owns==TRUE, then the read or take operation will copy 
  265.    --      the received_data values and SampleInfo values into the elements already 
  266.    --      inside the collections. On output, owns will be TRUE, len will be set to 
  267.    --      the number of values copied and max_len will remain unchanged. 
  268.    --      The use of this variant forces a copy but the application can control 
  269.    --      where the copy is placed and the application will not need to return the loan. 
  270.    --      The number of samples copied depends on the relative values of max_len and max_samples: 
  271.    --    * If max_samples == LENGTH_UNLIMITED, then at most max_len values will be copied. 
  272.    --      The use of this variant lets the application limit the number of samples 
  273.    --      returned to what the sequence can accommodate. 
  274.    --    * If max_samples <= max_len, then at most max_samples values will be copied. 
  275.    --      The use of this variant lets the application limit the number of samples 
  276.    --      returned to fewer that what the sequence can accommodate. 
  277.    --    * If max_samples > max_len, then the read or take operation will fail with 
  278.    --      exception PRECONDITION_NOT_MET. This avoids the potential confusion where 
  279.    --      the application expects to be able to access up to max_samples, but that 
  280.    --      number can never be returned, even if they are available in the DataReader, 
  281.    --      because the output sequence cannot accommodate them. 
  282.    --  As described above, upon completion, the received_data and info_seq collections 
  283.    --  may contain elements loaned from the DataReader. 
  284.    --  If this is the case, the application will need to use return_loan to return 
  285.    --  the loan once it is no longer using the received_data in the collection. 
  286.    --  When return_loan completes, the collection will have owns=FALSE and max_len=0. 
  287.    --  The application can determine whether it is necessary to return the loan or not 
  288.    --  based on how the state of the collections when the read/take operation was called 
  289.    --  or by accessing the owns property. However, in many cases it may be simpler to 
  290.    --  always call return_loan, as this operation is harmless 
  291.    --  (i.e., it leaves all elements unchanged) if the collection does not have a loan. 
  292.    --  To avoid potential memory leaks, the implementation of the data and SampleInfo 
  293.    --  collections should disallow changing the length of a collection for which owns==FALSE. 
  294.    --  Furthermore, deleting a collection for which owns==FALSE should be considered an error. 
  295.    --  On output, the collection of data values and the collection of SampleInfo structures 
  296.    --  are of the same length and are in a one-to-one correspondence. 
  297.    --  Each SampleInfo provides information, such as the source_timestamp, 
  298.    --  the sample_state, view_state, and instance_state, etc., about the corresponding sample. 
  299.    -- 
  300.    --  Some elements in the returned collection may not have valid data. 
  301.    --  If the instance_state in the SampleInfo is NOT_ALIVE_DISPOSED_INSTANCE_STATE 
  302.    --  or NOT_ALIVE_NO_WRITERS_INSTANCE_STATE, then the last sample for that instance 
  303.    --  in the collection (that is, the one whose SampleInfo has sample_rank==0) 
  304.    --  does not contain valid data. 
  305.    --  Samples that contain no data do not count towards the limits imposed by the 
  306.    --  ResourceLimitsQosPolicy. The act of reading/taking a sample sets its 
  307.    --  sample_state to READ_SAMPLE_STATE. 
  308.    --  If the sample belongs to the most recent generation of the instance, 
  309.    --  it will also set the view_state of the instance to NOT_NEW_VIEW_STATE. 
  310.    --  It will not affect the instance_state of the instance. 
  311.    --  This operation must be provided on the specialized class that is generated for 
  312.    --  the particular application data-type that is being read. If the DataReader has 
  313.    --  no samples that meet the constraints, the operations fails with exception NO_DATA. 
  314.    --  </internal> 
  315.  
  316.  
  317.    procedure Read_W_Condition 
  318.      (Self          : not null access constant Ref; 
  319.       Received_Data : not null access Data_Sequences.Sequence; 
  320.       Info_Seq      : not null access DDS.SampleInfo_Seq.Sequence; 
  321.       Max_Samples   : in DDS.Long := DDS.LENGTH_UNLIMITED; 
  322.       Condition     : access DDS.ReadCondition.Ref'Class); 
  323.    --  <dref>FooDataReader_read_w_condition</dref> 
  324.  
  325.    procedure Read_W_Condition 
  326.      (Self          : not null access constant Ref; 
  327.       Received_Data : out Data_Sequences.Sequence; 
  328.       Info_Seq      : out DDS.SampleInfo_Seq.Sequence; 
  329.       Max_Samples   : in DDS.Long := DDS.LENGTH_UNLIMITED; 
  330.       Condition     : access DDS.ReadCondition.Ref'Class); 
  331.    --  <dref>FooDataReader_read_w_condition</dref> 
  332.  
  333.    function Read_W_Condition 
  334.      (Self          : not null access Ref; 
  335.       Max_Samples   : in DDS.Long := DDS.LENGTH_UNLIMITED; 
  336.       Condition     : access DDS.ReadCondition.Ref'Class) return Container'Class; 
  337.    --  <<experimental>> <<extension>> Returns a container which allows for easier iteration through 
  338.    --  samples. See procedure Read_W_Condition 
  339.  
  340.    --  <internal> 
  341.    --  Accesses via read the samples that match the criteria specified in the ReadCondition. 
  342.    --  This operation is especially useful in combination with QueryCondition to 
  343.    --  filter data samples based on the content. 
  344.    --  The specified ReadCondition must be attached to the DataReader; 
  345.    --  otherwise the operation will fail with exception PRECONDITION_NOT_MET. 
  346.    --  In case the ReadCondition is a plain ReadCondition and not the 
  347.    --  specialized QueryCondition, the operation is equivalent to calling read 
  348.    --  and passing as sample_states, view_states and instance_states the value of 
  349.    --  the corresponding attributes in the read_condition. 
  350.    --  Using this operation, the application can avoid repeating the same parameters 
  351.    --  specified when creating the ReadCondition. 
  352.    --  The samples are accessed with the same semantics as read. 
  353.    --  If the DataReader has no samples that meet the constraints, 
  354.    --  the operation will fail with exception RETCODE_NO_DATA. 
  355.    --  </internal> 
  356.  
  357.  
  358.    procedure Take_W_Condition 
  359.      (Self          : not null access constant Ref; 
  360.       Received_Data : not null access Data_Sequences.Sequence; 
  361.       Info_Seq      : not null access DDS.SampleInfo_Seq.Sequence; 
  362.       Max_Samples   : in DDS.Long := DDS.LENGTH_UNLIMITED; 
  363.       Condition     : access DDS.ReadCondition.Ref'Class); 
  364.    --  <dref>FooDataReader_take_w_condition</dref> 
  365.  
  366.    function Take_W_Condition 
  367.      (Self          : not null access Ref; 
  368.       Max_Samples   : in DDS.Long := DDS.LENGTH_UNLIMITED; 
  369.       Condition     : access DDS.ReadCondition.Ref'Class) return Container'Class; 
  370.    --  <<experimental>> <<extension>> Returns a container which allows for easier iteration through 
  371.    --  samples. See procedure Take_W_Condition 
  372.  
  373.    --  <internal> 
  374.    --  Analogous to read_w_condition except it accesses samples via the take operation. 
  375.    --  This operation is analogous to read_w_condition except that it accesses 
  376.    --  samples via the take operation. 
  377.    --  The specified ReadCondition must be attached to the DataReader; 
  378.    --  otherwise the operation will fail with exception PRECONDITION_NOT_MET. 
  379.    --  The samples are accessed with the same semantics as take. 
  380.    --  This operation is especially useful in combination with QueryCondition 
  381.    --  to filter data samples based on the content. 
  382.    --  If the DataReader has no samples that meet the constraints, 
  383.    --  the function will fail with exception NO_DATA. 
  384.    --  </internal> 
  385.  
  386.    procedure Read_Next_Sample 
  387.      (Self          : not null access constant Ref; 
  388.       Received_Data : out Data_Type; 
  389.       Sample_Info   : not null access DDS.SampleInfo); 
  390.    --  <dref>FooDataReader_read_next_sample</dref> 
  391.  
  392.    procedure Read_Next_Sample 
  393.      (Self          : not null access constant Ref; 
  394.       Received_Data : not null Data_Type_Access; 
  395.       Sample_Info   : not null access DDS.SampleInfo); 
  396.    --  <dref>FooDataReader_read_next_sample</dref> 
  397.  
  398.    --  <internal> 
  399.    --  Copies the next not-previously-accessed data value from the DataReader. 
  400.    --  This operation copies the next not-previously-accessed data value from the DataReader. 
  401.    --  This operation also copies the corresponding SampleInfo. The implied order among 
  402.    --  the samples stored in the DataReader is the same as for the read operation. 
  403.    --  The read_next_sample operation is semantically equivalent to the read operation, 
  404.    --  where the input data sequences has max_len=1, the sample_states=NOT_READ, 
  405.    --  the view_states=ANY_VIEW_STATE, and the instance_states=ANY_INSTANCE_STATE. 
  406.    --  The read_next_sample operation provides a simplified API to 'read' samples, 
  407.    --  avoiding the need for the application to manage sequences and specify states. 
  408.    --  If there is no unread data in the DataReader, the operation will fail with 
  409.    --  exception NO_DATA and nothing is copied. 
  410.    --  </internal> 
  411.  
  412.    procedure Take_Next_Sample 
  413.      (Self          : not null access constant Ref; 
  414.       Received_Data : not null Data_Type_Access; 
  415.       Sample_Info   : not null access DDS.SampleInfo); 
  416.    --  <dref>FooDataReader_take_next_sample</dref> 
  417.  
  418.    procedure Take_Next_Sample 
  419.      (Self          : not null access constant Ref; 
  420.       Received_Data : out Data_Type; 
  421.       Sample_Info   : not null access DDS.SampleInfo); 
  422.    --  <dref>FooDataReader_take_next_sample</dref> 
  423.  
  424.    --  <internal> 
  425.    --  Copies the next not-previously-accessed data value from the DataReader. 
  426.    --  This operation copies the next not-previously-accessed data value from the DataReader 
  427.    --  and 'removes' it from the DataReader so that it is no longer accessible. 
  428.    --  This operation also copies the corresponding SampleInfo. 
  429.    --  This operation is analogous to the read_next_sample except for the fact 
  430.    --  that the sample is removed from the DataReader. 
  431.    --  The take_next_sample operation is semantically equivalent to the take operation, 
  432.    --  where the input data sequences has max_len=1, the sample_states=NOT_READ, 
  433.    --  the view_states=ANY_VIEW_STATE, and the instance_states=ANY_INSTANCE_STATE. 
  434.    --  The read_next_sample operation provides a simplified API to 'take' samples, 
  435.    --  avoiding the need for the application to manage sequences and specify states. 
  436.    --  If tere is no unread data in the DataReader, the operation will fail 
  437.    --  with exception NO_DATA and nothing is copied. 
  438.    --  </internal> 
  439.  
  440.    procedure Read_Instance 
  441.      (Self            : not null access constant Ref; 
  442.       Received_Data   : not null access Data_Sequences.Sequence; 
  443.       Info_Seq        : not null access DDS.SampleInfo_Seq.Sequence; 
  444.       Max_Samples     : in DDS.Long := DDS.LENGTH_UNLIMITED; 
  445.       A_Handle        : access constant DDS.InstanceHandle_T; 
  446.       Sample_States   : in DDS.SampleStateMask := DDS.ANY_SAMPLE_STATE; 
  447.       View_States     : in DDS.ViewStateMask := DDS.ANY_VIEW_STATE; 
  448.       Instance_States : in DDS.InstanceStateMask := DDS.ANY_INSTANCE_STATE); 
  449.    --  <dref>FooDataReader_read_instance</dref> 
  450.  
  451.    function Read_Instance 
  452.      (Self            : not null access Ref; 
  453.       Max_Samples     : in DDS.Long := DDS.LENGTH_UNLIMITED; 
  454.       A_Handle        : access constant DDS.InstanceHandle_T; 
  455.       Sample_States   : in DDS.SampleStateMask := DDS.ANY_SAMPLE_STATE; 
  456.       View_States     : in DDS.ViewStateMask := DDS.ANY_VIEW_STATE; 
  457.       Instance_States : in DDS.InstanceStateMask := DDS.ANY_INSTANCE_STATE) return Container'Class; 
  458.    --  <<experimental>> <<extension>> Returns a container which allows for easier iteration through 
  459.    --  samples. See procedure Read_Instance 
  460.  
  461.    --  <internal> 
  462.    --  Access a collection of data samples from the DataReader. 
  463.    --  This operation accesses a collection of data values from the DataReader. 
  464.    --  The behavior is identical to read, except that all samples returned belong 
  465.    --  to the single specified instance whose handle is a_handle. 
  466.    --  Upon successful completion, the data collection will contain samples all 
  467.    --  belonging to the same instance. The corresponding SampleInfo verifies 
  468.    --  SampleInfo::instance_handle == a_handle. 
  469.    --  The read_instance operation is semantically equivalent to the read operation, 
  470.    --  except in building the collection, the DataReader will check that the sample 
  471.    --  belongs to the specified instance and otherwise it will not place the sample 
  472.    --  in the returned collection. 
  473.    --  The behavior of the read_instance operation follows the same rules as the 
  474.    --  read operation regarding the pre-conditions and post-conditions for the received_data 
  475.    --  and sample_info. Similar to the read, the read_instance operation may 'loan' elements 
  476.    --  to the output collections, which must then be returned by means of return_loan. 
  477.    --  Similar to the read, this operation must be provided on the specialized class that 
  478.    --  is generated for the particular application data-type that is being taken. 
  479.    --  If the DataReader has no samples that meet the constraints, 
  480.    --  the function will fail with RETCODE_NO_DATA. 
  481.    --  This operation may fail with RETCODE_BAD_PARAMETER if the InstanceHandle_t 
  482.    --  a_handle does not correspond to an existing data-object known to the DataReader. 
  483.    --  </internal> 
  484.  
  485.  
  486.    procedure Take_Instance 
  487.      (Self            : not null access constant Ref; 
  488.       Received_Data   : not null access Data_Sequences.Sequence; 
  489.       Info_Seq        : not null access DDS.SampleInfo_Seq.Sequence; 
  490.       Max_Samples     : in DDS.Long := DDS.LENGTH_UNLIMITED; 
  491.       A_Handle        : access constant DDS.InstanceHandle_T; 
  492.       Sample_States   : in DDS.SampleStateMask := DDS.ANY_SAMPLE_STATE; 
  493.       View_States     : in DDS.ViewStateMask := DDS.ANY_VIEW_STATE; 
  494.       Instance_States : in DDS.InstanceStateMask := DDS.ANY_INSTANCE_STATE); 
  495.    --  <dref>FooDataReader_take_instance</dref> 
  496.  
  497.    function Take_Instance 
  498.      (Self            : not null access Ref; 
  499.       Max_Samples     : in DDS.Long := DDS.LENGTH_UNLIMITED; 
  500.       A_Handle        : access constant DDS.InstanceHandle_T; 
  501.       Sample_States   : in DDS.SampleStateMask := DDS.ANY_SAMPLE_STATE; 
  502.       View_States     : in DDS.ViewStateMask := DDS.ANY_VIEW_STATE; 
  503.       Instance_States : in DDS.InstanceStateMask := DDS.ANY_INSTANCE_STATE) return Container'Class; 
  504.    --  <<experimental>> <<extension>> Returns a container which allows for easier iteration through 
  505.    --  samples. See procedure Take_Instance 
  506.  
  507.    --  <internal> 
  508.    --  Access a collection of data samples from the DataReader. 
  509.    --  This operation accesses a collection of data values from the DataReader. 
  510.    --  The behavior is identical to take, except for that all samples returned belong 
  511.    --  to the single specified instance whose handle is a_handle. 
  512.    --  The semantics are the same for the take operation, except in building the collection, 
  513.    --  the DataReader will check that the sample belongs to the specified instance, 
  514.    --  and otherwise it will not place the sample in the returned collection. 
  515.    --  The behavior of the take_instance operation follows the same rules as the 
  516.    --  read operation regarding the pre-conditions and post-conditions for the 
  517.    --  received_data and sample_info. Similar to the read, the take_instance operation may 
  518.    --  'loan' elements to the output collections, which must then be returned by means of return_loan. 
  519.    --  Similar to the read, this operation must be provided on the specialized class 
  520.    --  that is generated for the particular application data-type that is being taken. 
  521.    --  If the DataReader has no samples that meet the constraints, the function fails with exception NO_DATA. 
  522.    --  This operation may fail with exception BAD_PARAMETER if the InstanceHandle_t 
  523.    --  a_handle does not correspond to an existing data-object known to the DataReader. 
  524.    --  </internal> 
  525.  
  526.    procedure Read_Next_Instance 
  527.      (Self            : not null access constant Ref; 
  528.       Received_Data   : not null access Data_Sequences.Sequence; 
  529.       Info_Seq        : not null access DDS.SampleInfo_Seq.Sequence; 
  530.       Max_Samples     : in DDS.Long := DDS.LENGTH_UNLIMITED; 
  531.       Previous_Handle : access constant DDS.InstanceHandle_T; 
  532.       Sample_States   : in DDS.SampleStateMask := DDS.ANY_SAMPLE_STATE; 
  533.       View_States     : in DDS.ViewStateMask := DDS.ANY_VIEW_STATE; 
  534.       Instance_States : in DDS.InstanceStateMask := DDS.ANY_INSTANCE_STATE); 
  535.    --  <dref>FooDataReader_read_next_instance</dref> 
  536.  
  537.    function Read_Next_Instance 
  538.      (Self            : not null access Ref; 
  539.       Max_Samples     : in DDS.Long := DDS.LENGTH_UNLIMITED; 
  540.       Previous_Handle : access constant DDS.InstanceHandle_T; 
  541.       Sample_States   : in DDS.SampleStateMask := DDS.ANY_SAMPLE_STATE; 
  542.       View_States     : in DDS.ViewStateMask := DDS.ANY_VIEW_STATE; 
  543.       Instance_States : in DDS.InstanceStateMask := DDS.ANY_INSTANCE_STATE) return Container'Class; 
  544.    --  <<experimental>> <<extension>> Returns a container which allows for easier iteration through 
  545.    --  samples. See procedure Read_Next_Instance 
  546.  
  547.    --  <internal> 
  548.    --  Access a collection of data samples from the DataReader. 
  549.    --  This operation accesses a collection of data values from the DataReader 
  550.    --  where all the samples belong to a single instance. The behavior is similar to 
  551.    --  read_instance, except that the actual instance is not directly specified. 
  552.    --  Rather, the samples will all belong to the 'next' instance with instance_handle 
  553.    --  'greater' than the specified 'previous_handle' that has available samples. 
  554.    --  This operation implies the existence of a total order 'greater-than' relationship 
  555.    --  between the instance handles. The specifics of this relationship are not all 
  556.    --  important and are implementation specific. The important thing is that, 
  557.    --  according to the middleware, all instances are ordered relative to each other. 
  558.    --  This ordering is between the instance handles; It should not depend on the state 
  559.    --  of the instance (e.g. whether it has data or not) and must be defined even for 
  560.    --  instance handles that do not correspond to instances currently managed by the DataReader. 
  561.    --  For the purposes of the ordering, it should be 'as if' each instance handle was 
  562.    --  represented as unique integer. 
  563.    --  The behavior of read_next_instance is 'as if' the DataReader invoked read_instance, 
  564.    --  passing the smallest instance_handle among all the ones that: 
  565.    --   (a) are greater than previous_handle, and 
  566.    --   (b) have available samples (i.e. samples that meet the constraints imposed by the specified states). 
  567.    --  The special value HANDLE_NIL is guaranteed to be 'less than' any valid instance_handle. 
  568.    --  So the use of the parameter value previous_handle == HANDLE_NIL will 
  569.    --   return the samples for the instance which has the smallest instance_handle 
  570.    --  among all the instances that contain available samples. 
  571.    --  The operation read_next_instance is intended to be used in an 
  572.    --  application-driven iteration, where the application starts by passing 
  573.    --  previous_handle == HANDLE_NIL, examines the samples returned, and then uses 
  574.    --  the instance_handle returned in the SampleInfo as the value of the previous_handle 
  575.    --  argument to the next call to read_next_instance. The iteration continues 
  576.    --  until read_next_instance fails with the value exception NO_DATA. 
  577.    --  Note that it is possible to call the read_next_instance operation with a 
  578.    --  previous_handle that does not correspond to an instance currently managed by 
  579.    --  the DataReader. This is because as stated earlier the 'greater-than' relationship 
  580.    --  is defined even for handles not managed by the DataReader. 
  581.    --  One practical situation where this may occur is when an application is iterating 
  582.    --  though all the instances, takes all the samples of a NOT_ALIVE_NO_WRITERS_INSTANCE_STATE 
  583.    --  instance, returns the loan (at which point the instance information may be removed, 
  584.    --  and thus the handle becomes invalid), and tries to read the next instance. 
  585.    --  The behavior of the read_next_instance operation follows the same rules as 
  586.    --  the read operation regarding the pre-conditions and post-conditions for the 
  587.    --  received_data and sample_info. Similar to the read, the read_instance operation may 
  588.    --  'loan' elements to the output collections, which must then be returned by means of return_loan. 
  589.    --  Similar to the read, this operation must be provided on the specialized class 
  590.    --  that is generated for the particular application data-type that is being taken. 
  591.    --  If the DataReader has no samples that meet the constraints, the function 
  592.    --  will fail with exception NO_DATA. 
  593.    --  </internal> 
  594.  
  595.    procedure Take_Next_Instance 
  596.      (Self            : not null access constant Ref; 
  597.       Received_Data   : not null access Data_Sequences.Sequence; 
  598.       Info_Seq        : not null access DDS.SampleInfo_Seq.Sequence; 
  599.       Max_Samples     : in DDS.Long := DDS.LENGTH_UNLIMITED; 
  600.       Previous_Handle : access constant DDS.InstanceHandle_T; 
  601.       Sample_States   : in DDS.SampleStateMask := DDS.ANY_SAMPLE_STATE; 
  602.       View_States     : in DDS.ViewStateMask := DDS.ANY_VIEW_STATE; 
  603.       Instance_States : in DDS.InstanceStateMask := DDS.ANY_INSTANCE_STATE); 
  604.    --  <dref>FooDataReader_take_next_instance</dref> 
  605.  
  606.    function Take_Next_Instance 
  607.      (Self            : not null access Ref; 
  608.       Max_Samples     : in DDS.Long := DDS.LENGTH_UNLIMITED; 
  609.       Previous_Handle : access constant DDS.InstanceHandle_T; 
  610.       Sample_States   : in DDS.SampleStateMask := DDS.ANY_SAMPLE_STATE; 
  611.       View_States     : in DDS.ViewStateMask := DDS.ANY_VIEW_STATE; 
  612.       Instance_States : in DDS.InstanceStateMask := DDS.ANY_INSTANCE_STATE) return Container'Class; 
  613.    --  <<experimental>> <<extension>> Returns a container which allows for easier iteration through 
  614.    --  samples. See procedure Take_Next_Instance 
  615.  
  616.    --  <internal> 
  617.    --  Access a collection of data samples from the DataReader. 
  618.    --  This operation accesses a collection of data values from the DataReader and 
  619.    --  'removes' them from the DataReader. 
  620.    --  This operation has the same behavior as read_next_Ret.Received_Datainstance, except that the 
  621.    --  samples are 'taken' from the DataReader such that they are no longer accessible 
  622.    --  via subsequent 'read' or 'take' operations. 
  623.    --  Similar to the operation read_next_instance, it is possible to call take_next_instance 
  624.    --  with a previous_handle that does not correspond to an instance currently managed by the DataReader. 
  625.    --  The behavior of the take_next_instance operation follows the same rules as the 
  626.    --  read operation regarding the pre-conditions and post-conditions for the received_data 
  627.    --  and sample_info. Similar to the read, the take_next_instance operation may 'loan' 
  628.    --  elements to the output collections, which must then be returned by means of return_loan. 
  629.    --  Similar to the read, this operation must be provided on the specialized class that 
  630.    --  is generated for the particular application data-type that is being taken. 
  631.    --  If the DataReader has no samples that meet the constraints, 
  632.    --  the function will fail with exception NO_DATA. 
  633.    --  </internal> 
  634.  
  635.    procedure Read_Next_Instance_W_Condition 
  636.      (Self            : not null access constant Ref; 
  637.       Received_Data   : not null access Data_Sequences.Sequence; 
  638.       Info_Seq        : not null access DDS.SampleInfo_Seq.Sequence; 
  639.       Max_Samples     : in DDS.Long := DDS.LENGTH_UNLIMITED; 
  640.       Previous_Handle : access constant DDS.InstanceHandle_T; 
  641.       Condition       : DDS.ReadCondition.Ref_Access); 
  642.    --  <dref>FooDataReader_read_next_instance_w_condition</dref> 
  643.  
  644.    function Read_Next_Instance_W_Condition 
  645.      (Self            : not null access Ref; 
  646.       Max_Samples     : in DDS.Long := DDS.LENGTH_UNLIMITED; 
  647.       Previous_Handle : access constant DDS.InstanceHandle_T; 
  648.       Condition       : DDS.ReadCondition.Ref_Access) return Container'Class; 
  649.    --  <<experimental>> <<extension>> Returns a container which allows for easier iteration through 
  650.    --  samples. See procedure Read_Next_Instance_W_Condition 
  651.  
  652.    --  <internal> 
  653.    --  Accesses via read_next_instance the samples that match the criteria 
  654.    --  specified in the ReadCondition. 
  655.    --  This operation access a collection of data values from the DataReader. 
  656.    --  The behavior is identical to read_next_instance, except that all samples returned satisfy 
  657.    --  the specified condition. In other words, on success, all returned samples 
  658.    --  belong to the same instance, and the instance is the instance with 'smallest' 
  659.    --  instance_handle among the ones that verify: 
  660.    --   (a) instance_handle >= previous_handle, and 
  661.    --   (b) have samples for which the specified ReadCondition evaluates to TRUE. 
  662.    --  Similar to the operation read_next_instance, it is possible to call 
  663.    --  read_next_instance_w_condition with a previous_handle that does not correspond 
  664.    --  to an instance currently managed by the DataReader. 
  665.    --  The behavior of the read_next_instance_w_condition operation follows the same 
  666.    --  rules as the read operation regarding the pre-conditions and post-conditions for 
  667.    --  the received_data and sample_info. Similar to the read, the 
  668.    --  read_next_instance_w_condition operation may 'loan' elements to the output collections, 
  669.    --  which must then be returned by means of return_loan. 
  670.    --  Similar to the read, this operation must be provided on the specialized class that 
  671.    --  is generated for the particular application data-type that is being taken. 
  672.    --  If the DataReader has no samples that meet the constraints, 
  673.    --  the function will fail with exception NO_DATA. 
  674.    --  </internal> 
  675.  
  676.    procedure Read_Instance_W_Condition 
  677.      (Self            : not null access constant Ref; 
  678.       Received_Data   : not null access Data_Sequences.Sequence; 
  679.       Info_Seq        : not null access DDS.SampleInfo_Seq.Sequence; 
  680.       Max_Samples     : in DDS.Long := DDS.LENGTH_UNLIMITED; 
  681.       A_Handle        : access constant DDS.InstanceHandle_T; 
  682.       Condition       : DDS.ReadCondition.Ref_Access); 
  683.    --  <dref>FooDataReader_read_instance_w_condition</dref> 
  684.  
  685.    procedure Take_Instance_W_Condition 
  686.      (Self            : not null access constant Ref; 
  687.       Received_Data   : not null access Data_Sequences.Sequence; 
  688.       Info_Seq        : not null access DDS.SampleInfo_Seq.Sequence; 
  689.       Max_Samples     : in DDS.Long := DDS.LENGTH_UNLIMITED; 
  690.       A_Handle        : access constant DDS.InstanceHandle_T; 
  691.       Condition       : DDS.ReadCondition.Ref_Access); 
  692.    --  <dref>FooDataReader_take_instance_w_condition</dref> 
  693.  
  694.    procedure Take_Next_Instance_W_Condition 
  695.      (Self            : not null access constant Ref; 
  696.       Received_Data   : not null access Data_Sequences.Sequence; 
  697.       Info_Seq        : not null access DDS.SampleInfo_Seq.Sequence; 
  698.       Max_Samples     : in DDS.Long := DDS.LENGTH_UNLIMITED; 
  699.       Previous_Handle : access constant DDS.InstanceHandle_T; 
  700.       Condition       : DDS.ReadCondition.Ref_Access); 
  701.    --  <dref>FooDataReader_take_next_instance_w_condition</dref> 
  702.  
  703.    procedure Take_Next_Instance_W_Condition 
  704.      (Self            : not null access constant Ref; 
  705.       Received_Data   : in out Data_Sequences.Sequence; 
  706.       Info_Seq        : in out DDS.SampleInfo_Seq.Sequence; 
  707.       Max_Samples     : in DDS.Long := DDS.LENGTH_UNLIMITED; 
  708.       Previous_Handle : access constant DDS.InstanceHandle_T; 
  709.       Condition       : DDS.ReadCondition.Ref_Access); 
  710.    --  <dref>FooDataReader_take_next_instance_w_condition</dref> 
  711.  
  712.    function Take_Next_Instance_W_Condition 
  713.      (Self            : not null access Ref; 
  714.       Max_Samples     : in DDS.Long := DDS.LENGTH_UNLIMITED; 
  715.       Previous_Handle : access constant DDS.InstanceHandle_T; 
  716.       Condition       : DDS.ReadCondition.Ref_Access) return Container'Class; 
  717.    --  <<experimental>> <<extension>> Returns a container which allows for easier iteration through 
  718.    --  samples. See procedure Take_Next_Instance_W_Condition 
  719.  
  720.    --  <internal> 
  721.    --  Accesses via take_next_instance the samples that match the criteria specified 
  722.    --  in the ReadCondition. 
  723.    --  This operation access a collection of data values from the DataReader and 
  724.    --  'removes' them from the DataReader. 
  725.    --  The operation has the same behavior as read_next_instance_w_condition, except 
  726.    --  that the samples are 'taken' from the DataReader such that they are no longer 
  727.    --  accessible via subsequent 'read' or 'take' operations. 
  728.    --  Similar to the operation read_next_instance, it is possible to call 
  729.    --  take_next_instance_w_condition with a previous_handle that does not correspond 
  730.    --  to an instance currently managed by the DataReader. 
  731.    --  The behavior of the take_next_instance_w_condition operation follows the same 
  732.    --  rules as the read operation regarding the pre-conditions and post-conditions 
  733.    --  for the received_data and sample_info. Similar to the read, 
  734.    --  the take_next_instance_w_condition operation may 'loan' elements to the output 
  735.    --  collections, which must then be returned by means of return_loan. 
  736.    --  Similar to the read, this operation must be provided on the specialized class 
  737.    --  that is generated for the particular application data-type that is being taken. 
  738.    --  If the DataReader has no samples that meet the constraints, 
  739.    --  the function will fail with exception NO_DATA. 
  740.    --  </internal> 
  741.  
  742.    procedure Return_Loan 
  743.      (Self          : not null access constant Ref; 
  744.       Received_Data : not null access Data_Sequences.Sequence; 
  745.       Info_Seq      : not null access DDS.SampleInfo_Seq.Sequence); 
  746.    --  <dref>FooDataReader_return_loan</dref> 
  747.  
  748.    procedure Return_Loan 
  749.      (Self          : not null access constant Ref; 
  750.       Received_Data : in out  Data_Sequences.Sequence; 
  751.       Info_Seq      : in out  DDS.SampleInfo_Seq.Sequence); 
  752.    --  <dref>FooDataReader_return_loan</dref> 
  753.  
  754.    --  <internal> 
  755.    --  Indicates to the DataReader that the application is done accessing the collection 
  756.    --  of received_data and info_seq obtained by some earlier invocation of 
  757.    --  read or take on the DataReader. 
  758.    --  This operation indicates to the DataReader that the application is done accessing 
  759.    --  the collection of received_data and info_seq obtained by some earlier 
  760.    --  invocation of read or take on the DataReader. 
  761.    --  The received_data and info_seq must belong to a single related "pair"; that is, 
  762.    --  they should correspond to a pair returned from a single call to read or take. 
  763.    --  The received_data and info_seq must also have been obtained from the same DataReader 
  764.    --  to which they are returned. If either of these conditions is not met, the operation 
  765.    --  will fail with exception PRECONDITION_NOT_MET. 
  766.    --  The operation return_loan allows implementations of the read and take operations 
  767.    --  to "loan" buffers from the DataReader to the application and in this manner provide 
  768.    --  "zerocopy" access to the data. During the loan, the DataReader will guarantee 
  769.    --  that the data and sample-information are not modified. 
  770.    --  It is not necessary for an application to return the loans immediately after 
  771.    --  the read or take calls. However, as these buffers correspond to internal resources 
  772.    --  inside the DataReader, the application should not retain them indefinitely. 
  773.    --  The use of return_loan is only necessary if the read or take calls "loaned" 
  774.    --  buffers to the application. This only occurs if the received_data and info_Seq 
  775.    --  collections had max_len=0 at the time read or take was called. 
  776.    --  The application may also examine the "owns" property of the collection to determine 
  777.    --  where there is an outstanding loan. However, calling return_loan on a collection 
  778.    --  that does not have a loan is safe and has no side effects. 
  779.    --  If the collections had a loan, upon completion of return_loan, 
  780.    --  the collections will have max_len=0. 
  781.    --  Similar to read, this operation must be provided on the specialized class that 
  782.    --  is generated for the particular application data-type that is being taken. 
  783.    --  </internal> 
  784.  
  785.    procedure Get_Key_Value 
  786.      (Self       : not null access constant Ref; 
  787.       Key_Holder : not null Data_Type_Access; 
  788.       Handle     : access constant DDS.InstanceHandle_T); 
  789.    --  <dref>FooDataReader_get_key_value</dref> 
  790.  
  791.    procedure Get_Key_Value 
  792.      (Self       : not null access constant Ref; 
  793.       Key_Holder : out Data_Type; 
  794.       Handle     : access constant DDS.InstanceHandle_T); 
  795.    --  <dref>FooDataReader_get_key_value</dref> 
  796.  
  797.    procedure Get_Key_Value 
  798.      (Self       : not null access constant Ref; 
  799.       Key_Holder : out Data_Type; 
  800.       Handle     : in DDS.InstanceHandle_T); 
  801.    --  <dref>FooDataReader_get_key_value</dref> 
  802.  
  803.    --  <internal> 
  804.    --  Retrieve the instance key that corresponds to an instance handle. 
  805.    --  Useful for keyed data types. 
  806.    --  The operation will only fill the fields that form the key inside the key_holder instance. 
  807.    --  For keyed data types, this operation may fail with exception BAD_PARAMETER 
  808.    --  if the handle does not correspond to an existing data-object known to the DDS_DataReader. 
  809.    --  </internal> 
  810.  
  811.    function Lookup_Instance 
  812.      (Self       : not null access constant Ref; 
  813.       Key_Holder : not null Data_Type_Access) return DDS.InstanceHandle_T; 
  814.    --  <dref>FooDataReader_lookup_instance</dref> 
  815.  
  816.    function Lookup_Instance 
  817.      (Self       : not null access constant Ref; 
  818.       Key_Holder : Data_Type) return DDS.InstanceHandle_T; 
  819.    --  <dref>FooDataReader_lookup_instance</dref> 
  820.  
  821.    procedure Lookup_Instance 
  822.      (Self       : not null access constant Ref; 
  823.       Key_Holder : Data_Type; 
  824.       Instance   : out DDS.InstanceHandle_T); 
  825.    --  <dref>FooDataReader_lookup_instance</dref> 
  826.  
  827.    --  <internal> 
  828.    --  Retrieve the instance handle that corresponds to an instance key_holder. 
  829.    --  Useful for keyed data types. 
  830.    --  This operation takes as a parameter an instance and returns a handle that 
  831.    --  can be used in subsequent operations that accept an instance handle as an argument. 
  832.    --  The instance parameter is only used for the purpose of examining the fields that 
  833.    --  define the key. This operation does not register the instance in question. 
  834.    --  If the instance has not been previously registered, or if for any other reason 
  835.    --  the Service is unable to provide an instance handle, 
  836.    --  the Service will return the special value HANDLE_NIL 
  837.    --  </internal> 
  838.  
  839.  
  840.    function Is_Data_Consistent 
  841.      (Self          : not null access constant Ref; 
  842.       Sample        : in not null Data_Type_Access; 
  843.       Sample_Info   : in not null DDS.SampleInfo_Access) return Standard.Boolean; 
  844.    --  <dref>FooDataReader_is_data_consistent</dref> 
  845.    --  <internal> 
  846.    --  When using SHMEM_REF transfer mode, the DataWriter will pass a reference 
  847.    --  to the sample on shared memory to the DataReader. The DataReader will 
  848.    --  use this reference to pass sample data up to the application in the form 
  849.    --  of a loaned sample that's actually stored in the DataWriter's queue in 
  850.    --  shared memory. 
  851.    --  In many situations, sample memory may be reused by the DataWriter to 
  852.    --  send another sample before or while the subscribing application acceses 
  853.    --  sample data, creating a data inconsistency problem. 
  854.    --  Is_Data_Consistent can be used to detect these inconsistencies. It 
  855.    --  should be used *after* the sample has been processed. If it returns 
  856.    --  false, processed data should be discarded. 
  857.    --  If Is_Data_Consistent is only called before processing data, it could 
  858.    --  return true at that point but the sample could still be modified while 
  859.    --  being processed, leading to a race condition. 
  860.    --  </internal> 
  861.  
  862.  
  863.    function As_DataReader (Self : Ref_Access) return Standard.DDS.DataReader.Ref_Access is 
  864.      (Standard.DDS.DataReader.Ref_Access (Self)); 
  865.  
  866.    function Narrow 
  867.      (Self        : access DDS.DataReader.Ref'Class) return not null access Ref is 
  868.      (Ref (Self.all)'Access); 
  869.  
  870.    function CreateTypedI return DDS.DataReader.Ref_Access; 
  871.  
  872.    procedure DestroyTypedI 
  873.      (Reader : in out DDS.DataReader.Ref_Access); 
  874.  
  875. private 
  876.  
  877.  
  878.    procedure  read_or_takeI 
  879.      (self            : not null access constant Ref; 
  880.       Received_Data   : not null access Data_Sequences.Sequence; 
  881.       Info_Seq        : not null access DDS.SampleInfo_Seq.Sequence; 
  882.       max_samples     : DDS.Long; 
  883.       sample_states   : DDS.SampleStateMask; 
  884.       view_states     : DDS.ViewStateMask; 
  885.       instance_states : DDS.InstanceStateMask; 
  886.       take            : DDS.Boolean); 
  887.    function read_or_takeI 
  888.      (self            : not null access constant Ref; 
  889.       Received_Data   : not null access Data_Sequences.Sequence; 
  890.       Info_Seq        : not null access DDS.SampleInfo_Seq.Sequence; 
  891.       max_samples     : DDS.Long; 
  892.       sample_states   : DDS.SampleStateMask; 
  893.       view_states     : DDS.ViewStateMask; 
  894.       instance_states : DDS.InstanceStateMask; 
  895.       take            : DDS.Boolean) return DDS_ReturnCode_t; 
  896.  
  897.    procedure  read_or_take_w_conditionI 
  898.      (Self            : not null access constant Ref; 
  899.       Received_Data   : not null access Data_Sequences.Sequence; 
  900.       Info_Seq        : not null access DDS.SampleInfo_Seq.Sequence; 
  901.       Max_samples     : DDS.Long; 
  902.       Condition       : not null access constant DDS.ReadCondition.Ref'Class; 
  903.       Take            : DDS.Boolean); 
  904.    function  read_or_take_w_conditionI 
  905.      (Self            : not null access constant Ref; 
  906.       Received_Data   : not null access Data_Sequences.Sequence; 
  907.       Info_Seq        : not null access DDS.SampleInfo_Seq.Sequence; 
  908.       Max_samples     : DDS.Long; 
  909.       Condition       : not null access constant DDS.ReadCondition.Ref'Class; 
  910.       Take            : DDS.Boolean) return DDS_ReturnCode_t; 
  911.  
  912.    procedure  read_or_take_next_sampleI 
  913.      (self            : not null access constant Ref; 
  914.       Received_Data   : not null Data_Type_Access; 
  915.       sample_info     : not null access DDS.SampleInfo; 
  916.       take            : DDS.Boolean); 
  917.  
  918.    procedure  read_or_take_instanceI 
  919.      (self            : not null access constant Ref; 
  920.       Received_Data   : not null access Data_Sequences.Sequence; 
  921.       Info_Seq        : not null access DDS.SampleInfo_Seq.Sequence; 
  922.       max_samples     : DDS.Long; 
  923.       handle          : not null access constant DDS.InstanceHandle_T; 
  924.       sample_states   : DDS.SampleStateMask; 
  925.       view_states     : DDS.ViewStateMask; 
  926.       instance_states : DDS.InstanceStateMask; 
  927.       take            : DDS.Boolean); 
  928.  
  929.    function read_or_take_instanceI 
  930.      (self            : not null access constant Ref; 
  931.       Received_Data   : not null access Data_Sequences.Sequence; 
  932.       Info_Seq        : not null access DDS.SampleInfo_Seq.Sequence; 
  933.       max_samples     : DDS.Long; 
  934.       handle          : not null access constant DDS.InstanceHandle_T; 
  935.       sample_states   : DDS.SampleStateMask; 
  936.       view_states     : DDS.ViewStateMask; 
  937.       instance_states : DDS.InstanceStateMask; 
  938.       take            : DDS.Boolean) return DDS_ReturnCode_t; 
  939.  
  940.    procedure  read_or_take_next_instanceI 
  941.      (self            : not null access constant Ref; 
  942.       Received_Data   : not null access Data_Sequences.Sequence; 
  943.       Info_Seq        : not null access DDS.SampleInfo_Seq.Sequence; 
  944.       max_samples     : DDS.Long; 
  945.       previous_handle : not null access constant DDS.InstanceHandle_T; 
  946.       sample_states   : DDS.SampleStateMask; 
  947.       view_states     : DDS.ViewStateMask; 
  948.       instance_states : DDS.InstanceStateMask; 
  949.       Take            : DDS.Boolean); 
  950.    function  read_or_take_next_instanceI 
  951.      (self            : not null access constant Ref; 
  952.       Received_Data   : not null access Data_Sequences.Sequence; 
  953.       Info_Seq        : not null access DDS.SampleInfo_Seq.Sequence; 
  954.       max_samples     : DDS.Long; 
  955.       previous_handle : not null access constant DDS.InstanceHandle_T; 
  956.       sample_states   : DDS.SampleStateMask; 
  957.       view_states     : DDS.ViewStateMask; 
  958.       instance_states : DDS.InstanceStateMask; 
  959.       Take            : DDS.Boolean) return DDS_ReturnCode_t; 
  960.  
  961.    procedure Read_Or_Take_Instance_W_ConditionI 
  962.      (Self            : not null access constant Ref; 
  963.       Received_Data   : not null access Data_Sequences.Sequence; 
  964.       Info_Seq        : not null access DDS.SampleInfo_Seq.Sequence; 
  965.       Max_Samples     : DDS.Long; 
  966.       Handle          : not null access constant DDS.InstanceHandle_T; 
  967.       Condition       : not null access constant DDS.ReadCondition.Ref'Class; 
  968.       Take            : DDS.Boolean); 
  969.    function  Read_Or_Take_Instance_W_ConditionI 
  970.      (Self            : not null access constant Ref; 
  971.       Received_Data   : not null access Data_Sequences.Sequence; 
  972.       Info_Seq        : not null access DDS.SampleInfo_Seq.Sequence; 
  973.       Max_Samples     : DDS.Long; 
  974.       Handle          : not null access constant DDS.InstanceHandle_T; 
  975.       Condition       : not null access constant DDS.ReadCondition.Ref'Class; 
  976.       Take            : DDS.Boolean) return DDS_ReturnCode_t; 
  977.  
  978.    procedure  read_or_take_next_instance_w_conditionI 
  979.      (self            : not null access constant Ref; 
  980.       Received_Data   : not null access Data_Sequences.Sequence; 
  981.       Info_Seq        : not null access DDS.SampleInfo_Seq.Sequence; 
  982.       max_samples     : DDS.Long; 
  983.       previous_handle : not null access constant DDS.InstanceHandle_T; 
  984.       condition       : not null access constant DDS.ReadCondition.Ref'Class; 
  985.       take            : DDS.Boolean); 
  986.    function read_or_take_next_instance_w_conditionI 
  987.      (self            : not null access constant Ref; 
  988.       Received_Data   : not null access Data_Sequences.Sequence; 
  989.       Info_Seq        : not null access DDS.SampleInfo_Seq.Sequence; 
  990.       max_samples     : DDS.Long; 
  991.       previous_handle : not null access constant DDS.InstanceHandle_T; 
  992.       condition       : not null access constant DDS.ReadCondition.Ref'Class; 
  993.       take            : DDS.Boolean) return DDS_ReturnCode_t; 
  994.  
  995.  
  996.    ---------------------------------------------------- 
  997.    --  Below here to be moved to dds-datareader_impl -- 
  998.    ---------------------------------------------------- 
  999.  
  1000.    procedure Get_Key_Value_UntypedI (Self          : not null access constant Ref; 
  1001.                                      Key_Holder    : System.Address; 
  1002.                                      Handle        : access constant DDS.InstanceHandle_T); 
  1003.  
  1004.  
  1005.    function Lookup_Instance_UntypedI (Self          : not null access constant Ref; 
  1006.                                        Key_Holder    : System.Address) return DDS.InstanceHandle_T; 
  1007.  
  1008.  
  1009. --  DDS_InstanceHandle_t TDataReader_lookup_instance(TDataReader* self, 
  1010. --                                                   const TData* key_holder) { 
  1011. --      return DDS_DataReader_lookup_instance_untypedI( 
  1012. --          (DDS_DataReader *)self, key_holder); 
  1013. --  } 
  1014. -- 
  1015. --  DDS_ReturnCode_t TDataReader_add_sample_to_remote_writer_queue(TDataReader* self, 
  1016. --                                                              const TData* local_data, 
  1017. --                                                              const struct DDS_GUID_t* queue_writer_guid) { 
  1018. --      return DDS_DataReader_add_sample_to_remote_writer_queue_untypedI( 
  1019. --          (DDS_DataReader *)self, local_data, queue_writer_guid); 
  1020. --  } 
  1021.  
  1022.    function Return_Loan_UntypedI 
  1023.      (Self          : not null access constant Ref; 
  1024.       Received_Data : System.Address; 
  1025.       Data_Count    : Natural; 
  1026.       Info_Seq      : not null Standard.DDS.SampleInfo_Seq.Sequence_Access) return DDS_ReturnCode_t; 
  1027.  
  1028.    procedure Return_Loan_UntypedI 
  1029.      (Self          : not null access constant Ref; 
  1030.       Received_Data : System.Address; 
  1031.       Data_Count    : Natural; 
  1032.       Info_Seq      : not null Standard.DDS.SampleInfo_Seq.Sequence_Access); 
  1033.  
  1034.  
  1035.    function Read_Or_Take_W_Condition_UntypedI 
  1036.      (Self                                : not null access constant Ref; 
  1037.       Is_Loan                             : access DDS.Boolean; 
  1038.       Received_Data                       : System.Address; 
  1039.       Data_Count                          : access Natural; 
  1040.       Info_Seq                            : SampleInfo_Seq.Sequence_Access; 
  1041.       Data_Seq_Len                        : Long_Integer; 
  1042.       Data_Seq_Max_Len                    : Long_Integer; 
  1043.       Data_Seq_Has_Ownership              : Long_Integer; 
  1044.       Data_Seq_Contiguous_Buffer_For_Copy : System.Address; 
  1045.       Data_Size                           : Integer; 
  1046.       Max_Samples                         : Long_Integer; 
  1047.       Condition                           : not null access DDS.ReadCondition.Ref'Class; 
  1048.       Take                                : DDS.Boolean) return DDS_ReturnCode_t; 
  1049.  
  1050.    function Read_Or_Take_Instance_UntypedI 
  1051.      (Self                                : not null access constant Ref; 
  1052.       Is_Loan                             : access DDS.Boolean; 
  1053.       Received_Data                       : System.Address; 
  1054.       Data_Count                          : access Natural; 
  1055.       Info_Seq                            : SampleInfo_Seq.Sequence_Access; 
  1056.       Data_Seq_Len                        : Long_Integer; 
  1057.       Data_Seq_Max_Len                    : Long_Integer; 
  1058.       Data_Seq_Has_Ownership              : Long_Integer; 
  1059.       Data_Seq_Contiguous_Buffer_For_Copy : System.Address; 
  1060.       Data_Size                           : Integer; 
  1061.       Max_Samples                         : Long_Integer; 
  1062.       Handle                              : DDS.InstanceHandle_T_Access; 
  1063.       Sample_States                       : DDS.SampleStateMask; 
  1064.       View_States                         : DDS.ViewStateMask; 
  1065.       Instance_States                     : DDS.InstanceStateMask; 
  1066.       Take                                : DDS.Boolean) return DDS_ReturnCode_t; 
  1067.  
  1068.    function Read_Or_Take_Instance_W_Condition_UntypedI 
  1069.      (Self                                : not null access constant Ref; 
  1070.       Is_Loan                             : access DDS.Boolean; 
  1071.       Received_Data                       : System.Address; 
  1072.       Data_Count                          : access Natural; 
  1073.       Info_Seq                            : SampleInfo_Seq.Sequence_Access; 
  1074.       Data_Seq_Len                        : Long_Integer; 
  1075.       Data_Seq_Max_Len                    : Long_Integer; 
  1076.       Data_Seq_Has_Ownership              : Long_Integer; 
  1077.       Data_Seq_Contiguous_Buffer_For_Copy : System.Address; 
  1078.       Data_Size                           : Integer; 
  1079.       Max_Samples                         : Long_Integer; 
  1080.       Handle                              : DDS.InstanceHandle_T_Access; 
  1081.       Condition                           : not null access DDS.ReadCondition.Ref'Class; 
  1082.       Take                                : DDS.Boolean) return DDS_ReturnCode_t; 
  1083.  
  1084.    function Read_Or_Take_Next_Instance_UntypedI 
  1085.      (Self                                : not null access constant Ref; 
  1086.       Is_Loan                             : access DDS.Boolean; 
  1087.       Received_Data                       : System.Address; 
  1088.       Data_Count                          : access Natural; 
  1089.       Info_Seq                            : SampleInfo_Seq.Sequence_Access; 
  1090.       Data_Seq_Len                        : Long_Integer; 
  1091.       Data_Seq_Max_Len                    : Long_Integer; 
  1092.       Data_Seq_Has_Ownership              : Long_Integer; 
  1093.       Data_Seq_Contiguous_Buffer_For_Copy : System.Address; 
  1094.       Data_Size                           : Integer; 
  1095.       Max_Samples                         : Long_Integer; 
  1096.       Previous_Handle                     : DDS.InstanceHandle_T_Access; 
  1097.       Sample_States                       : DDS.SampleStateMask; 
  1098.       View_States                         : DDS.ViewStateMask; 
  1099.       Instance_States                     : DDS.InstanceStateMask; 
  1100.       Take                                : DDS.Boolean) return DDS_ReturnCode_t; 
  1101.  
  1102.    function Read_Or_Take_Next_Instance_W_Condition_UntypedI 
  1103.      (Self                                : not null access constant Ref; 
  1104.       Is_Loan                             : access DDS.Boolean; 
  1105.       Received_Data                       : System.Address; 
  1106.       Data_Count                          : access Natural; 
  1107.       Info_Seq                            : SampleInfo_Seq.Sequence_Access; 
  1108.       Data_Seq_Len                        : Long_Integer; 
  1109.       Data_Seq_Max_Len                    : Long_Integer; 
  1110.       Data_Seq_Has_Ownership              : Long_Integer; 
  1111.       Data_Seq_Contiguous_Buffer_For_Copy : System.Address; 
  1112.       Data_Size                           : Integer; 
  1113.       Max_Samples                         : Long_Integer; 
  1114.       Previous_Handle                     : DDS.InstanceHandle_T_Access; 
  1115.       Condition                           : not null access DDS.ReadCondition.Ref'Class; 
  1116.       Take                                : DDS.Boolean) return DDS_ReturnCode_t; 
  1117.  
  1118.    function Read_Or_Take_Next_Sample_UntypedI 
  1119.      (Self                                : not null access constant Ref; 
  1120.       Received_Data                       : System.Address; 
  1121.       Sample_Info                         : DDS.SampleInfo_Access; 
  1122.       Take                                : DDS.Boolean) return DDS_ReturnCode_t; 
  1123.  
  1124.  
  1125. --     type DDS_InstanceHandle_T_Access is access all DDS_InstanceHandle_t; 
  1126. --     function Convert_Handle is new Ada.Unchecked_Conversion (DDS.InstanceHandle_T_Access, DDS_InstanceHandle_T_Access); 
  1127. -- 
  1128. --     type DDS_SampleInfoSeq_Access is access all DDS_SampleInfoSeq; 
  1129. --     function Convert_SampleInfoSeq is new Ada.Unchecked_Conversion (SampleInfo_Seq.Sequence_Access, DDS_SampleInfoSeq_Access); 
  1130. -- 
  1131. --     type DDS_SampleInfo_Access is access all DDS_SampleInfo; 
  1132. --     function Convert_SampleInfo is new Ada.Unchecked_Conversion (DDS.SampleInfo_Access, DDS_SampleInfo_Access); 
  1133.  
  1134.  
  1135.    type Container is limited new Ada.Finalization.Limited_Controlled with record 
  1136.       Received_Data   : aliased Data_Sequences.Sequence; 
  1137.       Info_Seq        : aliased DDS.SampleInfo_Seq.Sequence; 
  1138.       Reader          : Ref_Access; 
  1139.       Retcode         : DDS_ReturnCode_t := DDS_RETCODE_NO_DATA; 
  1140.    end record; 
  1141.  
  1142.    procedure Finalize (Self : in out Container); 
  1143.  
  1144. end DDS.Typed_DataReader_Generic;