Subversion Repositories public iLand

Rev

Rev 1033 | Rev 1104 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1
 
1033 werner 2
/********************************************************************************************
3
**    iLand - an individual based forest landscape and disturbance model
4
**    http://iland.boku.ac.at
5
**    Copyright (C) 2009-  Werner Rammer, Rupert Seidl
6
**
7
**    This program is free software: you can redistribute it and/or modify
8
**    it under the terms of the GNU General Public License as published by
9
**    the Free Software Foundation, either version 3 of the License, or
10
**    (at your option) any later version.
11
**
12
**    This program is distributed in the hope that it will be useful,
13
**    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
**    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
**    GNU General Public License for more details.
16
**
17
**    You should have received a copy of the GNU General Public License
18
**    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
********************************************************************************************/
870 werner 20
#include "global.h"
908 werner 21
#include "abe_global.h"
870 werner 22
#include "actgeneral.h"
23
 
24
#include "fmstp.h"
25
#include "fmstand.h"
26
#include "fomescript.h"
27
 
907 werner 28
namespace ABE {
870 werner 29
 
1095 werner 30
/** @class ActGeneral
31
    @ingroup abe
32
    The ActGeneral class is an all-purpose activity and implements no specific forest management activity.
870 werner 33
 
1095 werner 34
  */
35
 
36
 
870 werner 37
QStringList ActGeneral::info()
38
{
39
    QStringList lines = Activity::info();
891 werner 40
    lines << "this is the 'general' activity; the activity is not scheduled. Use the action-slot to define what should happen.";
870 werner 41
    return lines;
42
}
43
 
44
void ActGeneral::setup(QJSValue value)
45
{
46
    Activity::setup(value);
47
    // specific
48
    mAction = FMSTP::valueFromJs(value, "action", "", "Activity of type 'general'.");
49
    if (!mAction.isCallable())
50
        throw IException("'general' activity has not a callable javascript 'action'.");
51
}
52
 
53
bool ActGeneral::execute(FMStand *stand)
54
{
55
    FomeScript::setExecutionContext(stand);
887 werner 56
    if (FMSTP::verbose() || stand->trace())
909 werner 57
        qCDebug(abe) << stand->context() << "activity 'general': execute of" << name();
887 werner 58
 
870 werner 59
    QJSValue result = mAction.call();
60
    if (result.isError()) {
891 werner 61
        throw IException(QString("%1 Javascript error in 'general' activity '%3': %2").arg(stand->context()).arg(result.toString()).arg(name()));
870 werner 62
    }
63
    return result.toBool();
64
}
65
 
66
 
67
} // namespace