iLand
bitewrapper.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 BITEWRAPPER_H
20#define BITEWRAPPER_H
21
22#include "expressionwrapper.h"
23#include "grid.h"
24#include <QStringList>
25#include <QVector>
26
27namespace BITE {
28class BiteCell;
29
31{
32public:
33 BiteWrapperCore() { buildVarList(); }
35
37 void registerGridVar(Grid<double> *grid, QString var_name);
38 void registerClimateVar(int var_index, QString var_name);
39
40 virtual const QStringList getVariablesList();
41 double valueCell(const int variableIndex, const BiteCell* cell);
42 void setValueCell(const int variableIndex, const BiteCell* cell, double new_value);
43
45 Grid<double> *grid(QString var_name);
46
47private:
48 enum EVarType { VarDoubleGrid, VarNone, VarClimate };
49 void buildVarList();
50 double valueActivity(const int variableIndex);
51 double valueStand(const int variableIndex);
52 double valueSite(const int variableIndex);
53 QStringList mVariables;
54 QVector< QPair<EVarType, void*> > mVarObj;
55};
56
58{
59public:
60 BiteWrapper(BiteWrapperCore *wrap, BiteCell *cell=nullptr): mWrap(wrap), mCell(cell) {}
61 void setCell(BiteCell *cell) {mCell = cell; }
62
63 virtual const QStringList getVariablesList() { return mWrap->getVariablesList();}
64 virtual double value(const int variableIndex) { return mWrap->valueCell(variableIndex, mCell); }
65 void setValue(const int variableIndex, double new_value) { mWrap->setValueCell(variableIndex, mCell, new_value); }
66private:
67 BiteWrapperCore *mWrap;
68 const BiteCell *mCell;
69
70
71};
72
73} // end namespace
74
75#endif // BITEWRAPPER_H
Definition: bitecell.h:38
Definition: bitewrapper.h:31
double valueCell(const int variableIndex, const BiteCell *cell)
Definition: bitewrapper.cpp:62
BiteWrapperCore()
Definition: bitewrapper.h:33
void registerGridVar(Grid< double > *grid, QString var_name)
Definition: bitewrapper.cpp:39
virtual const QStringList getVariablesList()
Definition: bitewrapper.cpp:57
void setValueCell(const int variableIndex, const BiteCell *cell, double new_value)
Definition: bitewrapper.cpp:89
void registerClimateVar(int var_index, QString var_name)
Definition: bitewrapper.cpp:48
~BiteWrapperCore()
Definition: bitewrapper.cpp:30
Grid< double > * grid(QString var_name)
returns the grid for variable 'var_name' or nullptr
Definition: bitewrapper.cpp:118
Definition: bitewrapper.h:58
BiteWrapper(BiteWrapperCore *wrap, BiteCell *cell=nullptr)
Definition: bitewrapper.h:60
virtual double value(const int variableIndex)
Definition: bitewrapper.h:64
void setCell(BiteCell *cell)
Definition: bitewrapper.h:61
void setValue(const int variableIndex, double new_value)
Definition: bitewrapper.h:65
virtual const QStringList getVariablesList()
Definition: bitewrapper.h:63
ExpressionWrapper is the base class for exposing C++ elements to the built-in Expression engine.
Definition: expressionwrapper.h:27
virtual int variableIndex(const QString &variableName)
Definition: expressionwrapper.cpp:66
Grid class (template).
Definition: grid.h:44
Definition: biteagent.cpp:32