From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/a03000.html | 1089 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1089 insertions(+) create mode 100644 docs/doxygen/nel/a03000.html (limited to 'docs/doxygen/nel/a03000.html') diff --git a/docs/doxygen/nel/a03000.html b/docs/doxygen/nel/a03000.html new file mode 100644 index 00000000..01cc347f --- /dev/null +++ b/docs/doxygen/nel/a03000.html @@ -0,0 +1,1089 @@ + + +NeL: TemplateNLMISC::CObjectVector< T, EnableObjectBehavior > class Reference + + + +
+

NLMISC::CObjectVector< T, EnableObjectBehavior > Class Template Reference

#include <object_vector.h> +

+


Detailed Description

+

template<class T, bool EnableObjectBehavior = true>
+ class NLMISC::CObjectVector< T, EnableObjectBehavior >

+ +The purpose of this class is to copy most (but not all) of stl vector<> features, without some of the speed/memory problems involved: +

+Object contructors, destructors, operator= are correctly called, unless EnableObjectBehavior template argument is set to false (default is true) In this case: ctor, dtor are not called, and operator=() use memcpy.

+Of course some features are not implemented (for benefit of speed/memory):

+

+Also, for now, not all vector<> features are implemented (iterator, erase etc...).

+

Author:
Lionel Berenguier

+Nevrax France

+
Date:
2001
+ +

+ +

+Definition at line 77 of file object_vector.h. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Member Functions

Allocation
void clear ()
void resize (uint32 s)
Object
 CObjectVector (const CObjectVector &vec)
 CObjectVector ()
CObjectVectoroperator= (const CObjectVector &vec)
 ~CObjectVector ()
Tools
void copy (uint32 dstFirst, uint32 dstLast, const T *srcPtr)
void fill (const T &value)
void fill (uint32 dstFirst, uint32 dstLast, const T &value)
void serial (NLMISC::IStream &f)
Accessor
bool empty () const
T * getPtr () const
T & operator[] (uint index) const
uint32 size () const

Private Member Functions

void construct (uint32 i0, uint32 i1)
void destruct (uint32 i0, uint32 i1)
void myRealloc (uint32 s)

Private Attributes

T * _Ptr
 Ptr on our array.

uint32 _Size
 size of the array, in number of elements.

+


Constructor & Destructor Documentation

+

+ + + + +
+ + + + + + + + + + + + +
+template<class T, bool EnableObjectBehavior = true>
NLMISC::CObjectVector< T, EnableObjectBehavior >::CObjectVector  )  [inline]
+
+ + + + + +
+   + + +

+copy cons.

Exceptions:
+ + +
EReallocationFailed() if realloc fails.
+
+ +

+Definition at line 83 of file object_vector.h. +

+

00084         {
+00085                 _Ptr= NULL;
+00086                 _Size= 0;
+00087         }
+
+

+ + + + +
+ + + + + + + + + + + + +
+template<class T, bool EnableObjectBehavior = true>
NLMISC::CObjectVector< T, EnableObjectBehavior >::~CObjectVector  )  [inline]
+
+ + + + + +
+   + + +

+copy cons.

Exceptions:
+ + +
EReallocationFailed() if realloc fails.
+
+ +

+Definition at line 88 of file object_vector.h. +

+

00089         {
+00090                 clear();
+00091         }
+
+

+ + + + +
+ + + + + + + + + + + + + +
+template<class T, bool EnableObjectBehavior = true>
NLMISC::CObjectVector< T, EnableObjectBehavior >::CObjectVector const CObjectVector< T, EnableObjectBehavior > &  vec  )  [inline]
+
+ + + + + +
+   + + +

+copy cons.

Exceptions:
+ + +
EReallocationFailed() if realloc fails.
+
+ +

+Definition at line 95 of file object_vector.h. +

+

00096         {
+00097                 _Ptr= NULL;
+00098                 _Size= 0;
+00099                 operator=(vec);
+00100         }
+
+


