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