Home | History | Annotate | Download | only in Magick++
      1 // This may look like C code, but it is really -*- C++ -*-
      2 //
      3 // Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002
      4 // Copyright Dirk Lemstra 2014-2015
      5 //
      6 // Blob reference class
      7 //
      8 // This is an internal implementation class that should not be
      9 // accessed by users.
     10 //
     11 
     12 #if !defined(Magick_Blob_header)
     13 #define Magick_Blob_header
     14 
     15 #include "Magick++/Include.h"
     16 #include "Magick++/Thread.h"
     17 #include "Magick++/Blob.h"
     18 
     19 namespace Magick
     20 {
     21   class BlobRef
     22   {
     23   public:
     24 
     25     // Construct with data, making private copy of data
     26     BlobRef(const void* data_,const size_t length_);
     27 
     28     // Destructor (actually destroys data)
     29     ~BlobRef(void);
     30 
     31     // Decreases reference count and return the new count
     32     size_t decrease();
     33 
     34     // Increases reference count
     35     void increase();
     36 
     37     Blob::Allocator allocator; // Memory allocation system in use
     38     size_t          length;    // Blob length
     39     void*           data;      // Blob data
     40 
     41   private:
     42     // Copy constructor and assignment are not supported
     43     BlobRef(const BlobRef&);
     44     BlobRef& operator=(const BlobRef&);
     45 
     46     MutexLock _mutexLock; // Mutex lock
     47     size_t    _refCount;  // Reference count
     48   };
     49 
     50 } // namespace Magick
     51 
     52 #endif // Magick_Blob_header
     53