source: src/base/has_tempgrids.hpp@ 759a6a

Last change on this file since 759a6a was dfed1c, checked in by Julian Iseringhausen <isering@…>, 14 years ago

Major vmg update.

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

  • Property mode set to 100644
File size: 1.3 KB
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, TempGrid*>::iterator iter = grids_1.begin(); iter != grids_1.end(); ++iter)
28 delete iter->second;
29
30 for (std::map<const Grid*, TempGrid*>::iterator iter = grids_2.begin(); iter != grids_2.end(); ++iter)
31 delete iter->second;
32 }
33
34protected:
35 TempGrid* GetTempGrid(int key)
36 {
37 std::map<int, TempGrid*>::iterator iter = grids_1.find(key);
38
39 if (iter == grids_1.end())
40 iter = grids_1.insert(std::pair<int, TempGrid*>(key, new TempGrid())).first;
41
42 return iter->second;
43 }
44
45 TempGrid* GetTempGrid(const Grid* key)
46 {
47 std::map<const Grid*, TempGrid*>::iterator iter = grids_2.find(key);
48
49 if (iter == grids_2.end())
50 iter = grids_2.insert(std::pair<const Grid*, TempGrid*>(key, new TempGrid())).first;
51
52 return iter->second;
53 }
54
55private:
56 std::map<int, TempGrid*> grids_1;
57 std::map<const Grid*, TempGrid*> grids_2;
58};
59
60}
61
62#endif /* HAS_TEMPGRIDS_HPP_ */
Note: See TracBrowser for help on using the repository browser.