Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __CS_NOBJVEC_H__
00021 #define __CS_NOBJVEC_H__
00022
00023
00024
00025
00026
00027
00028
00029 #include "csextern.h"
00030 #include "csutil/refarr.h"
00031 #include "csutil/weakrefarr.h"
00032 #include "iutil/object.h"
00033
00038
00039
00040 #include "csutil/deprecated_warn_off.h"
00041
00051 template <class T,
00052 class Allocator = CS::Container::ArrayAllocDefault,
00053 class CapacityHandler = CS::Container::ArrayCapacityDefault>
00054 class csRefArrayObject : public csRefArray<T, Allocator, CapacityHandler>
00055 {
00056 public:
00057 csRefArrayObject (int ilimit = 0,
00058 const CapacityHandler& ch = CapacityHandler())
00059 : csRefArray<T, Allocator, CapacityHandler> (ilimit, ch)
00060 {
00061 }
00062
00063 size_t GetIndexByName (const char* name) const
00064 {
00065 size_t i;
00066 for (i = 0 ; i < this->GetSize () ; i++)
00067 {
00068 T* o = (*this)[i];
00069 const char* n = o->QueryObject ()->GetName ();
00070 if (n && !strcmp (n, name))
00071 return i;
00072 }
00073 return csArrayItemNotFound;
00074 }
00075
00076 T* FindByName (const char* name) const
00077 {
00078 size_t i = GetIndexByName (name);
00079 if (i != csArrayItemNotFound)
00080 return (*this)[i];
00081 else
00082 return 0;
00083 }
00084 };
00085
00094 template <class T>
00095 class csWeakRefArrayObject : public csWeakRefArray<T>
00096 {
00097 public:
00098 csWeakRefArrayObject (int ilimit = 0, int ithreshold = 0)
00099 : csWeakRefArray<T> (ilimit, ithreshold)
00100 {
00101 }
00102
00103 size_t GetIndexByName (const char* name) const
00104 {
00105 size_t i;
00106 for (i = 0 ; i < this->GetSize () ; i++)
00107 {
00108 T* o = (*this)[i];
00109 const char* n = o->QueryObject ()->GetName ();
00110 if (n && !strcmp (n, name))
00111 return i;
00112 }
00113 return csArrayItemNotFound;
00114 }
00115
00116 T* FindByName (const char* name) const
00117 {
00118 size_t i = GetIndexByName (name);
00119 if (i != csArrayItemNotFound)
00120 return (*this)[i];
00121 else
00122 return 0;
00123 }
00124 };
00125
00128 #include "csutil/deprecated_warn_on.h"
00129
00130 #endif // __CS_NOBJVEC_H__