Subversion Repositories public iLand

Rev

Rev 1221 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1033 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
********************************************************************************************/
870 werner 19
#include "global.h"
908 werner 20
#include "abe_global.h"
870 werner 21
#include "actgeneral.h"
22
 
23
#include "fmstp.h"
24
#include "fmstand.h"
25
#include "fomescript.h"
26
 
907 werner 27
namespace ABE {
870 werner 28
 
1095 werner 29
/** @class ActGeneral
30
    @ingroup abe
31
    The ActGeneral class is an all-purpose activity and implements no specific forest management activity.
870 werner 32
 
1095 werner 33
  */
34
 
35
 
870 werner 36
QStringList ActGeneral::info()
37
{
38
    QStringList lines = Activity::info();
891 werner 39
    lines << "this is the 'general' activity; the activity is not scheduled. Use the action-slot to define what should happen.";
870 werner 40
    return lines;
41
}
42
 
43
void ActGeneral::setup(QJSValue value)
44
{
45
    Activity::setup(value);
46
    // specific
47
    mAction = FMSTP::valueFromJs(value, "action", "", "Activity of type 'general'.");
48
    if (!mAction.isCallable())
49
        throw IException("'general' activity has not a callable javascript 'action'.");
50
}
51
 
52
bool ActGeneral::execute(FMStand *stand)
53
{
54
    FomeScript::setExecutionContext(stand);
887 werner 55
    if (FMSTP::verbose() || stand->trace())
909 werner 56
        qCDebug(abe) << stand->context() << "activity 'general': execute of" << name();
887 werner 57
 
870 werner 58
    QJSValue result = mAction.call();
59
    if (result.isError()) {
891 werner 60
        throw IException(QString("%1 Javascript error in 'general' activity '%3': %2").arg(stand->context()).arg(result.toString()).arg(name()));
870 werner 61
    }
62
    return result.toBool();
63
}
64
 
65
 
66
} // namespace