Member Function Documentation

+

+ + + + +
+ + + + + + + + + + + + + +
+template<class T, bool EnableObjectBehavior = true>
void NLMISC::CObjectVector< T, EnableObjectBehavior >::clear void   )  [inline]
+
+ + + + + +
+   + + +

+clear the array. +

+Definition at line 124 of file object_vector.h. +

+Referenced by NLMISC::CObjectVector< sint8, false >::myRealloc(), NLMISC::CObjectVector< sint8, false >::resize(), NL3D::CSkeletonModel::updateSkinRenderLists(), and NLMISC::CObjectVector< sint8, false >::~CObjectVector(). +

+

00125         {
+00126                 destruct(0, _Size);
+00127 #ifndef NL_OV_USE_NEW_ALLOCATOR
+00128                 free(_Ptr);
+00129 #else // NL_OV_USE_NEW_ALLOCATOR
+00130                 if (_Ptr)
+00131                         delete [] (char*)_Ptr;
+00132 #endif // NL_OV_USE_NEW_ALLOCATOR
+00133                 _Ptr= NULL;
+00134                 _Size= 0;
+00135         }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + +
+template<class T, bool EnableObjectBehavior = true>
void NLMISC::CObjectVector< T, EnableObjectBehavior >::construct uint32  i0,
uint32  i1
[inline, private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 382 of file object_vector.h. +

+Referenced by NLMISC::CObjectVector< sint8, false >::resize(). +

+

00383         {
+00384                 // don't do it if elements don't need it.
+00385                 if(!EnableObjectBehavior)
+00386                         return;
+00387                 // for all elements
+00388                 for(uint i=i0;i<i1;i++)
+00389                 {
+00390 // Must do a placement new
+00391 #undef new
+00392                         // call ctor.
+00393                         new (_Ptr+i) T;
+00394 // Must do a placement new
+00395 #define new NL_NEW
+00396                 }
+00397         }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+template<class T, bool EnableObjectBehavior = true>
void NLMISC::CObjectVector< T, EnableObjectBehavior >::copy uint32  dstFirst,
uint32  dstLast,
const T *  srcPtr
[inline]
+
+ + + + + +
+   + + +

+copy elements from an array ptr to this vector, beetween dstFirst element (included) and dstLast element (not included). nlassert if last is too big. copy(y, x, ...) where y>=x is valid, and nothing is copied. +

+Definition at line 206 of file object_vector.h. +

+Referenced by NLMISC::CObjectVector< sint8, false >::operator=(). +

+

00207         {
+00208                 // test if something to copy.
+00209                 if(dstFirst>=dstLast)
+00210                         return;
+00211                 nlassert(dstLast<=_Size);
+00212                 // if not object elements
+00213                 if(!EnableObjectBehavior)
+00214                 {
+00215                         // just memcpy
+00216                         memcpy(_Ptr+dstFirst, srcPtr, (dstLast-dstFirst)*sizeof(T));
+00217                 }
+00218                 else
+00219                 {
+00220                         // call ope= for all elements.
+00221                         for(uint i=dstFirst; i<dstLast; i++, srcPtr++)
+00222                         {
+00223                                 _Ptr[i]= *srcPtr;
+00224                         }
+00225                 }
+00226         }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + +
+template<class T, bool EnableObjectBehavior = true>
void NLMISC::CObjectVector< T, EnableObjectBehavior >::destruct uint32  i0,
uint32  i1
[inline, private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 368 of file object_vector.h. +

+Referenced by NLMISC::CObjectVector< sint8, false >::clear(), and NLMISC::CObjectVector< sint8, false >::resize(). +

+

00369         {
+00370                 // don't do it if elements don't need it.
+00371                 if(!EnableObjectBehavior)
+00372                         return;
+00373                 // for all elements
+00374                 for(uint i=i0;i<i1;i++)
+00375                 {
+00376                         // call dtor.
+00377                         _Ptr[i].~T();
+00378                 }
+00379         }
+
+

+ + + + +
+ + + + + + + + + + + + +
+template<class T, bool EnableObjectBehavior = true>
bool NLMISC::CObjectVector< T, EnableObjectBehavior >::empty  )  const [inline]
+
+ + + + + +
+   + + +

+return true if the container is empty +

+Definition at line 180 of file object_vector.h. +

+

00180 {return _Size==0;}
+
+

+ + + + +
+ + + + + + + + + + + + + +
+template<class T, bool EnableObjectBehavior = true>
void NLMISC::CObjectVector< T, EnableObjectBehavior >::fill const T &  value  )  [inline]
+
+ + + + + +
+   + + +

