1 //
2 // aegis - project change supervisor
3 // Copyright (C) 2007, 2008 Peter Miller
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program. If not, see
17 // <http://www.gnu.org/licenses/>.
18 //
19
20 #include <common/trace.h>
21
22 #include <libaegis/sub/functor/variable.h>
23
24
~sub_functor_variable()25 sub_functor_variable::~sub_functor_variable()
26 {
27 trace(("%s\n", __PRETTY_FUNCTION__));
28 }
29
30
sub_functor_variable(const nstring & a_name,const nstring & a_value)31 sub_functor_variable::sub_functor_variable(const nstring &a_name,
32 const nstring &a_value) :
33 sub_functor(a_name),
34 value(a_value),
35 used(false),
36 append_if_unused_flag(false),
37 override_flag(false),
38 resubstitute_flag(false)
39 {
40 trace(("%s\n", __PRETTY_FUNCTION__));
41 }
42
43
44 sub_functor::pointer
create(const nstring & a_name,const nstring & a_value)45 sub_functor_variable::create(const nstring &a_name, const nstring &a_value)
46 {
47 trace(("%s\n", __PRETTY_FUNCTION__));
48 return pointer(new sub_functor_variable(a_name, a_value));
49 }
50
51
52 wstring
evaluate(sub_context_ty *,const wstring_list &)53 sub_functor_variable::evaluate(sub_context_ty *, const wstring_list &)
54 {
55 trace(("%s\n", __PRETTY_FUNCTION__));
56 used = true;
57 return value;
58 }
59
60
61 bool
append_if_unused() const62 sub_functor_variable::append_if_unused()
63 const
64 {
65 trace(("%s\n", __PRETTY_FUNCTION__));
66 return append_if_unused_flag;
67 }
68
69
70 void
append_if_unused_set()71 sub_functor_variable::append_if_unused_set()
72 {
73 trace(("%s\n", __PRETTY_FUNCTION__));
74 append_if_unused_flag = true;
75 }
76
77
78 bool
override() const79 sub_functor_variable::override()
80 const
81 {
82 trace(("%s\n", __PRETTY_FUNCTION__));
83 return override_flag;
84 }
85
86
87 void
override_set()88 sub_functor_variable::override_set()
89 {
90 trace(("%s\n", __PRETTY_FUNCTION__));
91 override_flag = true;
92 }
93
94
95 bool
resubstitute() const96 sub_functor_variable::resubstitute()
97 const
98 {
99 trace(("%s\n", __PRETTY_FUNCTION__));
100 return resubstitute_flag;
101 }
102
103
104 void
resubstitute_set()105 sub_functor_variable::resubstitute_set()
106 {
107 trace(("%s\n", __PRETTY_FUNCTION__));
108 resubstitute_flag = true;
109 }
110
111
112 bool
must_be_used() const113 sub_functor_variable::must_be_used()
114 const
115 {
116 trace(("%s\n", __PRETTY_FUNCTION__));
117 return !used;
118 }
119
120
121 void
optional_set()122 sub_functor_variable::optional_set()
123 {
124 trace(("%s\n", __PRETTY_FUNCTION__));
125 used = true;
126 }
127