Eneboo - Documentación para desarrolladores
|
00001 // -*- C++ -*- 00002 00003 #ifndef _BASEHOARDMANAGER_H_ 00004 #define _BASEHOARDMANAGER_H_ 00005 00012 #include "sassert.h" 00013 00014 template <class SuperblockType_> 00015 class BaseHoardManager { 00016 public: 00017 00018 BaseHoardManager (void) 00019 : _magic (0xedded00d) 00020 {} 00021 00022 virtual ~BaseHoardManager (void) 00023 {} 00024 00025 inline int isValid (void) const { 00026 return (_magic == 0xedded00d); 00027 } 00028 00029 // Export the superblock type. 00030 typedef SuperblockType_ SuperblockType; 00031 00033 inline virtual void free (void *) {} 00034 00036 inline virtual void lock (void) {} 00037 00039 inline virtual void unlock (void) {}; 00040 00042 static inline size_t getSize (void * ptr) { 00043 SuperblockType * s = getSuperblock (ptr); 00044 assert (s->isValidSuperblock()); 00045 return s->getSize (ptr); 00046 } 00047 00050 00051 static inline SuperblockType * getSuperblock (void * ptr) { 00052 return SuperblockType::getSuperblock (ptr); 00053 } 00054 00055 private: 00056 00057 enum { SuperblockSize = sizeof(SuperblockType) }; 00058 00059 HL::sassert<((SuperblockSize & (SuperblockSize - 1)) == 0)> EnsureSuperblockSizeIsPowerOfTwo; 00060 00061 const unsigned long _magic; 00062 00063 }; 00064 00065 #endif