AutoArray.h

Go to the documentation of this file.
00001 #ifndef __AUTO_ARRAY_H
00002 #define __AUTO_ARRAY_H
00003 
00004 #include <esg/AutoPtr.h>
00005 #include <set>
00006 
00007 namespace esg {
00008 
00009 #define INSTANTIATE_AUTOARRAY_STATIC_MEMBERS(T) \
00010       template<> std::set<AutoArray<T>*> AutoArray<T>::_repos = \
00011             std::set<AutoArray<T>*>();
00012 
00024 template <class T> class OGSCENE_EXPORT AutoArray : public AutoPtr<T> {
00025 protected:
00026         static std::set<AutoArray<T>*> _repos; 
00027 
00028 protected:
00029     //    AutoArray<T> (const AutoArray<T>&);
00030 
00031         ~AutoArray<T> () {
00032             if (AutoPtr<T>::_pObject) {
00033                 delete [] AutoPtr<T>::_pObject;
00034                 AutoPtr<T>::_pObject = NULL;
00035             }
00036             if (AutoPtr<T>::_ref.size()) {
00037                 fprintf(stderr,"AutoArray Error: Have registered references\n");
00038                 AutoPtr<T>::_ref.clear();
00039             }
00040         }
00041     
00042 public:
00046         AutoArray<T>(T * t) : AutoPtr<T>(t) {}
00047 
00057         static bool destroy (AutoArray<T>* pA,void* pR) {
00058             if (pA && pR) {
00059                 pA->_unregister(pR);
00060                 if (!pA->hasReferer()) {
00061                     _repos.erase(pA);
00062                     delete pA;
00063                     return true;
00064                 }
00065             }
00066             return false;
00067         }
00068 };
00069 
00070 }; // namespace
00071 
00072 #endif // __AUTO_ARRAY_H

Generated on Wed Jun 28 12:24:28 2006 for esg by  doxygen 1.4.6