iLand
snapshot.h
Go to the documentation of this file.
1/********************************************************************************************
2** iLand - an individual based forest landscape and disturbance model
3** http://iland-model.org
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>
23#include <QHash>
24#include <QSqlQuery>
29class ResourceUnit; // forward
30class MapGrid; // forward
31class Snag; // forward
32class Soil; // forward
33
35{
36public:
37 Snapshot();
38 bool createSnapshot(const QString &file_name);
39 bool loadSnapshot(const QString &file_name);
40 // snapshot functions for single stands
42 bool saveStandSnapshot(const int stand_id, const MapGrid *stand_grid, const QString &file_name);
44 bool loadStandSnapshot(const int stand_id, const MapGrid *stand_grid, const QString &file_name);
46 bool saveStandCarbon(const int stand_id, QList<int> ru_ids, bool rid_mode);
48 bool loadStandCarbon();
49private:
50 bool openDatabase(const QString &file_name, const bool read);
51 bool openStandDatabase(const QString &file_name, bool read);
52 void saveTrees();
53 void saveSoil();
54 void saveSoilRU(QList<int> stand_ids, bool ridmode);
55 void saveSoilCore(ResourceUnit *ru, Soil *s, QSqlQuery &q);
56 void saveSnags();
57 void saveSnagRU(QList<int> stand_ids, bool ridmode);
58 void saveSnagCore(Snag *s, QSqlQuery &q);
59 void saveSaplings();
60 void loadTrees();
61 void loadSoil(QSqlDatabase db=QSqlDatabase());
62 void loadSnags(QSqlDatabase db=QSqlDatabase());
63 void loadSaplings();
64 void loadSaplingsOld();
65 QHash<int, ResourceUnit* > mRUHash;
66};
67
68#endif // SNAPSHOT_H
Definition: mapgrid.h:32
ResourceUnit is the spatial unit that encapsulates a forest stand and links to several environmental ...
Definition: resourceunit.h:49
Snag deals with carbon / nitrogen fluxes from the forest until the reach soil pools.
Definition: snag.h:79
way to save/load the current state of the model to a database.
Definition: snapshot.h:35
bool loadStandSnapshot(const int stand_id, const MapGrid *stand_grid, const QString &file_name)
load the trees/saplings from a single stand (given by 'stand_id' and 'stand_grid' from a database in ...
Definition: snapshot.cpp:363
bool loadSnapshot(const QString &file_name)
Definition: snapshot.cpp:185
bool saveStandSnapshot(const int stand_id, const MapGrid *stand_grid, const QString &file_name)
save the trees/saplings from a single stand (given by 'stand_id' and 'stand_grid' to a database in 'f...
Definition: snapshot.cpp:255
bool saveStandCarbon(const int stand_id, QList< int > ru_ids, bool rid_mode)
save the carbon/snag pools of a set of resource units
Definition: snapshot.cpp:477
bool createSnapshot(const QString &file_name)
Definition: snapshot.cpp:151
bool loadStandCarbon()
load the carbon/snags pools from the current (stand) snapshot
Definition: snapshot.cpp:489
Snapshot()
Definition: snapshot.cpp:109
implementation of the ICBM/2N soil carbon and nitrogen dynamics model.
Definition: soil.h:29