LCOV - code coverage report
Current view: top level - frmts/pcidsk/sdk/core - edb_pcidsk.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 0 27 0.0 %
Date: 2024-11-21 22:18:42 Functions: 0 13 0.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Purpose:  Implementation of the EDB interface that works only for
       4             :  *           links to another PCIDSK database.  This is mostly useful
       5             :  *           for testing - practical use is minimal.
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2010
       9             :  * PCI Geomatics, 90 Allstate Parkway, Markham, Ontario, Canada.
      10             :  *
      11             :  * SPDX-License-Identifier: MIT
      12             :  ****************************************************************************/
      13             : 
      14             : #include "pcidsk_config.h"
      15             : #include "pcidsk_types.h"
      16             : #include "core/pcidsk_utils.h"
      17             : #include "pcidsk_exception.h"
      18             : #include "pcidsk_edb.h"
      19             : #include "pcidsk.h"
      20             : #include <cassert>
      21             : #include <cstdio>
      22             : 
      23             : using namespace PCIDSK;
      24             : 
      25             : /************************************************************************/
      26             : /* ==================================================================== */
      27             : /*                            PCIDSK_EDBFile                            */
      28             : /* ==================================================================== */
      29             : /************************************************************************/
      30             : 
      31             : class PCIDSK_EDBFile final : public EDBFile
      32             : {
      33             :     mutable PCIDSKFile *file;
      34             : 
      35             : public:
      36             : 
      37           0 :     explicit PCIDSK_EDBFile( PCIDSKFile *file_in ) { file = file_in; }
      38           0 :     ~PCIDSK_EDBFile() { PCIDSK_EDBFile::Close(); }
      39             : 
      40             :     int Close() const override;
      41             :     int GetWidth() const override;
      42             :     int GetHeight() const override;
      43             :     int GetChannels() const override;
      44             :     int GetBlockWidth(int channel ) const override;
      45             :     int GetBlockHeight(int channel ) const override;
      46             :     eChanType GetType(int channel ) const override;
      47             :     int ReadBlock(int channel,
      48             :                   int block_index, void *buffer,
      49             :                   int win_xoff, int win_yoff,
      50             :                   int win_xsize, int win_ysize ) override;
      51             :     int WriteBlock( int channel, int block_index, void *buffer) override;
      52             : };
      53             : 
      54             : /************************************************************************/
      55             : /*                           DefaultOpenEDB()                           */
      56             : /************************************************************************/
      57             : 
      58           0 : EDBFile *PCIDSK::DefaultOpenEDB( const std::string& filename, const std::string& access )
      59             : 
      60             : {
      61             :     // it would be nice to be able to pass in an appropriate PCIDSKInterface!
      62             : 
      63           0 :     PCIDSKFile *file = PCIDSK::Open( filename, access, nullptr );
      64             : 
      65           0 :     return new PCIDSK_EDBFile( file );
      66             : }
      67             : 
      68             : /************************************************************************/
      69             : /*                               Close()                                */
      70             : /************************************************************************/
      71             : 
      72           0 : int PCIDSK_EDBFile::Close() const
      73             : 
      74             : {
      75           0 :     if( file != nullptr )
      76             :     {
      77           0 :         delete file;
      78           0 :         file = nullptr;
      79             :     }
      80             : 
      81           0 :     return 1;
      82             : }
      83             : 
      84             : /************************************************************************/
      85             : /*                              GetWidth()                              */
      86             : /************************************************************************/
      87             : 
      88           0 : int PCIDSK_EDBFile::GetWidth() const
      89             : 
      90             : {
      91           0 :     return file->GetWidth();
      92             : }
      93             : 
      94             : /************************************************************************/
      95             : /*                             GetHeight()                              */
      96             : /************************************************************************/
      97             : 
      98           0 : int PCIDSK_EDBFile::GetHeight() const
      99             : 
     100             : {
     101           0 :     return file->GetHeight();
     102             : }
     103             : 
     104             : /************************************************************************/
     105             : /*                            GetChannels()                             */
     106             : /************************************************************************/
     107             : 
     108           0 : int PCIDSK_EDBFile::GetChannels() const
     109             : 
     110             : {
     111           0 :     return file->GetChannels();
     112             : }
     113             : 
     114             : /************************************************************************/
     115             : /*                           GetBlockWidth()                            */
     116             : /************************************************************************/
     117             : 
     118           0 : int PCIDSK_EDBFile::GetBlockWidth( int channel ) const
     119             : 
     120             : {
     121           0 :     return file->GetChannel(channel)->GetBlockWidth();
     122             : }
     123             : 
     124             : /************************************************************************/
     125             : /*                           GetBlockHeight()                           */
     126             : /************************************************************************/
     127             : 
     128           0 : int PCIDSK_EDBFile::GetBlockHeight( int channel ) const
     129             : 
     130             : {
     131           0 :     return file->GetChannel(channel)->GetBlockHeight();
     132             : }
     133             : 
     134             : /************************************************************************/
     135             : /*                              GetType()                               */
     136             : /************************************************************************/
     137             : 
     138           0 : eChanType PCIDSK_EDBFile::GetType( int channel ) const
     139             : {
     140           0 :     return file->GetChannel(channel)->GetType();
     141             : }
     142             : 
     143             : /************************************************************************/
     144             : /*                             ReadBlock()                              */
     145             : /************************************************************************/
     146             : 
     147           0 : int PCIDSK_EDBFile::ReadBlock( int channel,
     148             :                                int block_index, void *buffer,
     149             :                                int win_xoff, int win_yoff,
     150             :                                int win_xsize, int win_ysize )
     151             : 
     152             : {
     153             :     return
     154           0 :         file->GetChannel(channel)->ReadBlock( block_index, buffer,
     155             :                                               win_xoff, win_yoff,
     156           0 :                                               win_xsize, win_ysize );
     157             : }
     158             : 
     159             : /************************************************************************/
     160             : /*                             WriteBlock()                             */
     161             : /************************************************************************/
     162             : 
     163           0 : int PCIDSK_EDBFile::WriteBlock( int channel, int block_index, void *buffer)
     164             : 
     165             : {
     166           0 :     return file->GetChannel(channel)->WriteBlock( block_index, buffer );
     167             : }

Generated by: LCOV version 1.14