+fill all elements with a value +

+Definition at line 246 of file object_vector.h. +

+

00247         {
+00248                 // call ope= for all elements.
+00249                 for(uint i=0; i<_Size; i++)
+00250                 {
+00251                         _Ptr[i]= value;
+00252                 }
+00253         }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+template<class T, bool EnableObjectBehavior = true>
void NLMISC::CObjectVector< T, EnableObjectBehavior >::fill uint32  dstFirst,
uint32  dstLast,
const T &  value
[inline]
+
+ + + + + +
+   + + +

+fill elements with a value, beetween dstFirst element (included) and dstLast element (not included). +

+Definition at line 231 of file object_vector.h. +

+

00232         {
+00233                 // test if something to copy.
+00234                 if(dstFirst>=dstLast)
+00235                         return;
+00236                 nlassert(dstLast<=_Size);
+00237                 // call ope= for all elements.
+00238                 for(uint i=dstFirst; i<dstLast; i++)
+00239                 {
+00240                         _Ptr[i]= value;
+00241                 }
+00242         }
+
+

+ + + + +
+ + + + + + + + + + + + +
+template<class T, bool EnableObjectBehavior = true>
T* NLMISC::CObjectVector< T, EnableObjectBehavior >::getPtr  )  const [inline]
+
+ + + + + +
+   + + +

+return a ptr on the first element of the array. NULL if empty. +

+Definition at line 195 of file object_vector.h. +

+Referenced by NL3D::CMeshMorpher::updateRawSkin(). +

+

00195 {return _Ptr;}
+
+

+ + + + +
+ + + + + + + + + + + + + +
+template<class T, bool EnableObjectBehavior = true>
void NLMISC::CObjectVector< T, EnableObjectBehavior >::myRealloc uint32  s  )  [inline, private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 328 of file object_vector.h. +

+Referenced by NLMISC::CObjectVector< sint8, false >::resize(). +

+

00329         {
+00330 #ifndef NL_OV_USE_NEW_ALLOCATOR
+00331                 // try to realloc the array.
+00332                 T       *newPtr= (T*)realloc(_Ptr, s*sizeof(T));
+00333 #else // NL_OV_USE_NEW_ALLOCATOR
+00334                 uint allocSize= s*sizeof(T);
+00335                 T       *newPtr= NULL;
+00336                 if (!_Ptr || (allocSize > _Size*sizeof(T)))
+00337                 {
+00338                         // Reallocate
+00339                         char *newblock = new char[allocSize];
+00340                         if (_Ptr)
+00341                         {
+00342                                 memcpy (newblock, _Ptr, _Size*sizeof(T));
+00343                                 delete [] (char*)_Ptr;
+00344                         }
+00345                         newPtr = (T*)newblock;
+00346                 }
+00347                 else
+00348                 {
+00349                         // Old block is big enough
+00350                         newPtr = _Ptr;
+00351                 }
+00352 #endif // NL_OV_USE_NEW_ALLOCATOR
+00353                 // if realloc failure
+00354                 if(newPtr==NULL)
+00355                 {
+00356                         // leave the array in a clean state.
+00357                         clear();
+00358                         // exception.
+00359                         throw EReallocationFailed();
+00360                 }
+00361                 else
+00362                 {
+00363                         _Ptr= newPtr;
+00364                 }
+00365         }
+
+

+ + + + +
+ + + + + + + + + + + + + +
+template<class T, bool EnableObjectBehavior = true>
CObjectVector& NLMISC::CObjectVector< T, EnableObjectBehavior >::operator= const CObjectVector< T, EnableObjectBehavior > &  vec  )  [inline]
+
+ + + + + +
+   + + +

