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

Generated by: LCOV version 1.14