fintp_routingengine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RoutingPlan.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 ROUTINGPLAN_H
22 #define ROUTINGPLAN_H
23 
24 #include "RoutingRule.h"
25 #include "RoutingStructures.h"
26 
27 /*
28 Eligible rules for a plan :
29 - no condition on message / function condition from start to end
30 
31 A RoutingPlan is defined by :
32 - start queue, end queue
33 - start message seq, end message seq
34 - routing actions in between
35 - conditions
36 */
38 {
39  private :
40 
43 
44  vector< RoutingRule > m_Rules;
45 
46  vector< RoutingCondition > m_ForkConditions;
47  vector< RoutingCondition > m_FailConditions;
48  vector< RoutingCondition > m_SuccessConditions;
49 
51 
53 
55  string m_Name;
56 
57  public:
58 
59  RoutingPlan( const long startQueue, const long endQueue, const long startSeq, const long endSeq, const string& name = "unnamed" );
60  ~RoutingPlan( void );
61 
62  long startQueue() const { return m_StartQueue; }
63  long endQueue() const { return m_EndQueue; }
64 
65  void setEndQueue( const long eQueue ) { m_EndQueue = eQueue; }
66 
67  void setExitpoint( const RoutingExitpoint& exitpoint ) { m_Exitpoint = exitpoint; }
68  const RoutingExitpoint& getExitpoint() const { return m_Exitpoint; }
69 
70  void setTerminal( const bool value ) { m_IsTerminal = value; }
71  const bool isTerminal() const { return m_IsTerminal; }
72 
73  unsigned long size() const { return m_Rules.size(); }
74  const vector< RoutingRule >& getRules() const { return m_Rules; }
75 
76  void addRule( const RoutingRule& rule ) { m_Rules.push_back( rule ); }
77 
78  void setForkConditions( const vector< RoutingCondition >& conditions );
79  const vector< RoutingCondition >& getForkConditions() const { return m_ForkConditions; }
80 
83 
84  const string name() const { return m_Name; }
85  void setName( const string& planname ) { m_Name = planname; }
86 
87  // combines conditions and flattens branches with plansize = 0
88  RoutingPlan* normalize( const string& name );
89  RoutingPlan* normalizeRules( const string& name );
90  void normalizeConditions( RoutingPlan* plan ) const;
91  const bool normalized() const { return m_IsNormalized; }
92 
93  void displayNested( const unsigned level );
94  void displayNormalized( const unsigned level );
95  void display( const unsigned int level );
96 
97  bool usable( RoutingMessage * message ) const;
99 };
100 
101 #endif //ROUTINGPLAN_H