+copy the array.

Exceptions:
+ + +
EReallocationFailed() if realloc fails.
+
+ +

+Definition at line 104 of file object_vector.h. +

+Referenced by NLMISC::CObjectVector< sint8, false >::CObjectVector(). +

+

00105         {
+00106                 // *this=*this mgt.
+00107                 if(this==&vec)
+00108                         return *this;
+00109                 // resize to the same size as vec.
+00110                 resize(vec._Size);
+00111                 // copy All the array.
+00112                 copy(0, _Size, vec._Ptr);
+00113 
+00114                 return *this;
+00115         }
+
+

+ + + + +
+ + + + + + + + + + + + + +
+template<class T, bool EnableObjectBehavior = true>
T& NLMISC::CObjectVector< T, EnableObjectBehavior >::operator[] uint  index  )  const [inline]
+
+ + + + + +
+   + + +

+Element accessor. no check is made on index. (No exception, no nlassert()) +

+Definition at line 188 of file object_vector.h. +

+

00189         {
+00190                 return _Ptr[index];
+00191         }
+
+

+ + + + +
+ + + + + + + + + + + + + +
+template<class T, bool EnableObjectBehavior = true>
void NLMISC::CObjectVector< T, EnableObjectBehavior >::resize uint32  s  )  [inline]
+
+ + + + + +
+   + + +

+resize the array. If reallocation occurs, ptr returned by getPtr() may not be the same. When reallocation occurs, memory is coped, but operator= are not called.

Exceptions:
+ + +
EReallocationFailed() if realloc fails.
+
+ +

+Definition at line 142 of file object_vector.h. +

+Referenced by NLMISC::CBitmap::alphaLuminanceToAlpha(), NLMISC::CBitmap::alphaLuminanceToLuminance(), NLMISC::CBitmap::alphaLuminanceToRGBA(), NLMISC::CBitmap::alphaToAlphaLuminance(), NLMISC::CBitmap::alphaToRGBA(), NLMISC::CBitmap::decompressDXT1(), NLMISC::CBitmap::decompressDXT3(), NLMISC::CBitmap::decompressDXT5(), NLMISC::CBitmap::luminanceToAlpha(), NLMISC::CBitmap::luminanceToAlphaLuminance(), NLMISC::CBitmap::luminanceToRGBA(), NLMISC::CObjectVector< sint8, false >::operator=(), NLMISC::CBitmap::resample(), NLMISC::CBitmap::rgbaToAlpha(), NLMISC::CBitmap::rgbaToAlphaLuminance(), NLMISC::CBitmap::rgbaToLuminance(), NLMISC::CBitmap::rot90CCW(), NLMISC::CBitmap::rot90CW(), NLMISC::CObjectVector< sint8, false >::serial(), and NL3D::CSkeletonModel::updateSkinRenderLists(). +

+

00143         {
+00144                 // if same size, no-op.
+00145                 if(s==_Size)
+00146                         return;
+00147 
+00148                 // if empty, just clear.
+00149                 if(s==0)
+00150                         clear();
+00151                 // crop the array?
+00152                 else if(s<_Size)
+00153                 {
+00154                         // destruct the objects to be freed
+00155                         destruct(s, _Size);
+00156                         // realloc
+00157                         myRealloc(s);
+00158                         _Size = s;
+00159                 }
+00160                 // else, enlarge the array
+00161                 else
+00162                 {
+00163                         // realloc first
+00164                         myRealloc(s);
+00165                         // For all new elements, construct them.
+00166                         construct(_Size, s);
+00167                         // change size.
+00168                         _Size= s;
+00169                 }
+00170         }
+
+

