LCOV - code coverage report
Current view: top level - frmts/pcidsk/sdk/channel - cpcidskchannel.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 12 12 100.0 %
Date: 2024-05-07 17:03:27 Functions: 9 9 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Purpose:  Declaration of the CPCIDSKChannel Abstract 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_CHANNEL_CPCIDSKCHANNEL_H
      28             : #define INCLUDE_CHANNEL_CPCIDSKCHANNEL_H
      29             : 
      30             : #include "pcidsk_config.h"
      31             : #include "pcidsk_buffer.h"
      32             : #include "pcidsk_channel.h"
      33             : #include "core/metadataset.h"
      34             : #include "core/mutexholder.h"
      35             : #include <vector>
      36             : #include <string>
      37             : 
      38             : namespace PCIDSK
      39             : {
      40             :     class CPCIDSKFile;
      41             :     class CTiledChannel;
      42             : /************************************************************************/
      43             : /*                            CPCIDSKChannel                            */
      44             : /*                                                                      */
      45             : /* Abstract class that helps implement some of the more mundane details */
      46             : /* required for when implementing an imagery channel I/O strategy.  If  */
      47             : /* you are using this to implement those details, use virtual           */
      48             : /* inheritance to attempt to avoid the fragile base class problem and   */
      49             : /* then implement the Imagery I/O functions.                            */
      50             : /************************************************************************/
      51             :     class PCIDSK_DLL CPCIDSKChannel : public PCIDSKChannel
      52             :     {
      53             :         friend class PCIDSKFile;
      54             : 
      55             :     public:
      56             :         CPCIDSKChannel( PCIDSKBuffer &image_header, uint64 ih_offset,
      57             :             CPCIDSKFile *file, eChanType pixel_type,
      58             :             int channel_number );
      59             :         virtual   ~CPCIDSKChannel();
      60             : 
      61         876 :         virtual int GetBlockWidth() const override { return block_width; }
      62         876 :         virtual int GetBlockHeight() const override { return block_height; }
      63             :         virtual int GetBlockCount() const override;
      64             : 
      65           1 :         virtual int GetWidth() const override { return width; }
      66           1 :         virtual int GetHeight() const override { return height; }
      67        1024 :         virtual eChanType GetType() const override { return pixel_type; }
      68             : 
      69             :         int       GetOverviewCount() override;
      70             :         PCIDSKChannel  *GetOverview( int i ) override;
      71             :         bool IsOverviewValid( int i ) override;
      72             :         void SetOverviewValidity( int i, bool validity ) override;
      73             :         std::string GetOverviewResampling( int i ) override;
      74             :         std::vector<int> GetOverviewLevelMapping() const override;
      75             : 
      76             :         int         GetChannelNumber() { return channel_number; }
      77             : 
      78             :         bool        IsLocked() const { return is_locked; }
      79             : 
      80             :         std::string GetFilename() const;
      81             : 
      82          31 :         std::string GetMetadataValue( const std::string &key ) const override
      83          31 :             { return metadata.GetMetadataValue(key); }
      84          11 :         void        SetMetadataValue( const std::string &key, const std::string &value ) override
      85          11 :             { metadata.SetMetadataValue(key,value); }
      86         252 :         std::vector<std::string> GetMetadataKeys() const override
      87         252 :             { return metadata.GetMetadataKeys(); }
      88             : 
      89         234 :         virtual void Synchronize() override {}
      90             : 
      91             :         std::string GetDescription() override;
      92             :         void SetDescription( const std::string &description ) override;
      93             : 
      94             :         virtual std::vector<std::string> GetHistoryEntries() const override;
      95             :         virtual void SetHistoryEntries( const std::vector<std::string> &entries ) override;
      96             :         virtual void PushHistory(const std::string &app,
      97             :                                  const std::string &message) override;
      98             : 
      99             :         virtual void GetChanInfo( std::string &filename, uint64 &image_offset,
     100             :                                   uint64 &pixel_offset, uint64 &line_offset,
     101             :                                   bool &little_endian ) const override;
     102             :         virtual void SetChanInfo( std::string filename, uint64 image_offset,
     103             :                                   uint64 pixel_offset, uint64 line_offset,
     104             :                                   bool little_endian ) override;
     105             :         virtual void GetEChanInfo( std::string &filename, int &echannel,
     106             :                                    int &exoff, int &eyoff,
     107             :                                    int &exsize, int &eysize ) const override;
     108             :         virtual void SetEChanInfo( std::string filename, int echannel,
     109             :                                    int exoff, int eyoff,
     110             :                                    int exsize, int eysize ) override;
     111             : 
     112             :     // Just for CPCIDSKFile.
     113             :         void      InvalidateOverviewInfo();
     114             :         void      UpdateOverviewInfo(const char *pszOverviewMDKey,
     115             :                                      int nFactor);
     116             : 
     117             :     protected:
     118             :         CPCIDSKFile *file;
     119             :         mutable MetadataSet  metadata;
     120             : 
     121             :         void LoadHistory( const PCIDSKBuffer &image_header );
     122             :         std::vector<std::string> history_;
     123             : 
     124             :         int       channel_number;
     125             :         uint64    ih_offset;
     126             :         mutable eChanType pixel_type;
     127             :         bool      is_locked;
     128             :         char      byte_order; // 'S': littleendian, 'N': bigendian
     129             :         mutable int       needs_swap;
     130             : 
     131             :     // width/height, and block size.
     132             :         mutable int       width;
     133             :         mutable int       height;
     134             :         mutable int       block_width;
     135             :         mutable int       block_height;
     136             : 
     137             :     // info about overviews;
     138             :         void      EstablishOverviewInfo() const;
     139             : 
     140             :         mutable bool                         overviews_initialized;
     141             :         mutable std::vector<std::string>     overview_infos;
     142             :         mutable std::vector<CTiledChannel *> overview_bands;
     143             :         mutable std::vector<int>             overview_decimations;
     144             : 
     145             :         void      InvalidateOverviews();
     146             :     };
     147             : } // end namespace PCIDSK
     148             : 
     149             : #endif // INCLUDE_CHANNEL_CPCIDSKCHANNEL_H

Generated by: LCOV version 1.14