Magick++  7.1.0
ImageRef.h
Go to the documentation of this file.
1 // This may look like C code, but it is really -*- C++ -*-
2 //
3 // Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002
4 //
5 // Copyright @ 2014 ImageMagick Studio LLC, a non-profit organization
6 // dedicated to making software imaging solutions freely available.
7 //
8 // Definition of an Image reference
9 //
10 // This is a private implementation class which should never be
11 // referenced by any user code.
12 //
13 
14 #if !defined(Magick_ImageRef_header)
15 #define Magick_ImageRef_header
16 
17 #include <string>
18 #include "Magick++/Include.h"
19 #include "Magick++/Thread.h"
20 
21 namespace Magick
22 {
23  class Options;
24 
25  //
26  // Reference counted access to Image *
27  //
29  {
30  public:
31 
32  // Construct with null image and default options
33  ImageRef(void);
34 
35  // Construct with an image pointer and default options
36  ImageRef(MagickCore::Image *image_);
37 
38  // Destroy image and options
39  ~ImageRef(void);
40 
41  // Decreases reference count and return the new count
42  size_t decrease();
43 
44  // Retrieve image from reference
45  MagickCore::Image *&image(void);
46 
47  // Increases reference count
48  void increase();
49 
50  // Returns true if the reference count is more than one
51  bool isShared();
52 
53  // Retrieve Options from reference
54  void options(Options *options_);
55  Options *options(void);
56 
57  // Tries to replaces the images with the specified image, returns
58  // a new instance when the current image is shared.
59  static ImageRef *replaceImage(ImageRef *imgRef,
60  MagickCore::Image *replacement_);
61 
62  // Image signature. Set force_ to true in order to re-calculate
63  // the signature regardless of whether the image data has been
64  // modified.
65  std::string signature(const bool force_=false);
66 
67  private:
68 
69  // Construct with an image pointer and options
70  ImageRef(MagickCore::Image *image_,const Options *options_);
71 
72  // Copy constructor and assignment are not supported
73  ImageRef(const ImageRef&);
74 
75  ImageRef& operator=(const ImageRef&);
76 
77  MagickCore::Image *_image; // ImageMagick Image
78  MutexLock _mutexLock; // Mutex lock
79  Options *_options; // User-specified options
80  ::ssize_t _refCount; // Reference count
81  };
82 
83 } // end of namespace Magick
84 
85 #endif // Magick_ImageRef_header
#define MagickPPExport
Definition: Include.h:297
class MagickPPExport Image
Definition: Drawable.h:722
Definition: Blob.h:17