/** * @file has_tempgrids.hpp * @author Julian Iseringhausen * @date Tue Apr 5 21:00:56 2011 * * @brief Provides an arbitrary number of temporary grids, * accessible by an integer key. * */ #ifndef HAS_TEMPGRIDS_HPP_ #define HAS_TEMPGRIDS_HPP_ #include #include "grid/tempgrid.hpp" #include "mg.hpp" namespace VMG { class HasTempGrids { public: virtual ~HasTempGrids() { for (std::map::iterator iter = grids_1.begin(); iter != grids_1.end(); ++iter) delete iter->second; for (std::map::iterator iter = grids_2.begin(); iter != grids_2.end(); ++iter) delete iter->second; } protected: TempGrid* GetTempGrid(int key) { std::map::iterator iter = grids_1.find(key); if (iter == grids_1.end()) iter = grids_1.insert(std::pair(key, new TempGrid())).first; return iter->second; } TempGrid* GetTempGrid(const Grid* key) { std::map::iterator iter = grids_2.find(key); if (iter == grids_2.end()) iter = grids_2.insert(std::pair(key, new TempGrid())).first; return iter->second; } private: std::map grids_1; std::map grids_2; }; } #endif /* HAS_TEMPGRIDS_HPP_ */