Rev 1221 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
677 | werner | 1 | /******************************************************************************************** |
2 | ** iLand - an individual based forest landscape and disturbance model |
||
3 | ** http://iland.boku.ac.at |
||
4 | ** Copyright (C) 2009- Werner Rammer, Rupert Seidl |
||
5 | ** |
||
6 | ** This program is free software: you can redistribute it and/or modify |
||
7 | ** it under the terms of the GNU General Public License as published by |
||
8 | ** the Free Software Foundation, either version 3 of the License, or |
||
9 | ** (at your option) any later version. |
||
10 | ** |
||
11 | ** This program is distributed in the hope that it will be useful, |
||
12 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
13 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
14 | ** GNU General Public License for more details. |
||
15 | ** |
||
16 | ** You should have received a copy of the GNU General Public License |
||
17 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. |
||
18 | ********************************************************************************************/ |
||
19 | #ifndef SNAPSHOT_H |
||
20 | #define SNAPSHOT_H |
||
21 | |||
22 | #include <QString> |
||
1045 | werner | 23 | #include <QHash> |
1213 | werner | 24 | /** @class Snapshot provides a way to save/load the current state of the model to a database. |
25 | * A snapshot contains trees, saplings, snags and soil (carbon/nitrogen pools), i.e. a |
||
26 | * snapshot allows to replicate all state variables of a landscape system. |
||
27 | */ |
||
28 | class ResourceUnit; // forward |
||
29 | class MapGrid; // forward |
||
677 | werner | 30 | class Snapshot |
31 | { |
||
32 | public: |
||
33 | Snapshot(); |
||
34 | bool createSnapshot(const QString &file_name); |
||
35 | bool loadSnapshot(const QString &file_name); |
||
1213 | werner | 36 | // snapshot functions for single stands |
37 | /// save the trees/saplings from a single stand (given by 'stand_id' and 'stand_grid' to a database in 'file_name' |
||
38 | bool saveStandSnapshot(const int stand_id, const MapGrid *stand_grid, const QString &file_name); |
||
39 | /// load the trees/saplings from a single stand (given by 'stand_id' and 'stand_grid' from a database in 'file_name' |
||
40 | bool loadStandSnapshot(const int stand_id, const MapGrid *stand_grid, const QString &file_name); |
||
677 | werner | 41 | private: |
42 | bool openDatabase(const QString &file_name, const bool read); |
||
1213 | werner | 43 | bool openStandDatabase(const QString &file_name, bool read); |
677 | werner | 44 | void saveTrees(); |
45 | void saveSoil(); |
||
46 | void saveSnags(); |
||
695 | werner | 47 | void saveSaplings(); |
677 | werner | 48 | void loadTrees(); |
49 | void loadSoil(); |
||
50 | void loadSnags(); |
||
695 | werner | 51 | void loadSaplings(); |
1117 | werner | 52 | void loadSaplingsOld(); |
1045 | werner | 53 | QHash<int, ResourceUnit* > mRUHash; |
677 | werner | 54 | }; |
55 | |||
56 | #endif // SNAPSHOT_H |