isce3  0.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
MemoryMap.h
1 #pragma once
2 
3 #include <cpl_virtualmem.h>
4 #include <gdal_priv.h>
5 #include <memory>
6 
7 #include "../forward.h"
8 
9 namespace isce3 { namespace io { namespace gdal { namespace detail {
10 
11 class MemoryMap {
12 public:
13 
14  MemoryMap() : _mmap(nullptr, [](CPLVirtualMem *) {}) {}
15 
16  explicit operator bool() const { return _mmap.get(); }
17 
18  // Get pointer to start of virtual memory mapping
19  void * data() { return CPLVirtualMemGetAddr(_mmap.get()); }
20 
21  // Get pointer to start of virtual memory mapping
22  const void * data() const { return CPLVirtualMemGetAddr(_mmap.get()); }
23 
24  // Size in bytes of mapped region
25  std::size_t size() const { return CPLVirtualMemGetSize(_mmap.get()); }
26 
27  // Access mode
28  CPLVirtualMemAccessMode access() const { return CPLVirtualMemGetAccessMode(_mmap.get()); }
29 
30  // Stride in bytes between the start of adjacent columns
31  std::size_t colstride() const { return _colstride; }
32 
33  // Stride in bytes between the start of adjacent rows
34  std::size_t rowstride() const { return _rowstride; }
35 
36  friend class isce3::io::gdal::Raster;
37 
38 private:
39 
40  MemoryMap(const GDALRasterBand * raster);
41 
42  MemoryMap(GDALRasterBand * raster, GDALAccess access);
43 
44  std::shared_ptr<CPLVirtualMem> _mmap;
45  std::size_t _colstride = 0;
46  std::size_t _rowstride = 0;
47 };
48 
49 }}}}
Definition: MemoryMap.h:11
Wrapper for GDALRasterBand representing a single raster.
Definition: Raster.h:14
GDALAccess access() const
Access mode.
Definition: Raster.h:146

Generated for ISCE3.0 by doxygen 1.8.5.