AFEPack
MPI_MemoryReclaimer.h
浏览该文件的文档。
00001 
00019 #ifndef __MPI_MemoryReclaimer_h__
00020 #define __MPI_MemoryReclaimer_h__
00021 
00022 #include <AFEPack/MemoryReclaimer.h>
00023 #include "MPI_HGeometry.h"
00024 
00025 namespace MPI {
00026 
00027   template <class HFOREST>
00028     class MemoryReclaimer : public ::MemoryReclaimer<HFOREST::dim,HFOREST::dow> {
00029   public:
00030     enum { dim = HFOREST::dim, dow = HFOREST::dow };
00031     typedef HFOREST forest_t;
00032     typedef ::MemoryReclaimer<dim,dow> base_t;
00033   public:
00034   MemoryReclaimer() : base_t() {}
00035   MemoryReclaimer(forest_t& tree) : base_t(tree) {}
00036     virtual ~MemoryReclaimer() {}
00037   private:
00038     template <int D> void
00039       reclaimHGeometry(HGeometry<D,dow> * p_geo) const {
00040       dynamic_cast<forest_t *>(this->get_tree_ptr())->erase_shared_info(*p_geo);
00041       delete p_geo;
00042     }
00043     virtual void 
00044       reclaimHGeometry(void * p_geo, int D) const {
00045       switch (D) {
00046       case 0: this->reclaimHGeometry((HGeometry<0,dow> *)p_geo); break;
00047       case 1: this->reclaimHGeometry((HGeometry<1,dow> *)p_geo); break;
00048       case 2: this->reclaimHGeometry((HGeometry<2,dow> *)p_geo); break;
00049       case 3: this->reclaimHGeometry((HGeometry<3,dow> *)p_geo); break;
00050       }
00051     }
00052   };
00053 
00054 }
00055 
00056 #endif // __MPI_MemoryReclaimer_h__
00057