1/*
2 * Legal Notice
3 *
4 * This document and associated source code (the "Work") is a part of a
5 * benchmark specification maintained by the TPC.
6 *
7 * The TPC reserves all right, title, and interest to the Work as provided
8 * under U.S. and international laws, including without limitation all patent
9 * and trademark rights therein.
10 *
11 * No Warranty
12 *
13 * 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION
14 * CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE
15 * AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER
16 * WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
17 * INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES,
18 * DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR
19 * PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF
20 * WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE.
21 * ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
22 * QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT
23 * WITH REGARD TO THE WORK.
24 * 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO
25 * ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE
26 * COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS
27 * OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT,
28 * INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY,
29 * OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT
30 * RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD
31 * ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.
32 *
33 * Contributors
34 * - Sergey Vasilevskiy
35 * - Doug Johnson
36 */
37
38/*
39 * Flat file loader class factory.
40 * This class instantiates particular table loader classes.
41 */
42#ifndef FLAT_LOADER_FACTORY_H
43#define FLAT_LOADER_FACTORY_H
44
45#include <cstring>
46
47#include "FlatFileLoad_stdafx.h"
48
49namespace TPCE {
50
51class CFlatLoaderFactory : public CBaseLoaderFactory {
52 char m_szOutDir[iMaxPath];
53 char m_szFullFileName[iMaxPath];
54 FlatFileOutputModes m_eOutputMode; // overwrite/append
55
56 void SetFileName(const char *szFileName) {
57 snprintf(m_szFullFileName, sizeof(m_szFullFileName), "%s%s", m_szOutDir, szFileName);
58 }
59
60public:
61 // Constructor
62 CFlatLoaderFactory(char *szOutDir, FlatFileOutputModes eOutputMode) : m_eOutputMode(eOutputMode) {
63 assert(szOutDir);
64
65 strncpy(m_szOutDir, szOutDir, sizeof(m_szOutDir));
66 };
67
68 // Functions to create loader classes for individual tables.
69
70 virtual CBaseLoader<ACCOUNT_PERMISSION_ROW> *CreateAccountPermissionLoader() {
71 SetFileName("AccountPermission.txt");
72
73 return new CFlatAccountPermissionLoad(m_szFullFileName, m_eOutputMode);
74 };
75 virtual CBaseLoader<ADDRESS_ROW> *CreateAddressLoader() {
76 SetFileName("Address.txt");
77
78 return new CFlatAddressLoad(m_szFullFileName, m_eOutputMode);
79 };
80 virtual CBaseLoader<BROKER_ROW> *CreateBrokerLoader() {
81 SetFileName("Broker.txt");
82
83 return new CFlatBrokerLoad(m_szFullFileName, m_eOutputMode);
84 };
85 virtual CBaseLoader<CASH_TRANSACTION_ROW> *CreateCashTransactionLoader() {
86 SetFileName("CashTransaction.txt");
87
88 return new CFlatCashTransactionLoad(m_szFullFileName, m_eOutputMode);
89 };
90 virtual CBaseLoader<CHARGE_ROW> *CreateChargeLoader() {
91 SetFileName("Charge.txt");
92
93 return new CFlatChargeLoad(m_szFullFileName, m_eOutputMode);
94 };
95
96 virtual CBaseLoader<COMMISSION_RATE_ROW> *CreateCommissionRateLoader() {
97 SetFileName("CommissionRate.txt");
98
99 return new CFlatCommissionRateLoad(m_szFullFileName, m_eOutputMode);
100 };
101
102 virtual CBaseLoader<COMPANY_COMPETITOR_ROW> *CreateCompanyCompetitorLoader() {
103 SetFileName("CompanyCompetitor.txt");
104
105 return new CFlatCompanyCompetitorLoad(m_szFullFileName, m_eOutputMode);
106 };
107
108 virtual CBaseLoader<COMPANY_ROW> *CreateCompanyLoader() {
109 SetFileName("Company.txt");
110
111 return new CFlatCompanyLoad(m_szFullFileName, m_eOutputMode);
112 };
113
114 virtual CBaseLoader<CUSTOMER_ACCOUNT_ROW> *CreateCustomerAccountLoader() {
115 SetFileName("CustomerAccount.txt");
116
117 return new CFlatCustomerAccountLoad(m_szFullFileName, m_eOutputMode);
118 };
119
120 virtual CBaseLoader<CUSTOMER_ROW> *CreateCustomerLoader() {
121 SetFileName("Customer.txt");
122
123 return new CFlatCustomerLoad(m_szFullFileName, m_eOutputMode);
124 };
125 virtual CBaseLoader<CUSTOMER_TAXRATE_ROW> *CreateCustomerTaxrateLoader() {
126 SetFileName("CustomerTaxrate.txt");
127
128 return new CFlatCustomerTaxrateLoad(m_szFullFileName, m_eOutputMode);
129 };
130 virtual CBaseLoader<DAILY_MARKET_ROW> *CreateDailyMarketLoader() {
131 SetFileName("DailyMarket.txt");
132
133 return new CFlatDailyMarketLoad(m_szFullFileName, m_eOutputMode);
134 };
135 virtual CBaseLoader<EXCHANGE_ROW> *CreateExchangeLoader() {
136 SetFileName("Exchange.txt");
137
138 return new CFlatExchangeLoad(m_szFullFileName, m_eOutputMode);
139 };
140 virtual CBaseLoader<FINANCIAL_ROW> *CreateFinancialLoader() {
141 SetFileName("Financial.txt");
142
143 return new CFlatFinancialLoad(m_szFullFileName, m_eOutputMode);
144 };
145 virtual CBaseLoader<HOLDING_ROW> *CreateHoldingLoader() {
146 SetFileName("Holding.txt");
147
148 return new CFlatHoldingLoad(m_szFullFileName, m_eOutputMode);
149 };
150 virtual CBaseLoader<HOLDING_HISTORY_ROW> *CreateHoldingHistoryLoader() {
151 SetFileName("HoldingHistory.txt");
152
153 return new CFlatHoldingHistoryLoad(m_szFullFileName, m_eOutputMode);
154 };
155 virtual CBaseLoader<HOLDING_SUMMARY_ROW> *CreateHoldingSummaryLoader() {
156 SetFileName("HoldingSummary.txt");
157
158 return new CFlatHoldingSummaryLoad(m_szFullFileName, m_eOutputMode);
159 };
160 virtual CBaseLoader<INDUSTRY_ROW> *CreateIndustryLoader() {
161 SetFileName("Industry.txt");
162
163 return new CFlatIndustryLoad(m_szFullFileName, m_eOutputMode);
164 };
165 virtual CBaseLoader<LAST_TRADE_ROW> *CreateLastTradeLoader() {
166 SetFileName("LastTrade.txt");
167
168 return new CFlatLastTradeLoad(m_szFullFileName, m_eOutputMode);
169 };
170 virtual CBaseLoader<NEWS_ITEM_ROW> *CreateNewsItemLoader() {
171 SetFileName("NewsItem.txt");
172
173 return new CFlatNewsItemLoad(m_szFullFileName, m_eOutputMode);
174 };
175 virtual CBaseLoader<NEWS_XREF_ROW> *CreateNewsXRefLoader() {
176 SetFileName("NewsXRef.txt");
177
178 return new CFlatNewsXRefLoad(m_szFullFileName, m_eOutputMode);
179 };
180 virtual CBaseLoader<SECTOR_ROW> *CreateSectorLoader() {
181 SetFileName("Sector.txt");
182
183 return new CFlatSectorLoad(m_szFullFileName, m_eOutputMode);
184 };
185 virtual CBaseLoader<SECURITY_ROW> *CreateSecurityLoader() {
186 SetFileName("Security.txt");
187
188 return new CFlatSecurityLoad(m_szFullFileName, m_eOutputMode);
189 };
190 virtual CBaseLoader<SETTLEMENT_ROW> *CreateSettlementLoader() {
191 SetFileName("Settlement.txt");
192
193 return new CFlatSettlementLoad(m_szFullFileName, m_eOutputMode);
194 };
195 virtual CBaseLoader<STATUS_TYPE_ROW> *CreateStatusTypeLoader() {
196 SetFileName("StatusType.txt");
197
198 return new CFlatStatusTypeLoad(m_szFullFileName, m_eOutputMode);
199 };
200 virtual CBaseLoader<TAX_RATE_ROW> *CreateTaxRateLoader() {
201 SetFileName("TaxRate.txt");
202
203 return new CFlatTaxRateLoad(m_szFullFileName, m_eOutputMode);
204 };
205 virtual CBaseLoader<TRADE_HISTORY_ROW> *CreateTradeHistoryLoader() {
206 SetFileName("TradeHistory.txt");
207
208 return new CFlatTradeHistoryLoad(m_szFullFileName, m_eOutputMode);
209 };
210 virtual CBaseLoader<TRADE_ROW> *CreateTradeLoader() {
211 SetFileName("Trade.txt");
212
213 return new CFlatTradeLoad(m_szFullFileName, m_eOutputMode);
214 };
215 virtual CBaseLoader<TRADE_REQUEST_ROW> *CreateTradeRequestLoader() {
216 SetFileName("TradeRequest.txt");
217
218 return new CFlatTradeRequestLoad(m_szFullFileName, m_eOutputMode);
219 };
220 virtual CBaseLoader<TRADE_TYPE_ROW> *CreateTradeTypeLoader() {
221 SetFileName("TradeType.txt");
222
223 return new CFlatTradeTypeLoad(m_szFullFileName, m_eOutputMode);
224 };
225 virtual CBaseLoader<WATCH_ITEM_ROW> *CreateWatchItemLoader() {
226 SetFileName("WatchItem.txt");
227
228 return new CFlatWatchItemLoad(m_szFullFileName, m_eOutputMode);
229 };
230
231 virtual CBaseLoader<WATCH_LIST_ROW> *CreateWatchListLoader() {
232 SetFileName("WatchList.txt");
233
234 return new CFlatWatchListLoad(m_szFullFileName, m_eOutputMode);
235 };
236
237 virtual CBaseLoader<ZIP_CODE_ROW> *CreateZipCodeLoader() {
238 SetFileName("ZipCode.txt");
239
240 return new CFlatZipCodeLoad(m_szFullFileName, m_eOutputMode);
241 };
242};
243
244} // namespace TPCE
245
246#endif // FLAT_LOADER_FACTORY_H
247