ifw-odp  2.0.0-alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
imageWrapper.hpp
Go to the documentation of this file.
1 
9 #ifndef ODP_IMAGE_WRAPPER_HPP
10 #define ODP_IMAGE_WRAPPER_HPP
11 
12 #ifndef __cplusplus
13 #error This is a C++ include file and cannot be used from plain C
14 #endif
15 
16 // System header files
17 #include <type_traits>
18 
19 // Local header files
20 #include "cppcpl/image.hpp"
21 
22 
23 namespace odp {
35  template <typename T>
36  class ImageWrapper: virtual public odp::Image
37  {
38 
39  // Restrict the usage to the supported built-in types
40  static_assert(std::is_same<T, int>::value ||
41  std::is_same<T, float>::value ||
42  std::is_same<T, double>::value,
43  "class ImageWrapper can only be instantiated with int|float|double types");
44 
45  public:
51  ImageWrapper();
52 
59  ImageWrapper(const ImageWrapper& image);
67  ImageWrapper(const cpl_size xsize, const cpl_size ysize);
68 
80  ImageWrapper(const ImageWrapper& image,
81  const cpl_size llx,
82  const cpl_size lly,
83  const cpl_size urx,
84  const cpl_size ury);
85 
93  virtual ~ImageWrapper();
94 
99  virtual void Unload();
100 
107  virtual bool IsWrapped() const;
108 
113  virtual void SetWrap(bool status);
114 
120  virtual void Save(const char *filename);
121 
128  virtual void Save(const char *filename, cpl_type_bpp type_bpp);
129 
144  virtual void Read(T *data_ptr,
145  cpl_size width,
146  cpl_size height);
147 
148  private:
154  void Allocate(size_t size);
155 
156  protected:
157  T* m_data;
158 
159 
160  private:
161  bool m_wrapped;
162  };
163 
164 
165 
166 
167 }
168 
169 #include "imageWrapper.ipp"
170 #endif
This class is C++ wrapper for a CPL image object. It provides a simplified interface that allows to c...
Definition: image.hpp:43
virtual ~ImageWrapper()
Class destructor.
This is the base class that provides the interface to wrap images from shared memory areas...
Definition: imageWrapper.hpp:36
virtual void Read(T *data_ptr, cpl_size width, cpl_size height)
Wrap data from a data buffer.
virtual void Save(const char *filename)
Saves image into a FITS file.
T * m_data
Object buffer to store copied or casted shared memory areas.
Definition: imageWrapper.hpp:157
virtual void SetWrap(bool status)
Set wrapped flag.
virtual bool IsWrapped() const
Check if image was created around a pixel buffer.
virtual void Unload()
Unwrap CPL image.
ImageWrapper()
Class constructor.
Image class header file.