6#if !defined(AFX_ELEMENTARRAY_H__04DC4B96_93F6_11D2_A1B6_000000000000__INCLUDED_)
7#define AFX_ELEMENTARRAY_H__04DC4B96_93F6_11D2_A1B6_000000000000__INCLUDED_
13#include "InstanciatedObject.h"
15BEGIN_MOOTOOLS_NAMESPACE
17typedef unsigned int ElementType;
47 virtual SIZET GetSizeof()
const = 0;
48 virtual ElementType GetType()
const = 0;
49 virtual ElementType GetBaseType()
const = 0;
50 virtual void ConstructElement(
void*
pNewData) = 0;
51 virtual void DestructElement(
void*
pNewData);
52 virtual void CopyElement(
void*
pDest,
const void*
pSrc);
56 virtual CXRuntimeClassPtr GetRuntimeClassDescriptor()
const { XASSERT(0);
return NULL; };
60 virtual void Dump(
const void *data)
const;
77 GROW_DOUBLE_SIZE = -2,
86 ElementType GetBaseTypeOfElement()
const;
87 ElementType GetTypeOfElement()
const;
88 SIZET GetSizeOfElement()
const;
108 int GetUpperBound()
const;
109 virtual void RemoveAll();
111 void *ElementAt(
int nIndex);
112 const void *ElementAt(
int nIndex)
const;
113 const void *GetFirst()
const;
114 const void *GetNext(
const void *
ptrObject)
const;
119 void *operator[](
int nIndex);
120 const void *operator[](
int nIndex)
const;
137 void Dump(
int index)
const;
146 unsigned char *buffer;
150 int growElementCount;
153 void InitElement(
SIZET);
158 #pragma warning(push)
159 #pragma warning(disable: 4995)
169 void CopyElements(
unsigned char *
pDest,
const unsigned char *
pSrc,
int nCount);
172inline int CElementArray::GetSize()
const
177inline int CElementArray::GetUpperBound()
const
179 return elementCount - 1;
184 if (
nIndex < elementCount)
185 CopyElements((buffer + (
nIndex*sizeofElement)), (
unsigned char *)
newElement, 1);
188inline void *CElementArray::ElementAt(
int nIndex)
190 if (
nIndex < elementCount)
191 return (
void *)(buffer + (
nIndex*sizeofElement));
197inline const void *CElementArray::ElementAt(
int nIndex)
const
199 if (
nIndex < elementCount)
200 return (
const void *)(buffer + (
nIndex*sizeofElement));
206inline const void *CElementArray::GetFirst()
const
208 return (
const void *)buffer;
211inline const void *CElementArray::GetNext(
const void *
ptrObject)
const
213 return (
const void *)(((
unsigned char *)
ptrObject) + sizeofElement);
216inline void *CElementArray::GetFirst()
218 return (
void *)buffer;
221inline void *CElementArray::GetNext(
void *
ptrObject)
223 return (
void *)(((
unsigned char *)
ptrObject) + sizeofElement);
228 int nIndex = elementCount;
238 if (
nIndex >= elementCount)
241 CopyElements((buffer + (
nIndex*sizeofElement)), (
const unsigned char *)
newElement, 1);
244inline void *CElementArray::operator[](
int nIndex)
246 if (
nIndex < elementCount)
247 return (
void *)(buffer + (
nIndex*sizeofElement));
253inline const void *CElementArray::operator[](
int nIndex)
const
255 if (
nIndex < elementCount)
256 return (
const void *)(buffer + (
nIndex*sizeofElement));
262inline void CElementArray::CopyElements(
unsigned char *
pDest,
const unsigned char *
pSrc,
int nCount)
266 XASSERT(
pDest >= buffer);
267 XASSERT((SIZET)(((
pDest - buffer) / sizeofElement)*sizeofElement) == (SIZET)(
pDest - buffer));
273 XASSERT(sizeofElement > 0);
277 pElementMethods->CopyElement(
pDest,
pSrc);
278 pDest += sizeofElement;
279 pSrc += sizeofElement;
283END_MOOTOOLS_NAMESPACE
The class defines an x, y, z 3D point which can use int, float or double.
Definition 3DPoint.h:27
An advanced array class containing data that needs to be construct / destruct.
Definition ElementArray.h:69
void ConstructMode(bool constructAllOnce)
virtual void SetSize(int nNewSize, bool growOnly=false, int nGrowBy=GROW_KEEP_MODE)
unsigned int GetChecksum() const
Return a checksum value made by bitwise operator that is a simple way to check if content changed bet...
CElementArray(CElementMethods *methods)
Create an array. methods can be set to NULL when serializing (CElementMethods are created on the fly)...
void PreAllocate(int estimatedSize)
GrowMode
Definition ElementArray.h:74
CElementMethods is provided to CElementArray and give some information on the data as well as the met...
Definition ElementArray.h:22
virtual bool IsKindOf(const CElementMethods *methods) const
For class we if this->GetBaseType() == B->GetType() that means that this knows how to copy from B.
virtual bool IsObject() const
Definition InstanciatedObject.h:16