"Fossies" - the Fresh Open Source Software Archive

Member "heaplayers-351/allocators/hoard/ownerheader.h" (5 May 2005, 1314 Bytes) of package /linux/misc/old/heaplayers_3_5_1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "ownerheader.h" see the Fossies "Dox" file reference documentation.

    1 #ifndef _OWNERHEADER_H_
    2 #define _OWNERHEADER_H_
    3 
    4 #include <assert.h>
    5 
    6 /**
    7  * @class OwnerHeader
    8  * @brief Adds ownership management to a superblock.
    9  * @author Emery Berger <http://www.cs.umass.edu/~emery>
   10  */
   11 
   12 template <class Super, class SuperblockType, class HeapType>
   13 class OwnerHeader : public Super {
   14 public:
   15 
   16   typedef HeapType OwnerType;
   17 
   18   class Header : public Super {};
   19 
   20   OwnerHeader (size_t sz)
   21     : Super (sz),
   22     _owner (NULL),
   23     _prev (NULL),
   24     _next (NULL)
   25   {}
   26 
   27   inline HeapType * getOwner (void) const {
   28     return _owner;
   29   }
   30 
   31   inline void setOwner (HeapType * o) {
   32     assert (o != NULL);
   33     _owner = o;
   34   }
   35 
   36   inline SuperblockType * getNext (void) const {
   37     return _next;
   38   }
   39 
   40   inline SuperblockType * getPrev (void) const {
   41     return _prev;
   42   }
   43 
   44   inline void setNext (SuperblockType * f) {
   45     assert (f != this);
   46     _next = f;
   47   }
   48 
   49   inline void setPrev (SuperblockType * f) {
   50     assert (f != this);
   51     _prev = f;
   52   }
   53 
   54 private:
   55 
   56   // Disable copying and assignment.
   57 
   58   OwnerHeader (const OwnerHeader&);
   59   OwnerHeader& operator=(const OwnerHeader&);
   60 
   61   /// The owner of this superblock.
   62   HeapType * _owner;
   63 
   64   /// The preceding superblock in a linked list.
   65   SuperblockType * _prev;
   66 
   67   /// The succeeding superblock in a linked list.
   68   SuperblockType * _next;
   69 
   70 };
   71 
   72 #endif