forked from perabrahamsen/daisy-model
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action_merge.C
65 lines (59 loc) · 1.96 KB
/
action_merge.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// action_merge.C
//
// Copyright 1996-2001 Per Abrahamsen and Søren Hansen
// Copyright 2000-2001 KVL.
//
// This file is part of Daisy.
//
// Daisy is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// Daisy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser Public License for more details.
//
// You should have received a copy of the GNU Lesser Public License
// along with Daisy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#define BUILD_DLL
#include "action.h"
#include "block.h"
#include "daisy.h"
#include "field.h"
#include "librarian.h"
struct ActionMerge : public Action
{
const symbol combine;
const symbol remove;
void doIt (Daisy& daisy, const Scope&, Treelog& out)
{
out.message ("Merging " + remove + " into " + combine);
daisy.field->merge (combine, remove);
}
ActionMerge (Block& al)
: Action (al),
combine (al.identifier ("combine")),
remove (al.identifier ("remove"))
{ }
};
static struct ActionMergeSyntax : DeclareModel
{
Model* make (Block& al) const
{ return new ActionMerge (al); }
ActionMergeSyntax ()
: DeclareModel (Action::component, "merge", "\
Merge two columns. After the merge, only the first column will remain,\n\
but its state will be a average of the the columns, weighted after size.")
{ }
void load_frame (Frame& frame) const
{
frame.add ("combine", Syntax::String, Syntax::Const,
"Column to merge into.");
frame.add ("remove", Syntax::String, Syntax::Const,
"Column to remove after merge.");
frame.order ("combine", "remove");
}
} ActionMerge_syntax;