00001 /* 00002 * This file is part of openMask © INRIA, CNRS, Universite de Rennes 1 1993-2002, thereinafter the Software 00003 * 00004 * The Software has been developped within the Siames Project. 00005 * INRIA, the University of Rennes 1 and CNRS jointly hold intellectual property rights 00006 * 00007 * The Software has been registered with the Agence pour la Protection des 00008 * Programmes (APP) under registration number IDDN.FR.001.510008.00.S.P.2001.000.4120 00009 * 00010 * This file may be distributed under the terms of the Q Public License 00011 * version 1.0 as defined by Trolltech AS of Norway and appearing in the file 00012 * LICENSE.QPL included in the packaging of this file. 00013 * 00014 * Licensees holding valid specific licenses issued by INRIA, CNRS or Université de Rennes 1 00015 * for the software may use this file in accordance with that specific license 00016 * 00017 */ 00018 #ifndef PsAllocatorHEADER 00019 #define PsAllocatorHEADER 00020 00021 #ifdef _SGI 00022 #include <stddef.h> 00023 #else 00024 #include <cstddef> 00025 #endif 00026 00028 template <typename T> class PsAllocatorT; 00029 00031 template<> 00032 class PsAllocatorT<void> { 00033 public: 00034 typedef void* pointer; 00035 typedef const void* const_pointer; 00036 typedef void value_type; 00037 00038 template <typename _Tp1> struct rebind { 00039 typedef PsAllocatorT<_Tp1> other; 00040 }; 00041 }; 00042 00044 template <typename T> 00045 class PsAllocatorT { 00046 public: 00047 typedef size_t size_type; 00048 typedef ptrdiff_t difference_type; 00049 typedef T * pointer; 00050 typedef const T* const_pointer; 00051 typedef T& reference; 00052 typedef const T & const_reference; 00053 typedef T value_type; 00054 00055 template <typename T1> struct rebind { 00056 typedef PsAllocatorT<T1> other; 00057 }; 00058 00062 PsAllocatorT () throw() { 00063 //cerr<<"PsAllocatorT"<<endl; 00064 } 00065 00066 00068 PsAllocatorT(const PsAllocatorT &) throw() { 00069 //cerr<<"PsAllocatorT(const PsAllocatorT &)"<<endl; 00070 } 00071 00072 00074 template <typename U> PsAllocatorT(const PsAllocatorT<U> &) throw() { 00075 //cerr<<"PsAllocatorT(const PsAllocatorT<U> &)"<<endl; 00076 } 00077 00078 00080 ~PsAllocatorT() throw() { 00081 //cerr<<"~PsAllocatorT()"<<endl; 00082 } 00084 00085 pointer address(reference x) const { 00086 return &x; 00087 } 00088 00089 const_pointer address(const_reference x) const { 00090 return &x; 00091 } 00092 00093 pointer allocate(size_type n, PsAllocatorT<void>::const_pointer hint = 0) { 00094 #ifdef _DEBUGALLOCATIONMOME 00095 cerr<<"PsAllocatorT::allocate"<<endl; 00096 #endif 00097 if(n<=0) { 00098 n=1; 00099 } 00100 pointer resul=(pointer)operator new(n*sizeof(T)); 00101 #ifdef _DEBUGALLOCATIONMOME 00102 cerr<<"PsAllocatorT::allocate returns "<<resul<<" of size "<<n*sizeof(T)<<endl; 00103 #endif 00104 return resul; 00105 } 00106 00107 void deallocate(pointer p, size_type n) { 00108 #ifdef _DEBUGALLOCATIONMOME 00109 cerr<<"PsAllocatorT::deallocate"<<endl; 00110 #endif 00111 operator delete ((void *)p); 00112 } 00113 00114 size_type max_size() const throw() { 00115 #ifdef _DEBUGALLOCATIONMOME 00116 cerr<<"PsAllocatorT::max_size"<<endl; 00117 #endif 00118 return 16374; 00119 } 00120 00121 void construct(pointer p, const T& val) { 00122 #ifdef _DEBUGALLOCATIONMOME 00123 cerr<<"PsAllocatorT::construct"<<endl; 00124 #endif 00125 return new((void *)p) T(val); 00126 }; 00127 00128 void destroy(pointer p) { 00129 #ifdef _DEBUGALLOCATIONMOME 00130 cerr<<"PsAllocatorT::destroy"<<endl; 00131 #endif 00132 ((T*)p)->~T() ; 00133 } 00134 }; 00135 00136 00137 00138 #endif 00139
| Documentation generated on Wed Jun 2 18:44:20 2004 |
Generated with doxygen 1.2.12 by Dimitri van Heesch , 1997-2001 |