Use configured resolution for login/outgame/ingame
[ryzomcore.git] / ryzom / tools / assoc_mem / cond_node.h
blob60a9aa7426c984ca0f6d8c21c973d0c1a9ef4b73
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
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.
8 //
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_
20 #include <iostream>
22 #include "field.h"
23 #include "node.h"
24 #include "record.h"
26 class ICondNode : public INode
28 protected:
29 int _Key;
30 CField *_Field;
31 std::vector<INode *> _Nodes;
32 public:
33 ICondNode();
34 ICondNode(CField *, int);
35 ~ICondNode();
37 void setKey(int);
38 void addNode(INode *);
41 template<class T> class CEqualNode : public ICondNode {
42 private:
43 std::vector<T> _Values;
44 public:
45 CEqualNode();
46 CEqualNode(CField *, int);
47 ~CEqualNode();
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();
68 int id_node = 0;
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 );
76 id_node++;
77 it_val++;
79 return false;
83 template<class T> class CInfNode : public ICondNode {
84 private:
85 T _Value;
86 public:
87 CInfNode();
88 ~CInfNode();
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 );
105 else
106 return _FalseNode->propagRecord( record );
109 template<class T> class CSupNode : public ICondNode {
110 private:
111 T _Value;
112 public:
113 CSupNode();
114 ~CSupNode();
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 );
131 else
132 return _FalseNode->propagRecord( record );
136 #endif