fintp_base
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RoutingKeyword.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 ROUTINGKEYWORDS_H
22 #define ROUTINGKEYWORDS_H
23 
24 #include <map>
25 #include <vector>
26 #include <string>
27 
28 #include "DllMain.h"
29 
31 
32 typedef map< string, RoutingKeyword > RoutingKeywordCollection;
33 typedef map< string, map< string, string > > RoutingKeywordMappings;
34 typedef map< string, bool > RoutingIsoMessageTypes;
35 
37 {
38  public :
39 
40  typedef enum
41  {
44  DATE
45  } EVALUATOR_TYPE;
46 
47 
48  RoutingKeyword::EVALUATOR_TYPE parseType( const string& value );
49 
50  // ctor
52  RoutingKeyword( const string& name, const string& comparer, const string& regex, const string& regexIso );
53  ~RoutingKeyword();
54 
55  // evaluates a field from a value
56  pair< string, EVALUATOR_TYPE > Evaluate( const string& value, const string& field, bool iso = false );
57  //EVALUATOR_TYPE operator[]( const string& field );
58 
59  string getRegex() const { return m_Regex; }
60  void setRegex( const string& value ) { m_Regex = value; }
61 
62  string getRegexIso() const { return m_RegexIso; }
63  void setRegexIso( const string& value ) { m_RegexIso = value; }
64 
65  // pretty print
66  void Dump();
67 
68  private :
69 
70  string m_Regex, m_RegexIso;
71  string m_Name;
72  vector< pair< string, EVALUATOR_TYPE > > m_Fields;
73  vector< pair< string, EVALUATOR_TYPE > > m_FieldsIso;
74 };
75 
76 class KeywordMappingNotFound : public logic_error
77 {
78  private :
80 
81  public:
82  KeywordMappingNotFound( const string& keyword, const string& messageType ):
83  logic_error( "Unable to map keyword to a message type" ), m_MessageType( messageType ), m_Keyword( keyword )
84  {}
86 
87  string getMessageType() const { return m_MessageType; }
88  string getKeyword() const { return m_Keyword; }
89 };
90 
92 {
93  private :
94  // for each keyword we have a collection of < MT, tag >
96 
97  static void DeleteCollections( void* data );
98 
99  public:
100 
101  static pthread_once_t NotFoundKeysCreate;
102  static pthread_key_t NotFoundKey;
103 
106  static void CreateKeys();
107 };
108 #endif // ROUTINGKEYWORDS_H