| Rev | Line | |
|---|
| [48b662] | 1 | /**
|
|---|
| 2 | * @file has_tempgrids.hpp
|
|---|
| 3 | * @author Julian Iseringhausen <isering@ins.uni-bonn.de>
|
|---|
| 4 | * @date Tue Apr 5 21:00:56 2011
|
|---|
| [dfed1c] | 5 | *
|
|---|
| [48b662] | 6 | * @brief Provides an arbitrary number of temporary grids,
|
|---|
| 7 | * accessible by an integer key.
|
|---|
| [dfed1c] | 8 | *
|
|---|
| [48b662] | 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 |
|
|---|
| 19 | namespace VMG
|
|---|
| 20 | {
|
|---|
| 21 |
|
|---|
| 22 | class HasTempGrids
|
|---|
| 23 | {
|
|---|
| 24 | public:
|
|---|
| 25 | virtual ~HasTempGrids()
|
|---|
| 26 | {
|
|---|
| [dfed1c] | 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)
|
|---|
| [48b662] | 31 | delete iter->second;
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | protected:
|
|---|
| [dfed1c] | 35 | TempGrid* GetTempGrid(int key)
|
|---|
| [48b662] | 36 | {
|
|---|
| [dfed1c] | 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;
|
|---|
| [48b662] | 53 | }
|
|---|
| 54 |
|
|---|
| 55 | private:
|
|---|
| [dfed1c] | 56 | std::map<int, TempGrid*> grids_1;
|
|---|
| 57 | std::map<const Grid*, TempGrid*> grids_2;
|
|---|
| [48b662] | 58 | };
|
|---|
| 59 |
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 | #endif /* HAS_TEMPGRIDS_HPP_ */
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.