LCOV - code coverage report
Current view: top level - src/io - ReadHDF5VarLen.hpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 4 13 30.8 %
Date: 2020-12-16 07:07:30 Functions: 2 3 66.7 %
Branches: 1 16 6.2 %

           Branch data     Line data    Source code
       1                 :            : /** \file   ReadHDF5VarLen.hpp
       2                 :            :  *  \author Jason Kraftcheck
       3                 :            :  *  \date   2010-09-04
       4                 :            :  */
       5                 :            : 
       6                 :            : #ifndef moab_READ_HDF5_VAR_LEN_HPP
       7                 :            : #define moab_READ_HDF5_VAR_LEN_HPP
       8                 :            : 
       9                 :            : #include "moab/MOABConfig.h"
      10                 :            : #ifdef MOAB_HAVE_MPI
      11                 :            : #include "moab_mpi.h"
      12                 :            : #endif
      13                 :            : #include "DebugOutput.hpp"
      14                 :            : #include "moab/Range.hpp"
      15                 :            : #include "H5Ipublic.h"
      16                 :            : 
      17                 :            : namespace moab
      18                 :            : {
      19                 :            : 
      20                 :            : class ReadHDF5Dataset;
      21                 :            : 
      22                 :            : /**\brief Read variable-length data from 1-D array dataset
      23                 :            :  *
      24                 :            :  * Utility class for reading variable-length data from an HDF5 dataset.
      25                 :            :  * Used for reading set contents, set parents, set children,
      26                 :            :  * polygon and polyhedron connectivity, and variable-length tag
      27                 :            :  * data.
      28                 :            :  *
      29                 :            :  * This is an abstract class.  The pure virtual \c store_data method
      30                 :            :  * must be implemented to create a concrete instance.
      31                 :            :  */
      32                 :            : class ReadHDF5VarLen
      33                 :            : {
      34                 :            :   protected:
      35                 :            :     DebugOutput& dbgOut;
      36                 :            : 
      37                 :            :   private:
      38                 :            :     void* const dataBuffer;
      39                 :            :     const size_t bufferSize;
      40                 :            : 
      41                 :            :     /**\brief Test if passed file_id is value pointed to by ranged_iter,
      42                 :            :      *        and if so, incremenet ranged_iter
      43                 :            :      */
      44                 :            :     static bool is_ranged( EntityHandle file_id, Range::const_iterator& ranged_iter, Range::const_iterator ranged_end );
      45                 :            : 
      46                 :            :   protected:
      47                 :            :     /**\brief Store data list for a single entity
      48                 :            :      *
      49                 :            :      * The is the pure virtual method that must be provided.
      50                 :            :      * It is responsible for storing the data read for a single
      51                 :            :      * entity.
      52                 :            :      *
      53                 :            :      * This function will always be called in the order of the
      54                 :            :      * file_ids in the range passed to the \c read method.
      55                 :            :      *
      56                 :            :      *\param file_id  The file ID for the entity
      57                 :            :      *\param data     A pointer to the data for the entity
      58                 :            :      *\param num_data Number of values for the entity
      59                 :            :      *\param ranged   For set contents, true if in ranged format.
      60                 :            :      */
      61                 :            :     virtual ErrorCode store_data( EntityHandle file_id, void* data, long num_data, bool ranged ) = 0;
      62                 :            : 
      63                 :            :   public:
      64                 :            :     /**\brief Constructor
      65                 :            :      *\param buffer      A temporary buffer to use during read
      66                 :            :      *\param buffer_size Size of \c buffer, in bytes.
      67                 :            :      */
      68                 :         73 :     ReadHDF5VarLen( DebugOutput& debug_output, void* buffer, size_t buffer_size )
      69                 :         73 :         : dbgOut( debug_output ), dataBuffer( buffer ), bufferSize( buffer_size )
      70                 :            :     {
      71                 :         73 :     }
      72                 :            : 
      73         [ -  + ]:        146 :     virtual ~ReadHDF5VarLen() {}
      74                 :            : 
      75                 :            :     /**\brief Do actual read of data set
      76                 :            :      *\param data_set         The data set to read.
      77                 :            :      *\param file_ids         The file ids of the entities to read.
      78                 :            :      *\param start_file_id    The file id corresponding to the first row of the dataset
      79                 :            :      *\param data_type        The desired, in-memory data type for values
      80                 :            :      *\param vals_per_ent     The number of values for each entity
      81                 :            :      *\param ranged_file_ids  Those file ids for which the 'ranged'
      82                 :            :      *                        argument to \c storedata should be passed
      83                 :            :      *                        as \c true.
      84                 :            :      */
      85                 :            :     ErrorCode read_data( ReadHDF5Dataset& data_set, const Range& offsets, EntityHandle start_offset, hid_t data_type,
      86                 :            :                          const Range& file_ids, const std::vector< unsigned >& vals_per_ent,
      87                 :            :                          const Range& ranged_file_ids );
      88                 :            : 
      89                 :            :     /**\brief Read set description table or offset vector for
      90                 :            :      *        var-len tags or old-format poly(gon|hedra) connectivity.
      91                 :            :      *\param data_set         The data set to read.
      92                 :            :      *\param file_ids         The file ids of the entities to read.
      93                 :            :      *\param start_file_id    The file id corresponding to the first row of the dataset
      94                 :            :      *\param num_columns      The number of columns of offsets in the dataset
      95                 :            :      *\param indices          Array of length \c num_columns contaning the
      96                 :            :      *                        indices of the columns to read.
      97                 :            :      *\param nudge            Amount by which to offset values in
      98                 :            :      *                        \c offset_out to avoid putting zeros in
      99                 :            :      *                        Range.  Must be greater than 0.  Probably 1.
     100                 :            :      *\param offsets_out      An array of length \c num_columns which will
     101                 :            :      *                        be populated with the resulting list of offsets
     102                 :            :      *                        into the contents list calculated from reading
     103                 :            :      *                        the offsets from the passed data set.
     104                 :            :      *\param counts_out       An array of length \c num_columns of std::vectors,
     105                 :            :      *                        where each vector will be filled with one value
     106                 :            :      *                        per file ID indicating the length of the data for
     107                 :            :      *                        the corresponding file ID.
     108                 :            :      *\param ranged_file_ids  If non-null, the last column of the table will
     109                 :            :      *                        be read and tested for the ranged bit.  For
     110                 :            :      *                        all file_ids for which the range bit is set,
     111                 :            :      *                        the file ID will be added to this list.
     112                 :            :      */
     113                 :            :     /*
     114                 :            :        ErrorCode read_offsets( ReadHDF5Dataset& data_set,
     115                 :            :                                const Range& file_ids,
     116                 :            :                                EntityHandle start_file_id,
     117                 :            :                                unsigned num_columns,
     118                 :            :                                const unsigned indices[],
     119                 :            :                                EntityHandle nudge,
     120                 :            :                                Range offsets_out[],
     121                 :            :                                std::vector<unsigned> counts_out[],
     122                 :            :                                Range* ranged_file_ids = 0 );
     123                 :            :    */
     124                 :            :     ErrorCode read_offsets( ReadHDF5Dataset& data_set, const Range& file_ids, EntityHandle start_file_id,
     125                 :            :                             EntityHandle nudge, Range& offsets_out, std::vector< unsigned >& counts_out );
     126                 :            : 
     127                 :          0 :     ErrorCode read( ReadHDF5Dataset& offset_data, ReadHDF5Dataset& value_data, const Range& file_ids,
     128                 :            :                     EntityHandle start_file_id, hid_t data_type, const Range* ranged = 0 )
     129                 :            :     {
     130                 :            :         ErrorCode rval;
     131                 :          0 :         const EntityHandle nudge = 1;
     132         [ #  # ]:          0 :         Range offsets;
     133         [ #  # ]:          0 :         std::vector< unsigned > counts;
     134         [ #  # ]:          0 :         rval = read_offsets( offset_data, file_ids, start_file_id, nudge, offsets, counts );
     135         [ #  # ]:          0 :         if( MB_SUCCESS != rval ) return rval;
     136         [ #  # ]:          0 :         Range empty;
     137 [ #  # ][ #  # ]:          0 :         rval = read_data( value_data, offsets, nudge, data_type, file_ids, counts, ranged ? *ranged : empty );
     138                 :          0 :         return rval;
     139                 :            :     }
     140                 :            : };
     141                 :            : 
     142                 :            : }  // namespace moab
     143                 :            : 
     144                 :            : #endif  // moab_READ_HDF5_VAR_LEN_HPP

Generated by: LCOV version 1.11