+ + + + +
+ + + + + + + + + + + + + +
+template<class T, bool EnableObjectBehavior = true>
void NLMISC::CObjectVector< T, EnableObjectBehavior >::serial NLMISC::IStream f  )  [inline]
+
+ + + + + +
+   + + +

+Serial this ObjectVector. NB: actually, the serial of a vector<> and the serial of a CObjectVector is the same in the stream. +

+Definition at line 260 of file object_vector.h. +

+

00261         {
+00262                 // Open a node header
+00263                 f.xmlPushBegin ("VECTOR");
+00264 
+00265                 // Attrib size
+00266                 f.xmlSetAttrib ("size");
+00267 
+00268                 sint32  len=0;
+00269                 if(f.isReading())
+00270                 {
+00271                         f.serial(len);
+00272 
+00273                         // Open a node header
+00274                         f.xmlPushEnd ();
+00275 
+00276                         // special version for vector: adjut good size.
+00277                         contReset(*this);
+00278                         resize (len);
+00279 
+00280                         // Read the vector
+00281                         for(sint i=0;i<len;i++)
+00282                         {
+00283                                 f.xmlPush ("ELM");
+00284 
+00285                                 f.serial(_Ptr[i]);
+00286 
+00287                                 f.xmlPop ();
+00288                         }
+00289                 }
+00290                 else
+00291                 {
+00292                         len= size();
+00293                         f.serial(len);
+00294 
+00295                         // Close the node header
+00296                         f.xmlPushEnd ();
+00297 
+00298                         // Write the vector
+00299                         for(sint i=0;i<len;i++)
+00300                         {
+00301                                 f.xmlPush ("ELM");
+00302 
+00303                                 f.serial(_Ptr[i]);
+00304 
+00305                                 f.xmlPop ();
+00306                         }
+00307                 }
+00308 
+00309                 // Close the node
+00310                 f.xmlPop ();
+00311         }
+
+

+ + + + +
+ + + + + + + + + + + + +
+template<class T, bool EnableObjectBehavior = true>
uint32 NLMISC::CObjectVector< T, EnableObjectBehavior >::size  )  const [inline]
+
+ + + + + +
+   + + +

+return size of the array (in number of elements) +

+Definition at line 184 of file object_vector.h. +

+Referenced by NLMISC::CBitmap::decompressDXT1(), NLMISC::CBitmap::decompressDXT3(), NLMISC::CBitmap::decompressDXT5(), NL3D::CSkeletonModel::renderShadowSkins(), NL3D::CSkeletonModel::renderSkinList(), NLMISC::CObjectVector< sint8, false >::serial(), and NL3D::CSkeletonModel::traverseAnimDetail(). +

+

00184 {return _Size;}
+
+


Field Documentation

+

+ + + + +
+ + + + + +
+template<class T, bool EnableObjectBehavior = true>
T* NLMISC::CObjectVector< T, EnableObjectBehavior >::_Ptr [private] +
+
+ + + + + +
+   + + +

+Ptr on our array. +

+ +

+Definition at line 321 of file object_vector.h. +

+Referenced by NLMISC::CObjectVector< sint8, false >::operator=().

+

+ + + + +
+ + + + + +
+template<class T, bool EnableObjectBehavior = true>
uint32 NLMISC::CObjectVector< T, EnableObjectBehavior >::_Size [private] +
+
+ + + + + +
+   + + +

+size of the array, in number of elements. +

+ +

+Definition at line 323 of file object_vector.h. +

+Referenced by NLMISC::CObjectVector< sint8, false >::operator=().

+


The documentation for this class was generated from the following file: +
Generated on Tue Mar 16 13:23:51 2004 for NeL by + +doxygen +1.3.6
+ + -- cgit v1.2.1