LCOV - code coverage report
Current view: top level - frmts/pcidsk/sdk - pcidsk_file.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 10 11 90.9 %
Date: 2024-05-04 12:52:34 Functions: 2 3 66.7 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Purpose: Declaration of the PCIDSKFile Interface
       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_PCIDSK_FILE_H
      28             : #define INCLUDE_PCIDSK_FILE_H
      29             : 
      30             : #include "pcidsk_segment.h"
      31             : #include <string>
      32             : #include <vector>
      33             : #include <map>
      34             : #include <functional>
      35             : #include <algorithm>
      36             : 
      37             : namespace PCIDSK
      38             : {
      39             : /************************************************************************/
      40             : /*                              PCIDSKFile                              */
      41             : /************************************************************************/
      42         575 :     static bool CheckSegNamesEqual(const char * pszName, unsigned nSize,
      43             :                                    const char * pszCheckName, unsigned nCheckSize)
      44             :     {
      45         575 :         if(nCheckSize == 0)
      46          97 :             return true;
      47         478 :         int nFirstSize = std::min(nCheckSize, nSize);
      48         478 :         if(!std::equal(pszName, pszName + nFirstSize, pszCheckName))
      49         232 :             return false;
      50             :         //make sure the rest of the string is just whitespace
      51         267 :         for(unsigned i = nFirstSize; i < nSize; i++)
      52          21 :             if(pszName[i] != ' ')
      53           0 :                 return false;
      54         246 :         return true;
      55             :     }
      56             : 
      57             :     class PCIDSKChannel;
      58             :     class PCIDSKSegment;
      59             :     class PCIDSKInterfaces;
      60             :     class Mutex;
      61             : 
      62             : //! Top interface to PCIDSK (.pix) files.
      63             :     class PCIDSK_DLL PCIDSKFile
      64             :     {
      65             :     public:
      66         255 :         virtual ~PCIDSKFile() {}
      67             : 
      68             :         virtual PCIDSKInterfaces *GetInterfaces() = 0;
      69             : 
      70             :         virtual PCIDSKChannel  *GetChannel( int band ) = 0;
      71             :         virtual PCIDSKSegment  *GetSegment( int segment ) = 0;
      72             : 
      73             :         virtual PCIDSK::PCIDSKSegment *
      74             :             GetSegment( int type, const std::string & name, int previous = 0 ) = 0;
      75             :         virtual unsigned GetSegmentID(int segment, const std::string & name = {},
      76             :                                       unsigned previous = 0) const = 0;
      77             :         virtual std::vector<unsigned> GetSegmentIDs(int segment,
      78             :                  const std::function<bool(const char *, unsigned)> & oFilter) const = 0;
      79             :         std::vector<unsigned> GetSegmentIDs(int segment) const
      80             :         {
      81             :             static const std::function<bool(const char *, unsigned)> oTrue =
      82             :                 [](const char *, unsigned) { return true; };
      83             :             return GetSegmentIDs(segment, oTrue);
      84             :         }
      85             :         std::vector<unsigned> GetSegmentIDs(int segment, const std::string & name) const
      86             :         {
      87             :             std::function<bool(const char *, unsigned)> oCheck =
      88             :                 [&name](const char * pszName, unsigned nSize)
      89             :                 {
      90             :                     return CheckSegNamesEqual(pszName, nSize, name.c_str(),
      91             :                                               (unsigned)name.size());
      92             :                 };
      93             :             return GetSegmentIDs(segment, std::move(oCheck));
      94             :         }
      95             : 
      96             :         virtual int GetWidth() const = 0;
      97             :         virtual int GetHeight() const = 0;
      98             :         virtual int GetChannels() const = 0;
      99             :         virtual std::string GetInterleaving() const = 0;
     100             :         virtual bool GetUpdatable() const = 0;
     101             :         virtual uint64 GetFileSize() const = 0;
     102             : 
     103             :         virtual int  CreateSegment( std::string name, std::string description,
     104             :             eSegType seg_type, int data_blocks ) = 0;
     105             :         virtual void DeleteSegment( int segment ) = 0;
     106             :         virtual void CreateOverviews( int chan_count, const int *chan_list,
     107             :             int factor, std::string resampling ) = 0;
     108             : 
     109             :     // the following are only for pixel interleaved IO
     110             :         virtual int    GetPixelGroupSize() const = 0;
     111             :         virtual void *ReadAndLockBlock( int block_index, int xoff=-1, int xsize=-1) = 0;
     112             :         virtual void  UnlockBlock( bool mark_dirty = false ) = 0;
     113             : 
     114             :     // low level io, primarily internal.
     115             :         virtual void WriteToFile( const void *buffer, uint64 offset, uint64 size)=0;
     116             :         virtual void ReadFromFile( void *buffer, uint64 offset, uint64 size ) = 0;
     117             : 
     118             :         virtual void GetIODetails( void ***io_handle_pp, Mutex ***io_mutex_pp,
     119             :                                    const std::string& filename=std::string(), bool writable=false ) = 0;
     120             : 
     121             :         virtual std::string GetUniqueEDBFilename() = 0;
     122             : 
     123             :         virtual std::map<int,int> GetEDBChannelMap(std::string oExtFilename) = 0;
     124             : 
     125             :         virtual std::string GetMetadataValue( const std::string& key ) = 0;
     126             :         virtual void SetMetadataValue( const std::string& key, const std::string& value ) = 0;
     127             :         virtual std::vector<std::string> GetMetadataKeys() = 0;
     128             : 
     129             :         virtual void Synchronize() = 0;
     130             :     };
     131             : } // end namespace PCIDSK
     132             : 
     133             : #endif // INCLUDE_PCIDSK_FILE_H

Generated by: LCOV version 1.14