1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifndef NL_COND_NODE_H_
18 #define NL_COND_NODE_H_
26 class ICondNode
: public INode
31 std::vector
<INode
*> _Nodes
;
34 ICondNode(CField
*, int);
38 void addNode(INode
*);
41 template<class T
> class CEqualNode
: public ICondNode
{
43 std::vector
<T
> _Values
;
46 CEqualNode(CField
*, int);
49 virtual bool propagRecord(CRecord
*);
52 template<class T
> CEqualNode
<T
>::CEqualNode() : ICondNode()
56 template<class T
> CEqualNode
<T
>::CEqualNode(CField
*field
, int key
) : ICondNode(field
, key
)
60 template<class T
> CEqualNode
<T
>::~CEqualNode()
64 template<class T
> bool CEqualNode
<T
>::propagRecord(CRecord
*record
)
66 std::vector
<IValue
*>::const_iterator it_val
= _Field
->getPossibleValues().begin();
67 std::vector
<IValue
*>::const_iterator it_end
= _Field
->getPossibleValues().end();
69 while ( it_val
!= it_end
)
71 if ( ( (CValue
<T
> *) (*record
)[ _Key
] )->getValue() == ( (CValue
<T
> *) (*it_val
))->getValue() )
73 std::cout
<< std::endl
<< "EQUAL_NODE (" << _Field
->getName() << _Key
<< " = " << ((CValue
<T
> *)(*it_val
))->getValue() << " ) -> Node " << id_node
<< std::endl
;
74 return _Nodes
[id_node
]->propagRecord( record
);
83 template<class T> class CInfNode : public ICondNode {
90 virtual bool propagRecord(CRecord *);
93 template<class T> CInfNode<T>::CInfNode() : ICondNode()
97 template<class T> CInfNode<T>::~CInfNode()
101 template<class T> bool CInfNode<T>::propagRecord(CRecord *record)
103 if ( ( (CValue<T> *) (*record)[ _Key ] )->getValue() <= _Value )
104 return _TrueNode->propagRecord( record );
106 return _FalseNode->propagRecord( record );
109 template<class T> class CSupNode : public ICondNode {
116 virtual bool propagRecord(CRecord *);
119 template<class T> CSupNode<T>::CSupNode() : ICondNode()
123 template<class T> CSupNode<T>::~CSupNode()
127 template<class T> bool CSupNode<T>::propagRecord(CRecord *record)
129 if ( ( (CValue<T> *) (*record)[ _Key ] )->getValue() >= _Value )
130 return _TrueNode->propagRecord( record );
132 return _FalseNode->propagRecord( record );