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