| 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 |
|
|---|
| 19 | namespace VMG
|
|---|
| 20 | {
|
|---|
| 21 |
|
|---|
| 22 | class HasTempGrids
|
|---|
| 23 | {
|
|---|
| 24 | public:
|
|---|
| 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 |
|
|---|
| 31 | protected:
|
|---|
| 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 |
|
|---|
| 45 | private:
|
|---|
| 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.