Merge branch 'fixes' into main/rendor-staging
[ryzomcore.git] / nel / src / gui / interface_expr_node.cpp
blob802414f258363e8d4b7198f389fed2c74203a5eb
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
6 //
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
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 Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "stdpch.h"
22 #include "nel/misc/cdb_leaf.h"
23 #include "nel/misc/cdb_branch.h"
24 #include "nel/gui/interface_expr_node.h"
26 using NLMISC::ICDBNode;
27 using NLMISC::CCDBNodeBranch;
28 using NLMISC::CCDBNodeLeaf;
30 #ifdef DEBUG_NEW
31 #define new DEBUG_NEW
32 #endif
34 namespace NLGUI
37 // *******************************************************************************************************
38 void CInterfaceExprNodeValue::eval(CInterfaceExprValue &result)
40 result = Value;
43 void CInterfaceExprNodeValue::evalWithDepends(CInterfaceExprValue &result, std::vector<ICDBNode *> &/* nodes */)
45 result = Value;
48 void CInterfaceExprNodeValue::getDepends(std::vector<ICDBNode *> &/* nodes */)
53 // *******************************************************************************************************
54 void CInterfaceExprNodeValueFnCall::eval(CInterfaceExprValue &result)
56 nlassert(Func);
57 uint numParams = (uint)Params.size();
58 std::vector<CInterfaceExprValue> params(numParams);
59 for(uint k = 0; k < numParams; ++k)
61 Params[k]->eval(params[k]);
63 Func(params, result); // do actual call
66 void CInterfaceExprNodeValueFnCall::evalWithDepends(CInterfaceExprValue &result, std::vector<ICDBNode *> &nodes)
68 nlassert(Func);
69 uint numParams = (uint)Params.size();
70 std::vector<CInterfaceExprValue> params(numParams);
71 for(uint k = 0; k < numParams; ++k)
73 Params[k]->evalWithDepends(params[k], nodes);
75 Func(params, result); // do actual call
78 void CInterfaceExprNodeValueFnCall::getDepends(std::vector<ICDBNode *> &nodes)
80 uint numParams = (uint)Params.size();
81 for(uint k = 0; k < numParams; ++k)
83 Params[k]->getDepends(nodes);
88 CInterfaceExprNodeValueFnCall::~CInterfaceExprNodeValueFnCall()
90 for(uint k = 0; k < Params.size(); ++k)
92 delete Params[k];
96 // *******************************************************************************************************
97 void CInterfaceExprNodeDBLeaf::eval(CInterfaceExprValue &result)
99 nlassert(Leaf);
100 result.setInteger(Leaf->getValue64());
103 void CInterfaceExprNodeDBLeaf::evalWithDepends(CInterfaceExprValue &result,std::vector<ICDBNode *> &nodes)
105 nlassert(Leaf);
106 result.setInteger(Leaf->getValue64());
107 if (std::find(nodes.begin(), nodes.end(), Leaf) == nodes.end())
109 nodes.push_back(Leaf);
113 void CInterfaceExprNodeDBLeaf::getDepends(std::vector<ICDBNode *> &nodes)
115 nlassert(Leaf);
116 if (std::find(nodes.begin(), nodes.end(), Leaf) == nodes.end())
118 nodes.push_back(Leaf);
123 // *******************************************************************************************************
124 void CInterfaceExprNodeDBBranch::eval(CInterfaceExprValue &result)
126 nlassert(Branch);
127 result.setInteger(0);
130 void CInterfaceExprNodeDBBranch::evalWithDepends(CInterfaceExprValue &result,std::vector<ICDBNode *> &nodes)
132 nlassert(Branch);
133 result.setInteger(0);
134 if (std::find(nodes.begin(), nodes.end(), Branch) == nodes.end())
136 nodes.push_back(Branch);
140 void CInterfaceExprNodeDBBranch::getDepends(std::vector<ICDBNode *> &nodes)
142 nlassert(Branch);
143 if (std::find(nodes.begin(), nodes.end(), Branch) == nodes.end())
145 nodes.push_back(Branch);
150 // *******************************************************************************************************
151 void CInterfaceExprNodeDependantDBRead::eval(CInterfaceExprValue &result)
153 // no gain there, but barely used
154 CInterfaceExpr::eval(Expr, result);
157 void CInterfaceExprNodeDependantDBRead::evalWithDepends(CInterfaceExprValue &result, std::vector<ICDBNode *> &nodes)
159 CInterfaceExpr::eval(Expr, result, &nodes);
162 void CInterfaceExprNodeDependantDBRead::getDepends(std::vector<ICDBNode *> &nodes)
164 CInterfaceExprValue dummyResult;
165 CInterfaceExpr::eval(Expr, dummyResult, &nodes, true);