LCOV - code coverage report
Current view: directory - frmts/pcidsk/sdk/core - cpcidskfile.h (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 15 14 93.3 %
Date: 2011-12-18 Functions: 12 11 91.7 %

       1                 : /******************************************************************************
       2                 :  *
       3                 :  * Purpose:  Declaration of the CPCIDSKFile class.
       4                 :  * 
       5                 :  ******************************************************************************
       6                 :  * Copyright (c) 2009
       7                 :  * PCI Geomatics, 50 West Wilmot Street, Richmond Hill, Ont, 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 : public PCIDSKFile
      51                 :     {
      52                 :         friend PCIDSKFile PCIDSK_DLL *Open( std::string filename, 
      53                 :             std::string access, const PCIDSKInterfaces *interfaces );
      54                 :     public:
      55                 : 
      56                 :         CPCIDSKFile( std::string filename );
      57                 :         virtual ~CPCIDSKFile();
      58                 : 
      59             386 :         virtual PCIDSKInterfaces *GetInterfaces() { return &interfaces; }
      60                 : 
      61                 :         PCIDSKChannel  *GetChannel( int band );
      62                 :         PCIDSKSegment  *GetSegment( int segment );
      63                 :         std::vector<PCIDSKSegment *> GetSegments();
      64                 : 
      65                 :         PCIDSKSegment  *GetSegment( int type, std::string name,
      66                 :             int previous = 0 );
      67                 :         int  CreateSegment( std::string name, std::string description,
      68                 :             eSegType seg_type, int data_blocks );
      69                 :         void DeleteSegment( int segment );
      70                 :         void CreateOverviews( int chan_count, int *chan_list, 
      71                 :             int factor, std::string resampling );
      72                 : 
      73             284 :         int       GetWidth() const { return width; }
      74             284 :         int       GetHeight() const { return height; }
      75             343 :         int       GetChannels() const { return channel_count; }
      76             368 :         std::string GetInterleaving() const { return interleaving; }
      77            1400 :         bool      GetUpdatable() const { return updatable; } 
      78             132 :         uint64    GetFileSize() const { return file_size; }
      79                 : 
      80                 :         // the following are only for pixel interleaved IO
      81               0 :         int       GetPixelGroupSize() const { return pixel_group_size; }
      82                 :         void     *ReadAndLockBlock( int block_index, int xoff=-1, int xsize=-1 );
      83                 :         void      UnlockBlock( bool mark_dirty = false );
      84                 :         void      WriteBlock( int block_index, void *buffer );
      85                 :         void      FlushBlock();
      86                 : 
      87                 :         void      WriteToFile( const void *buffer, uint64 offset, uint64 size );
      88                 :         void      ReadFromFile( void *buffer, uint64 offset, uint64 size );
      89                 : 
      90               4 :         std::string GetFilename() const { return base_filename; }
      91                 : 
      92                 :         void      GetIODetails( void ***io_handle_pp, Mutex ***io_mutex_pp,
      93                 :                                 std::string filename="", bool writable=false );
      94                 : 
      95                 :         bool      GetEDBFileDetails( EDBFile** file_p, Mutex **io_mutex_p,
      96                 :                                      std::string filename );
      97                 : 
      98               7 :         std::string GetMetadataValue( const std::string& key ) 
      99               7 :             { return metadata.GetMetadataValue(key); }
     100              24 :         void        SetMetadataValue( const std::string& key, const std::string& value ) 
     101              24 :             { metadata.SetMetadataValue(key,value); }
     102               2 :         std::vector<std::string> GetMetadataKeys() 
     103               2 :             { return metadata.GetMetadataKeys(); }
     104                 : 
     105                 :         void      Synchronize();
     106                 : 
     107                 :     // not exposed to applications.
     108                 :         void      ExtendFile( uint64 blocks_requested, bool prezero = false );
     109                 :         void      ExtendSegment( int segment, uint64 blocks_to_add,
     110                 :             bool prezero = false );
     111                 :         void      MoveSegmentToEOF( int segment );
     112                 : 
     113                 :     private:
     114                 :         PCIDSKInterfaces interfaces;
     115                 : 
     116                 :         void         InitializeFromHeader();
     117                 : 
     118                 :         std::string  base_filename;
     119                 :         
     120                 :         int          width;
     121                 :         int          height;
     122                 :         int          channel_count;
     123                 :         std::string  interleaving;
     124                 : 
     125                 :         std::vector<PCIDSKChannel*> channels;
     126                 : 
     127                 :         int          segment_count;
     128                 :         uint64       segment_pointers_offset;
     129                 :         PCIDSKBuffer segment_pointers;
     130                 : 
     131                 :         std::vector<PCIDSKSegment*> segments;
     132                 : 
     133                 :     // pixel interleaved info.
     134                 :         uint64       block_size; // pixel interleaved scanline size.
     135                 :         int          pixel_group_size; // pixel interleaved pixel_offset value.
     136                 :         uint64       first_line_offset;
     137                 : 
     138                 :         int          last_block_index;
     139                 :         bool         last_block_dirty;
     140                 :         int          last_block_xoff;
     141                 :         int          last_block_xsize;
     142                 :         void        *last_block_data;
     143                 :         Mutex       *last_block_mutex;
     144                 : 
     145                 :         void        *io_handle;
     146                 :         Mutex       *io_mutex;
     147                 :         bool         updatable;
     148                 : 
     149                 :         uint64       file_size; // in blocks.
     150                 : 
     151                 :     // register of open external raw files.
     152                 :         std::vector<ProtectedFile>  file_list;
     153                 : 
     154                 :     // register of open external databasefiles
     155                 :         std::vector<ProtectedEDBFile> edb_file_list;
     156                 : 
     157                 :         MetadataSet  metadata;
     158                 :     };
     159                 : } // end namespace PCIDSK
     160                 : 
     161                 : #endif // __INCLUDE_PRIV_CPCIDSKFILE_H

Generated by: LCOV version 1.7