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 * Contains class definition to generate Customer table.
40 */
41#ifndef CUSTOMER_TABLE_H
42#define CUSTOMER_TABLE_H
43
44#include "EGenTables_common.h"
45#include "input/DataFileManager.h"
46
47namespace TPCE {
48const int iNumEMAIL_DOMAINs = 6;
49
50class CCustomerTable : public TableTemplate<CUSTOMER_ROW> {
51private:
52 TIdent m_iRowsToGenerate; // total # of rows to generate
53 CPerson m_person;
54 const AreaCodeDataFile_t &m_Phones;
55 TIdent m_iStartFromCustomer;
56 TIdent m_iCustomerCount;
57 const StatusTypeDataFile_t &m_StatusTypeFile; // STATUS_TYPE table from the flat file
58 CCustomerSelection m_CustomerSelection;
59 TIdent m_iCompanyCount; // number of Companies
60 unsigned int m_iExchangeCount; // number of Exchanges
61
62 void GenerateC_ST_ID();
63 void GeneratePersonInfo(); // generate last name, first name, and gender.
64 void GenerateC_DOB();
65 void GenerateC_AD_ID();
66 void GenerateC_CTRY_1();
67 void GenerateC_LOCAL_1();
68 void GenerateC_AREA_1();
69 void GenerateC_EXT_1();
70 void GenerateC_CTRY_2();
71 void GenerateC_LOCAL_2();
72 void GenerateC_AREA_2();
73 void GenerateC_EXT_2();
74 void GenerateC_CTRY_3();
75 void GenerateC_LOCAL_3();
76 void GenerateC_AREA_3();
77 void GenerateC_EXT_3();
78 void GenerateC_EMAIL_1_and_C_EMAIL_2();
79
80 /*
81 * Reset the state for the next load unit
82 */
83 void InitNextLoadUnit();
84
85public:
86 /*
87 * Constructor for the CUSTOMER table class.
88 *
89 * PARAMETERS:
90 * IN dfm - input flat files loaded in memory
91 * IN iCustomerCount - number of customers to generate
92 * IN iStartFromCustomer - ordinal position of the first customer in
93 * the sequence (Note: 1-based)
94 */
95 CCustomerTable(const DataFileManager &dfm, TIdent iCustomerCount, TIdent iStartFromCustomer);
96
97 TIdent GenerateNextC_ID(); // generate C_ID and store state information;
98 // return false if all ids are generated
99 TIdent GetCurrentC_ID(); // return current customer id
100
101 void GetC_TAX_ID(TIdent C_ID,
102 char *szOutput); // return tax id (ala Social Security number)
103 eCustomerTier GetC_TIER(TIdent C_ID); // returns unique C_TIER for a given customer id
104
105 bool GenerateNextRecord(); // generates the next table row
106};
107
108} // namespace TPCE
109
110#endif // CUSTOMER_TABLE_H
111