00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __CS_GARRAY_H__
00021 #define __CS_GARRAY_H__
00022
00023 #include "csutil/array.h"
00024
00039 template <class T>
00040 class csDirtyAccessArray : public csArray<T>
00041 {
00042 private:
00043 int RefCount;
00044
00045 public:
00050 csDirtyAccessArray (int ilimit = 0, int ithreshold = 0)
00051 : csArray<T> (ilimit, ithreshold)
00052 {
00053 RefCount = 0;
00054 }
00055
00056
00057 void IncRef () { RefCount++; }
00058
00059
00060 void DecRef ()
00061 {
00062 if (RefCount == 1) { DeleteAll (); }
00063 RefCount--;
00064 }
00065
00067 T* GetArray ()
00068 {
00069 if (Length () > 0)
00070 return &Get (0);
00071 else
00072 return 0;
00073 }
00074
00076 const T* GetArray () const
00077 {
00078 if (Length () > 0)
00079 return &Get (0);
00080 else
00081 return 0;
00082 }
00083
00089 T* GetArrayCopy ()
00090 {
00091 if (Length () > 0)
00092 {
00093 T* copy = new T [Length ()];
00094 memcpy (copy, &Get (0), sizeof (T) * Length ());
00095 return copy;
00096 }
00097 else
00098 return 0;
00099 }
00100 };
00101
00102 #endif // __CS_GARRAY_H__
00103