fintp_udal
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DatabaseProvider.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 DATABASEPROVIDER_H
22 #define DATABASEPROVIDER_H
23 
24 #include "ConnectionString.h"
25 #include "Database.h"
26 #include "DataColumn.h"
27 
28 #include <map>
29 using namespace std;
30 
34 namespace FinTP
35 {
41  {
42  protected :
43 
44  string m_Name;
45 
46  explicit DatabaseProviderFactory( const string& providername ) : m_Name( providername ) {}
47 
48  public :
49 
51 
56  virtual Database* createDatabase() = 0;
57 
64  virtual DataParameterBase* createParameter( DataType::DATA_TYPE paramType, DataParameterBase::PARAMETER_DIRECTION paramDirection ) = 0;
66  return createParameter( paramType, DataParameterBase::PARAM_IN );
67  }
68 
77  virtual DataColumnBase* createColumn( DataType::DATA_TYPE columnType, unsigned int dimension, int scale, const string& name ) = 0;
78  DataColumnBase* createColumn( DataType::DATA_TYPE columnType, unsigned int dimension, int scale ) {
79  return createColumn( columnType, dimension, scale, "" );
80  }
81 
86  string name() const {
87  return m_Name;
88  }
89 
95  virtual string getParamPlaceholder( const unsigned int i ) const = 0;
96 
102  virtual string getParamPlaceholder( const string& paramname ) const = 0;
103 
109  virtual string getTrimFunc( const string& value ) const = 0;
110  };
111 
116  {
117  public:
118 
119  typedef enum
120  {
121  None = 0,
122  DB2 = 1,
123  Oracle = 2,
124  Fox = 3,
125  Informix = 4,
126  SqlServer = 5,
127  Postgres = 6
128  } PROVIDER_TYPE;
129 
135  static DatabaseProviderFactory* GetFactory( const PROVIDER_TYPE& provider );
136 
142  static DatabaseProviderFactory* GetFactory( const string& provider );
143 
149  static PROVIDER_TYPE Parse( const string& providerName );
150 
156  static string ToString( PROVIDER_TYPE providerType );
157  };
158 }
159 
160 #endif // DATABASEPROVIDER_H