fintp_routingengine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RoutingEvaluators.h
Go to the documentation of this file.
1 /*
2 * FinTP - Financial Transactions Processing Application
3 * Copyright (C) 2013 Business Information Systems (Allevo) S.R.L.
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 <http://www.gnu.org/licenses/>
17 * or contact Allevo at : 031281 Bucuresti, 23C Calea Vitan, Romania,
18 * phone +40212554577, office@allevo.ro <mailto:office@allevo.ro>, www.allevo.ro.
19 */
20 
21 #ifndef ROUTINGEVALUATORS_H
22 #define ROUTINGEVALUATORS_H
23 
24 #include "RoutingMessage.h"
25 #include "RoutingKeyword.h"
26 #include "Currency.h"
27 
29 {
30  public :
31  typedef enum
32  {
34  EQUALITY, // ==
35  DIFF, // !=
36  IN_SET, // IN
37  GREATER, // >
38  LESS, // <
39  GREATER_EQ, // >=
40  LESS_EQ, // <=
42  } OPERATOR_TYPE;
43 
44  private :
45  string m_FirstOp;
47  string m_SecondOp;
48 
49  public :
50  //ctor
52  ExpressionEvaluator( const string& text );
53 
54  // accessors
55  string getFirstOp() const { return m_FirstOp; }
56  string getSecondOp() const { return m_SecondOp; }
57  OPERATOR_TYPE getOperator() const { return m_Operator; }
58 
59  // eval methods
60  bool EvaluateBool( const bool actualValue ) const;
61  bool EvaluateString( const string& actulValue ) const;
62  bool EvaluateDate( const string& actualValue ) const;
63  bool EvaluateCurrency( const string& actualValue ) const;
64 
65  bool Evaluate( const string& actualValue, const RoutingKeyword::EVALUATOR_TYPE evalType ) const;
66 };
67 
69 {
70  public :
71 
72  // datatype type
73  typedef enum
74  {
75  ALWAYS = 1,
76  MESSAGE = 2,
77  FUNCTION = 4,
78  METADATA = 8
79  } ROUTING_CONDITION;
80 
81  typedef enum
82  {
87  IS_REPLY
88  } SUPPORTED_FUNCTION_EVALS;
89 
90  typedef enum
91  {
92  MT,
97  FINCOPY
98  } SUPPORTED_MESSAGE_EVALS;
99 
100  typedef enum
101  {
107  REQUESTTYPE
108  } SUPPORTED_METADATA_EVALS;
109 
110  // returns a friendly name of the condition
111  static string ToString( const ROUTING_CONDITION type );
112  string ToString() const;
113 
114  // .ctor
115  RoutingCondition( const ROUTING_CONDITION conditionType, const string& text );
117 
118  // accessors
119  ROUTING_CONDITION getConditionType() const { return m_ConditionType; }
120 
121  // evaluate condition on a message
122  bool Eval( RoutingMessage& message ) const;
123 
124  // used by plans to evaluate if a condition must be fullfilled or not
125  const bool expectedResult() const { return m_ExpectedResult; }
126  void setExpectedResult( const bool result ) { m_ExpectedResult = result; }
127 
128  bool Validate( const string& options, RoutingMessage& message ) const;
129 
130  private :
131 
132  bool internalEvalMessage( RoutingMessage& message ) const;
133  bool internalEvalFunction( RoutingMessage& message ) const;
134  bool internalEvalMetadata( RoutingMessage& message ) const;
135 
137  string m_Text;
138 
140 
142  vector< string > m_EvalFunctionParams;
143 
147 };
148 
149 #endif