source: src/base/has_tempgrids.hpp@ 48b662

Last change on this file since 48b662 was 48b662, checked in by Olaf Lenz <olenz@…>, 14 years ago

Moved files in scafacos_fcs one level up.

git-svn-id: https://svn.version.fz-juelich.de/scafacos/trunk@847 5161e1c8-67bf-11de-9fd5-51895aff932f

  • Property mode set to 100644
File size: 984 bytes
Line 
1/**
2 * @file has_tempgrids.hpp
3 * @author Julian Iseringhausen <isering@ins.uni-bonn.de>
4 * @date Tue Apr 5 21:00:56 2011
5 *
6 * @brief Provides an arbitrary number of temporary grids,
7 * accessible by an integer key.
8 *
9 */
10
11#ifndef HAS_TEMPGRIDS_HPP_
12#define HAS_TEMPGRIDS_HPP_
13
14#include <map>
15
16#include "grid/tempgrid.hpp"
17#include "mg.hpp"
18
19namespace VMG
20{
21
22class HasTempGrids
23{
24public:
25 virtual ~HasTempGrids()
26 {
27 for (std::map<int, VMG::TempGrid*>::iterator iter = grids.begin(); iter != grids.end(); ++iter)
28 delete iter->second;
29 }
30
31protected:
32 VMG::TempGrid* GetTempGrid(int key)
33 {
34 std::map<int, VMG::TempGrid*>::iterator iter = grids.find(key);
35
36 if (iter != grids.end())
37 return iter->second;
38 else {
39 VMG::TempGrid* temp = new VMG::TempGrid();
40 grids.insert(std::pair<int,VMG::TempGrid*>(key, temp));
41 return temp;
42 }
43 }
44
45private:
46 std::map<int,VMG::TempGrid*> grids;
47};
48
49}
50
51#endif /* HAS_TEMPGRIDS_HPP_ */
Note: See TracBrowser for help on using the repository browser.