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-05-03 15:49:35 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             :  * Permission is hereby granted, free of charge, to any person obtaining a
      12             :  * copy of this software and associated documentation files (the "Software"),
      13             :  * to deal in the Software without restriction, including without limitation
      14             :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      15             :  * and/or sell copies of the Software, and to permit persons to whom the
      16             :  * Software is furnished to do so, subject to the following conditions:
      17             :  *
      18             :  * The above copyright notice and this permission notice shall be included
      19             :  * in all copies or substantial portions of the Software.
      20             :  *
      21             :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      22             :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      23             :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      24             :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      25             :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      26             :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      27             :  * DEALINGS IN THE SOFTWARE.
      28             :  ****************************************************************************/
      29             : 
      30             : #include "pcidsk_config.h"
      31             : #include "pcidsk_types.h"
      32             : #include "core/pcidsk_utils.h"
      33             : #include "pcidsk_exception.h"
      34             : #include "pcidsk_edb.h"
      35             : #include "pcidsk.h"
      36             : #include <cassert>
      37             : #include <cstdio>
      38             : 
      39             : using namespace PCIDSK;
      40             : 
      41             : /************************************************************************/
      42             : /* ==================================================================== */
      43             : /*                            PCIDSK_EDBFile                            */
      44             : /* ==================================================================== */
      45             : /************************************************************************/
      46             : 
      47             : class PCIDSK_EDBFile final : public EDBFile
      48             : {
      49             :     mutable PCIDSKFile *file;
      50             : 
      51             : public:
      52             : 
      53           0 :     explicit PCIDSK_EDBFile( PCIDSKFile *file_in ) { file = file_in; }
      54           0 :     ~PCIDSK_EDBFile() { PCIDSK_EDBFile::Close(); }
      55             : 
      56             :     int Close() const override;
      57             :     int GetWidth() const override;
      58             :     int GetHeight() const override;
      59             :     int GetChannels() const override;
      60             :     int GetBlockWidth(int channel ) const override;
      61             :     int GetBlockHeight(int channel ) const override;
      62             :     eChanType GetType(int channel ) const override;
      63             :     int ReadBlock(int channel,
      64             :                   int block_index, void *buffer,
      65             :                   int win_xoff, int win_yoff,
      66             :                   int win_xsize, int win_ysize ) override;
      67             :     int WriteBlock( int channel, int block_index, void *buffer) override;
      68             : };
      69             : 
      70             : /************************************************************************/
      71             : /*                           DefaultOpenEDB()                           */
      72             : /************************************************************************/
      73             : 
      74           0 : EDBFile *PCIDSK::DefaultOpenEDB( const std::string& filename, const std::string& access )
      75             : 
      76             : {
      77             :     // it would be nice to be able to pass in an appropriate PCIDSKInterface!
      78             : 
      79           0 :     PCIDSKFile *file = PCIDSK::Open( filename, access, nullptr );
      80             : 
      81           0 :     return new PCIDSK_EDBFile( file );
      82             : }
      83             : 
      84             : /************************************************************************/
      85             : /*                               Close()                                */
      86             : /************************************************************************/
      87             : 
      88           0 : int PCIDSK_EDBFile::Close() const
      89             : 
      90             : {
      91           0 :     if( file != nullptr )
      92             :     {
      93           0 :         delete file;
      94           0 :         file = nullptr;
      95             :     }
      96             : 
      97           0 :     return 1;
      98             : }
      99             : 
     100             : /************************************************************************/
     101             : /*                              GetWidth()                              */
     102             : /************************************************************************/
     103             : 
     104           0 : int PCIDSK_EDBFile::GetWidth() const
     105             : 
     106             : {
     107           0 :     return file->GetWidth();
     108             : }
     109             : 
     110             : /************************************************************************/
     111             : /*                             GetHeight()                              */
     112             : /************************************************************************/
     113             : 
     114           0 : int PCIDSK_EDBFile::GetHeight() const
     115             : 
     116             : {
     117           0 :     return file->GetHeight();
     118             : }
     119             : 
     120             : /************************************************************************/
     121             : /*                            GetChannels()                             */
     122             : /************************************************************************/
     123             : 
     124           0 : int PCIDSK_EDBFile::GetChannels() const
     125             : 
     126             : {
     127           0 :     return file->GetChannels();
     128             : }
     129             : 
     130             : /************************************************************************/
     131             : /*                           GetBlockWidth()                            */
     132             : /************************************************************************/
     133             : 
     134           0 : int PCIDSK_EDBFile::GetBlockWidth( int channel ) const
     135             : 
     136             : {
     137           0 :     return file->GetChannel(channel)->GetBlockWidth();
     138             : }
     139             : 
     140             : /************************************************************************/
     141             : /*                           GetBlockHeight()                           */
     142             : /************************************************************************/
     143             : 
     144           0 : int PCIDSK_EDBFile::GetBlockHeight( int channel ) const
     145             : 
     146             : {
     147           0 :     return file->GetChannel(channel)->GetBlockHeight();
     148             : }
     149             : 
     150             : /************************************************************************/
     151             : /*                              GetType()                               */
     152             : /************************************************************************/
     153             : 
     154           0 : eChanType PCIDSK_EDBFile::GetType( int channel ) const
     155             : {
     156           0 :     return file->GetChannel(channel)->GetType();
     157             : }
     158             : 
     159             : /************************************************************************/
     160             : /*                             ReadBlock()                              */
     161             : /************************************************************************/
     162             : 
     163           0 : int PCIDSK_EDBFile::ReadBlock( int channel,
     164             :                                int block_index, void *buffer,
     165             :                                int win_xoff, int win_yoff,
     166             :                                int win_xsize, int win_ysize )
     167             : 
     168             : {
     169             :     return
     170           0 :         file->GetChannel(channel)->ReadBlock( block_index, buffer,
     171             :                                               win_xoff, win_yoff,
     172           0 :                                               win_xsize, win_ysize );
     173             : }
     174             : 
     175             : /************************************************************************/
     176             : /*                             WriteBlock()                             */
     177             : /************************************************************************/
     178             : 
     179           0 : int PCIDSK_EDBFile::WriteBlock( int channel, int block_index, void *buffer)
     180             : 
     181             : {
     182           0 :     return file->GetChannel(channel)->WriteBlock( block_index, buffer );
     183             : }

Generated by: LCOV version 1.14