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-05-04 12:52:34 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             :  * Permission is hereby granted, free of charge, to any person obtaining a
      10             :  * copy of this software and associated documentation files (the "Software"),
      11             :  * to deal in the Software without restriction, including without limitation
      12             :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      13             :  * and/or sell copies of the Software, and to permit persons to whom the
      14             :  * Software is furnished to do so, subject to the following conditions:
      15             :  *
      16             :  * The above copyright notice and this permission notice shall be included
      17             :  * in all copies or substantial portions of the Software.
      18             :  *
      19             :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      20             :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      21             :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      22             :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      23             :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      24             :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      25             :  * DEALINGS IN THE SOFTWARE.
      26             :  ****************************************************************************/
      27             : #ifndef INCLUDE_PRIV_CPCIDSKFILE_H
      28             : #define INCLUDE_PRIV_CPCIDSKFILE_H
      29             : 
      30             : #include "pcidsk_config.h"
      31             : #include "pcidsk_types.h"
      32             : #include "pcidsk_buffer.h"
      33             : #include "pcidsk_file.h"
      34             : #include "pcidsk_mutex.h"
      35             : #include "pcidsk_interfaces.h"
      36             : #include "core/metadataset.h"
      37             : #include "core/protectedfile.h"
      38             : 
      39             : #include <string>
      40             : #include <vector>
      41             : 
      42             : namespace PCIDSK
      43             : {
      44             :     class PCIDSKChannel;
      45             :     class PCIDSKSegment;
      46             :     class PCIDSKInterfaces;
      47             : /************************************************************************/
      48             : /*                             CPCIDSKFile                              */
      49             : /************************************************************************/
      50             :     class CPCIDSKFile final: public PCIDSKFile
      51             :     {
      52             :         friend PCIDSKFile PCIDSK_DLL *Open( const std::string& filename,
      53             :             const std::string& access, const PCIDSKInterfaces *interfaces, int max_channel_count_allowed );
      54             :     public:
      55             : 
      56             :         CPCIDSKFile( const std::string& filename );
      57             :         virtual ~CPCIDSKFile();
      58             : 
      59         752 :         virtual PCIDSKInterfaces *GetInterfaces() override { return &interfaces; }
      60             : 
      61             :         PCIDSKChannel  *GetChannel( int band ) override;
      62             :         PCIDSKSegment  *GetSegment( int segment ) override;
      63             : 
      64             :         PCIDSKSegment  *GetSegment( int type, const std::string & name,
      65             :             int previous = 0 ) override;
      66             :         unsigned GetSegmentID(int segment, const std::string & name = {},
      67             :                               unsigned previous = 0) const override;
      68             :         std::vector<unsigned> GetSegmentIDs(int segment,
      69             :                   const std::function<bool(const char *,unsigned)> & oFilter) const override;
      70             : 
      71             :         int  CreateSegment( std::string name, std::string description,
      72             :             eSegType seg_type, int data_blocks ) override;
      73             :         void DeleteSegment( int segment ) override;
      74             :         void CreateOverviews( int chan_count, const int *chan_list,
      75             :             int factor, std::string resampling ) override;
      76             : 
      77         893 :         int       GetWidth() const override { return width; }
      78         893 :         int       GetHeight() const override { return height; }
      79         651 :         int       GetChannels() const override { return channel_count; }
      80         701 :         std::string GetInterleaving() const override { return interleaving; }
      81       12867 :         bool      GetUpdatable() const override { return updatable; }
      82        2481 :         uint64    GetFileSize() const override { return file_size; }
      83             : 
      84             :         // the following are only for pixel interleaved IO
      85           0 :         int       GetPixelGroupSize() const override { return pixel_group_size; }
      86             :         void     *ReadAndLockBlock( int block_index, int xoff=-1, int xsize=-1 ) override;
      87             :         void      UnlockBlock( bool mark_dirty = false ) override;
      88             :         void      WriteBlock( int block_index, void *buffer );
      89             :         void      FlushBlock();
      90             : 
      91             :         void      WriteToFile( const void *buffer, uint64 offset, uint64 size ) override;
      92             :         void      ReadFromFile( void *buffer, uint64 offset, uint64 size ) override;
      93             : 
      94           4 :         std::string GetFilename() const { return base_filename; }
      95             : 
      96             :         void      GetIODetails( void ***io_handle_pp, Mutex ***io_mutex_pp,
      97             :                                 const std::string& filename=std::string(), bool writable=false ) override;
      98             : 
      99             :         bool      GetEDBFileDetails( EDBFile** file_p, Mutex **io_mutex_p,
     100             :                                      const std::string& filename );
     101             : 
     102             :         std::string GetUniqueEDBFilename() override;
     103             : 
     104             :         std::map<int,int> GetEDBChannelMap(std::string oExtFilename) override;
     105             : 
     106         130 :         std::string GetMetadataValue( const std::string& key ) override
     107         130 :             { return metadata.GetMetadataValue(key); }
     108          27 :         void        SetMetadataValue( const std::string& key, const std::string& value ) override
     109          27 :             { metadata.SetMetadataValue(key,value); }
     110          24 :         std::vector<std::string> GetMetadataKeys() override
     111          24 :             { return metadata.GetMetadataKeys(); }
     112             : 
     113             :         void      Synchronize() override;
     114             : 
     115             :     // not exposed to applications.
     116             :         void      ExtendFile( uint64 blocks_requested,
     117             :                               bool prezero = false, bool writedata = true );
     118             :         void      ExtendSegment( int segment, uint64 blocks_to_add,
     119             :                                  bool prezero = false, bool writedata = true );
     120             :         void      MoveSegmentToEOF( int segment );
     121             : 
     122             :     private:
     123             :         PCIDSKInterfaces interfaces;
     124             : 
     125             :         void         InitializeFromHeader(int max_channel_count_allowed = -1);
     126             : 
     127             :         std::string  base_filename;
     128             : 
     129             :         int          width;
     130             :         int          height;
     131             :         int          channel_count;
     132             :         std::string  interleaving;
     133             : 
     134             :         std::vector<PCIDSKChannel*> channels;
     135             : 
     136             :         int          segment_count;
     137             :         uint64       segment_pointers_offset;
     138             :         PCIDSKBuffer segment_pointers;
     139             : 
     140             :         std::vector<PCIDSKSegment*> segments;
     141             : 
     142             :     // pixel interleaved info.
     143             :         uint64       block_size; // pixel interleaved scanline size.
     144             :         int          pixel_group_size; // pixel interleaved pixel_offset value.
     145             :         uint64       first_line_offset;
     146             : 
     147             :         int          last_block_index;
     148             :         bool         last_block_dirty;
     149             :         int          last_block_xoff;
     150             :         int          last_block_xsize;
     151             :         void        *last_block_data;
     152             :         Mutex       *last_block_mutex;
     153             : 
     154             :         void        *io_handle;
     155             :         Mutex       *io_mutex;
     156             :         bool         updatable;
     157             : 
     158             :         uint64       file_size; // in blocks.
     159             : 
     160             :     // register of open external raw files.
     161             :         std::vector<ProtectedFile>  file_list;
     162             : 
     163             :     // register of open external databasefiles
     164             :         std::vector<ProtectedEDBFile> edb_file_list;
     165             : 
     166             :         MetadataSet  metadata;
     167             :     };
     168             : } // end namespace PCIDSK
     169             : 
     170             : #endif // INCLUDE_PRIV_CPCIDSKFILE_H

Generated by: LCOV version 1.14