LCOV - code coverage report
Current view: top level - frmts/pcidsk/sdk/core - cpcidskfile.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 14 15 93.3 %
Date: 2024-11-21 22:18:42 Functions: 11 12 91.7 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Purpose:  Declaration of the CPCIDSKFile class.
       4             :  *
       5             :  ******************************************************************************
       6             :  * Copyright (c) 2009
       7             :  * PCI Geomatics, 90 Allstate Parkway, Markham, Ontario, Canada.
       8             :  *
       9             :  * SPDX-License-Identifier: MIT
      10             :  ****************************************************************************/
      11             : #ifndef INCLUDE_PRIV_CPCIDSKFILE_H
      12             : #define INCLUDE_PRIV_CPCIDSKFILE_H
      13             : 
      14             : #include "pcidsk_config.h"
      15             : #include "pcidsk_types.h"
      16             : #include "pcidsk_buffer.h"
      17             : #include "pcidsk_file.h"
      18             : #include "pcidsk_mutex.h"
      19             : #include "pcidsk_interfaces.h"
      20             : #include "core/metadataset.h"
      21             : #include "core/protectedfile.h"
      22             : 
      23             : #include <string>
      24             : #include <vector>
      25             : 
      26             : namespace PCIDSK
      27             : {
      28             :     class PCIDSKChannel;
      29             :     class PCIDSKSegment;
      30             :     class PCIDSKInterfaces;
      31             : /************************************************************************/
      32             : /*                             CPCIDSKFile                              */
      33             : /************************************************************************/
      34             :     class CPCIDSKFile final: public PCIDSKFile
      35             :     {
      36             :         friend PCIDSKFile PCIDSK_DLL *Open( const std::string& filename,
      37             :             const std::string& access, const PCIDSKInterfaces *interfaces, int max_channel_count_allowed );
      38             :     public:
      39             : 
      40             :         CPCIDSKFile( const std::string& filename );
      41             :         virtual ~CPCIDSKFile();
      42             : 
      43         752 :         virtual PCIDSKInterfaces *GetInterfaces() override { return &interfaces; }
      44             : 
      45             :         PCIDSKChannel  *GetChannel( int band ) override;
      46             :         PCIDSKSegment  *GetSegment( int segment ) override;
      47             : 
      48             :         PCIDSKSegment  *GetSegment( int type, const std::string & name,
      49             :             int previous = 0 ) override;
      50             :         unsigned GetSegmentID(int segment, const std::string & name = {},
      51             :                               unsigned previous = 0) const override;
      52             :         std::vector<unsigned> GetSegmentIDs(int segment,
      53             :                   const std::function<bool(const char *,unsigned)> & oFilter) const override;
      54             : 
      55             :         int  CreateSegment( std::string name, std::string description,
      56             :             eSegType seg_type, int data_blocks ) override;
      57             :         void DeleteSegment( int segment ) override;
      58             :         void CreateOverviews( int chan_count, const int *chan_list,
      59             :             int factor, std::string resampling ) override;
      60             : 
      61         893 :         int       GetWidth() const override { return width; }
      62         893 :         int       GetHeight() const override { return height; }
      63         651 :         int       GetChannels() const override { return channel_count; }
      64         701 :         std::string GetInterleaving() const override { return interleaving; }
      65       12867 :         bool      GetUpdatable() const override { return updatable; }
      66        2481 :         uint64    GetFileSize() const override { return file_size; }
      67             : 
      68             :         // the following are only for pixel interleaved IO
      69           0 :         int       GetPixelGroupSize() const override { return pixel_group_size; }
      70             :         void     *ReadAndLockBlock( int block_index, int xoff=-1, int xsize=-1 ) override;
      71             :         void      UnlockBlock( bool mark_dirty = false ) override;
      72             :         void      WriteBlock( int block_index, void *buffer );
      73             :         void      FlushBlock();
      74             : 
      75             :         void      WriteToFile( const void *buffer, uint64 offset, uint64 size ) override;
      76             :         void      ReadFromFile( void *buffer, uint64 offset, uint64 size ) override;
      77             : 
      78           4 :         std::string GetFilename() const { return base_filename; }
      79             : 
      80             :         void      GetIODetails( void ***io_handle_pp, Mutex ***io_mutex_pp,
      81             :                                 const std::string& filename=std::string(), bool writable=false ) override;
      82             : 
      83             :         bool      GetEDBFileDetails( EDBFile** file_p, Mutex **io_mutex_p,
      84             :                                      const std::string& filename );
      85             : 
      86             :         std::string GetUniqueEDBFilename() override;
      87             : 
      88             :         std::map<int,int> GetEDBChannelMap(std::string oExtFilename) override;
      89             : 
      90         130 :         std::string GetMetadataValue( const std::string& key ) override
      91         130 :             { return metadata.GetMetadataValue(key); }
      92          27 :         void        SetMetadataValue( const std::string& key, const std::string& value ) override
      93          27 :             { metadata.SetMetadataValue(key,value); }
      94          24 :         std::vector<std::string> GetMetadataKeys() override
      95          24 :             { return metadata.GetMetadataKeys(); }
      96             : 
      97             :         void      Synchronize() override;
      98             : 
      99             :     // not exposed to applications.
     100             :         void      ExtendFile( uint64 blocks_requested,
     101             :                               bool prezero = false, bool writedata = true );
     102             :         void      ExtendSegment( int segment, uint64 blocks_to_add,
     103             :                                  bool prezero = false, bool writedata = true );
     104             :         void      MoveSegmentToEOF( int segment );
     105             : 
     106             :     private:
     107             :         PCIDSKInterfaces interfaces;
     108             : 
     109             :         void         InitializeFromHeader(int max_channel_count_allowed = -1);
     110             : 
     111             :         std::string  base_filename;
     112             : 
     113             :         int          width;
     114             :         int          height;
     115             :         int          channel_count;
     116             :         std::string  interleaving;
     117             : 
     118             :         std::vector<PCIDSKChannel*> channels;
     119             : 
     120             :         int          segment_count;
     121             :         uint64       segment_pointers_offset;
     122             :         PCIDSKBuffer segment_pointers;
     123             : 
     124             :         std::vector<PCIDSKSegment*> segments;
     125             : 
     126             :     // pixel interleaved info.
     127             :         uint64       block_size; // pixel interleaved scanline size.
     128             :         int          pixel_group_size; // pixel interleaved pixel_offset value.
     129             :         uint64       first_line_offset;
     130             : 
     131             :         int          last_block_index;
     132             :         bool         last_block_dirty;
     133             :         int          last_block_xoff;
     134             :         int          last_block_xsize;
     135             :         void        *last_block_data;
     136             :         Mutex       *last_block_mutex;
     137             : 
     138             :         void        *io_handle;
     139             :         Mutex       *io_mutex;
     140             :         bool         updatable;
     141             : 
     142             :         uint64       file_size; // in blocks.
     143             : 
     144             :     // register of open external raw files.
     145             :         std::vector<ProtectedFile>  file_list;
     146             : 
     147             :     // register of open external databasefiles
     148             :         std::vector<ProtectedEDBFile> edb_file_list;
     149             : 
     150             :         MetadataSet  metadata;
     151             :     };
     152             : } // end namespace PCIDSK
     153             : 
     154             : #endif // INCLUDE_PRIV_CPCIDSKFILE_H

Generated by: LCOV version 1.14