iLand
biteitem.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 BITEITEM_H
20#define BITEITEM_H
21
22#include "bite_global.h"
23#include "bitecell.h"
24#include <QObject>
25
26namespace ABE {
27class FMTreeList; // forward
28class FMSaplingList; // forward
29}
30
31namespace BITE {
32
33class BiteAgent;
34class BiteCell;
35
36class BiteItem : public QObject
37{
38 Q_OBJECT
39 Q_PROPERTY(QString name READ name WRITE setName)
40 Q_PROPERTY(BiteAgent* agent READ agent)
41public:
42 explicit BiteItem(QObject *parent = nullptr);
43 Q_INVOKABLE BiteItem(QJSValue obj);
44 BiteAgent *agent() const { return mAgent; }
45
46
47 virtual void setup(BiteAgent *agent);
48 virtual QString info();
49
51 bool runCells() const { return mRunCells; }
52
53 QString name() const {return mName; }
54 void setName(QString name) { mName = name; }
55
56 QString description() const {return mDescription; }
57
58
59 virtual void notify(BiteCell *cell, BiteCell::ENotification what);
60signals:
61
62public slots:
63 // actions
64 virtual void afterSetup();
65 virtual void beforeRun();
66 virtual void run();
67 virtual void runCell(BiteCell *cell, ABE::FMTreeList *treelist, ABE::FMSaplingList *saplist);
68
69protected:
70
71 int cellSize() const;
72 virtual QStringList allowedProperties();
73 void checkProperties(QJSValue obj);
74 QJSValue thisJSObj() { return mThis; }
75 QJSValue mObj;
76 QJSValue mThis;
77 void setRunCells(bool rc) { mRunCells = rc; }
78 bool verbose();
79private:
80 BiteAgent *mAgent;
81 QString mName;
82 QString mDescription;
83 bool mRunCells;
84
85};
86
87} // end namespace
88#endif // BITEITEM_H
Definition: fmsaplinglist.h:12
The FMTreeList class implements low-level functionality for selecting and harvesting of trees.
Definition: fmtreelist.h:34
Definition: biteagent.h:71
Definition: bitecell.h:38
ENotification
Definition: bitecell.h:71
Definition: biteitem.h:37
QString description() const
Definition: biteitem.h:56
void setName(QString name)
Definition: biteitem.h:54
QJSValue thisJSObj()
Definition: biteitem.h:74
bool verbose()
Definition: biteitem.cpp:113
void checkProperties(QJSValue obj)
Definition: biteitem.cpp:99
virtual QStringList allowedProperties()
Definition: biteitem.cpp:92
virtual void beforeRun()
for initializations, called every year
Definition: biteitem.cpp:68
bool runCells() const
true if the item runs cell by cell
Definition: biteitem.h:51
BiteItem(QObject *parent=nullptr)
Definition: biteitem.cpp:24
virtual QString info()
Definition: biteitem.cpp:52
virtual void runCell(BiteCell *cell, ABE::FMTreeList *treelist, ABE::FMSaplingList *saplist)
Definition: biteitem.cpp:78
virtual void run()
Definition: biteitem.cpp:73
QJSValue mObj
the JS value used to setup the item
Definition: biteitem.h:75
QJSValue mThis
the JS representation of the item
Definition: biteitem.h:76
virtual void setup(BiteAgent *agent)
Definition: biteitem.cpp:35
virtual void notify(BiteCell *cell, BiteCell::ENotification what)
Definition: biteitem.cpp:57
BiteAgent * agent() const
Definition: biteitem.h:44
QString name() const
Definition: biteitem.h:53
virtual void afterSetup()
called once after the full agent is set up
Definition: biteitem.cpp:63
BiteAgent * agent
Definition: biteitem.h:40
void setRunCells(bool rc)
Definition: biteitem.h:77
int cellSize() const
Definition: biteitem.cpp:86
QString name
Definition: biteitem.h:39
Definition: abegrid.h:22
Definition: biteagent.cpp:32