#include <array.h>
Inheritance diagram for mudbox::Array< type >:
Public Member Functions |
|
Array (const char *sName) | |
Array (const char *sName, unsigned int iSize) | |
Array (const char *sName, const type *pArray, int iSize) | |
Array (const char *sName, bool bNoObjects) | |
Array (const char *sName, const Array< type > &a) | |
void | Clear (bool bDestruct=false) |
Array< type > | Clone (void) const |
bool | Copy (Array< type > &a) const |
void | Set (unsigned int iStart, unsigned int iSize, unsigned char cPattern) |
bool | Extend (unsigned int iElementIndex) |
bool | Alloc (unsigned int iNewSize) |
type & | operator[] (int iIndex) |
type & | operator[] (unsigned int iIndex) |
const type & | operator[] (unsigned int iIndex) const |
type * | operator+ (unsigned int iIndex) |
type * | operator+ (int iIndex) |
void | operator= (const Array< type > &a) |
~Array (void) | |
virtual long long | MemoryUsage (void) const |
Protected Attributes |
|
type * | m_pArray |
unsigned int | m_iSize |
bool | m_bData |
const Array< type > * | m_pThis |
Friends |
|
class | Block |
|
|
00073 : Block( sName, sizeof(type) ) 00074 { 00075 m_bData = true; 00076 m_iSize = iSize; 00077 m_pArray = 0; 00078 try 00079 { 00080 if ( RegisterMemoryBlock( sizeof(type)*iSize ) ) 00081 { 00082 SetAllocatorID( sName ); 00083 m_pArray = new type[iSize]; 00084 SetAllocatorID( 0 ); 00085 } 00086 else 00087 throw &Error::s_cBadAlloc; 00088 } 00089 catch ( ... ) 00090 { 00091 LogAll(); 00092 throw &Error::s_cBadAlloc; 00093 }; 00094 m_pThis = this; 00095 }; |
|
00096 : Block( sName, sizeof(type) ) 00097 { 00098 m_bData = true; 00099 m_pArray = 0; 00100 try 00101 { 00102 if ( RegisterMemoryBlock( sizeof(type)*iSize ) ) 00103 { 00104 SetAllocatorID( sName ); 00105 m_pArray = new type[iSize]; 00106 SetAllocatorID( 0 ); 00107 } 00108 else 00109 Error::ThrowBadAlloc(); 00110 } 00111 catch ( ... ) 00112 { 00113 // probably std::bad_alloc 00114 LogAll(); 00115 throw &Error::s_cBadAlloc; 00116 }; 00117 if( !m_pArray ) 00118 return; 00119 00120 memcpy( m_pArray, pArray, sizeof(type)*iSize ); 00121 m_iSize = iSize; 00122 m_pThis = this; 00123 }; |
|
|
|
|
Reimplemented in mudbox::Store< type >, mudbox::Store< TC >, mudbox::Store< Attribute * >, mudbox::Store< Vector >, mudbox::Store< ChordLength >, mudbox::Store< float >, mudbox::Store< QString >, mudbox::Store< mudbox::Vector >, mudbox::Store< unsigned int >, mudbox::Store< VertexChange >, mudbox::Store< Vertex >, mudbox::Store< unsigned char >, and mudbox::Store< BrushConfiguration * >. 00141 { 00142 bDestruct = bDestruct; 00143 00144 if ( m_pArray ) 00145 { 00146 UnregisterMemoryBlock( (long long)(sizeof(type)*m_iSize) ); 00147 // if ( bDestruct ) 00148 delete [] m_pArray; 00149 // else 00150 // delete m_pArray; 00151 m_pArray = 0; 00152 }; 00153 m_iSize = 0; 00154 }; |
|
Reimplemented in mudbox::Store< type >, mudbox::Store< TC >, mudbox::Store< Attribute * >, mudbox::Store< Vector >, mudbox::Store< ChordLength >, mudbox::Store< float >, mudbox::Store< QString >, mudbox::Store< mudbox::Vector >, mudbox::Store< unsigned int >, mudbox::Store< VertexChange >, mudbox::Store< Vertex >, mudbox::Store< unsigned char >, and mudbox::Store< BrushConfiguration * >. 00155 { Array<type> a; Copy( a ); return a; }; |
|
00157 { 00158 if ( !a.Alloc( m_iSize ) ) 00159 return false; 00160 memcpy( a.m_pArray, m_pArray, sizeof(type)*a.m_iSize ); 00161 return true; 00162 }; |
|
|
Reimplemented in mudbox::Store< type >, mudbox::Store< TC >, mudbox::Store< Attribute * >, mudbox::Store< Vector >, mudbox::Store< ChordLength >, mudbox::Store< float >, mudbox::Store< QString >, mudbox::Store< mudbox::Vector >, mudbox::Store< unsigned int >, mudbox::Store< VertexChange >, mudbox::Store< Vertex >, mudbox::Store< unsigned char >, and mudbox::Store< BrushConfiguration * >. 00165 { 00166 if ( iElementIndex == 0xffffffff ) 00167 return true; 00168 unsigned int iNewSize = m_iSize; 00169 while ( iElementIndex >= iNewSize ) 00170 iNewSize = iNewSize*2+1; 00171 if( iNewSize > m_iSize ) 00172 return Alloc( iNewSize ); 00173 return true; 00174 }; |
|
00176 { 00177 if ( iNewSize == m_iSize ) 00178 return true; 00179 MB_ASSERT( m_pThis == this ); 00180 type *pNew = 0; 00181 try 00182 { 00183 if ( RegisterMemoryBlock( sizeof(type)*iNewSize ) ) 00184 { 00185 SetAllocatorID( m_sName ); 00186 pNew = new type[iNewSize]; 00187 SetAllocatorID( 0 ); 00188 } 00189 else 00190 throw &Error::s_cBadAlloc; 00191 } 00192 catch ( Error * ) 00193 { 00194 LogAll(); 00195 return false; 00196 } 00197 catch ( ... ) 00198 { 00199 // probably std::bad_alloc 00200 LogAll(); 00201 throw &Error::s_cBadAlloc; 00202 }; 00203 if( pNew == 0 ) 00204 return false; 00205 if( m_iSize ) 00206 { 00207 UnregisterMemoryBlock( sizeof(type)*m_iSize ); 00208 if ( m_bData ) 00209 CopyMemoryBlock( pNew, m_pArray, Min( iNewSize, m_iSize )*sizeof(type) ); 00210 else 00211 for ( unsigned int i = 0; i < Min( iNewSize, m_iSize ); i++ ) 00212 pNew[i] = m_pArray[i]; 00213 delete [] m_pArray; 00214 }; 00215 m_pArray = pNew; 00216 m_iSize = iNewSize; 00217 return true; 00218 }; |
|
|
|
|
Reimplemented in mudbox::Store< type >, mudbox::Store< TC >, mudbox::Store< Attribute * >, mudbox::Store< Vector >, mudbox::Store< ChordLength >, mudbox::Store< float >, mudbox::Store< QString >, mudbox::Store< mudbox::Vector >, mudbox::Store< unsigned int >, mudbox::Store< VertexChange >, mudbox::Store< Vertex >, mudbox::Store< unsigned char >, and mudbox::Store< BrushConfiguration * >. 00241 { MB_ASSERT( m_pThis == this ); return &operator[]( iIndex ); }; |
|
Reimplemented in mudbox::Store< type >, mudbox::Store< TC >, mudbox::Store< Attribute * >, mudbox::Store< Vector >, mudbox::Store< ChordLength >, mudbox::Store< float >, mudbox::Store< QString >, mudbox::Store< mudbox::Vector >, mudbox::Store< unsigned int >, mudbox::Store< VertexChange >, mudbox::Store< Vertex >, mudbox::Store< unsigned char >, and mudbox::Store< BrushConfiguration * >. 00242 { MB_ASSERT( m_pThis == this ); return &operator[]( iIndex ); }; |
|
|
00254 { return m_iSize*sizeof(type); }; |
|
|
|
|
|