| 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 | * Description: Implementation of the Company Competitor input file |
| 40 | * that scales with the database size. |
| 41 | ******************************************************************************/ |
| 42 | |
| 43 | #ifndef COMPANY_COMPETITOR_FILE_H |
| 44 | #define COMPANY_COMPETITOR_FILE_H |
| 45 | |
| 46 | #include <string> |
| 47 | #include "utilities/EGenStandardTypes.h" |
| 48 | #include "DataFileTypes.h" |
| 49 | |
| 50 | namespace TPCE { |
| 51 | |
| 52 | class CCompanyCompetitorFile { |
| 53 | CompanyCompetitorDataFile_t const *m_dataFile; |
| 54 | |
| 55 | // Configured and active number of companies in the database. |
| 56 | // Depends on the configured and active number of customers. |
| 57 | // |
| 58 | TIdent m_iConfiguredCompanyCompetitorCount; |
| 59 | TIdent m_iActiveCompanyCompetitorCount; |
| 60 | |
| 61 | // Number of base companies (=rows in Company.txt input file). |
| 62 | // |
| 63 | UINT m_iBaseCompanyCount; |
| 64 | |
| 65 | public: |
| 66 | /* |
| 67 | * Constructor. |
| 68 | * |
| 69 | * PARAMETERS: |
| 70 | * IN dataFile - CompanyCompetitorDataFile |
| 71 | * IN iConfiguredCustomerCount - total configured number of |
| 72 | * customers in the database IN iActiveCustomerCount - active number |
| 73 | * of customers in the database (provided for engineering purposes) |
| 74 | * |
| 75 | * RETURNS: |
| 76 | * not applicable. |
| 77 | */ |
| 78 | CCompanyCompetitorFile(const CompanyCompetitorDataFile_t &dataFile, TIdent iConfiguredCustomerCount, |
| 79 | TIdent iActiveCustomerCount, UINT baseCompanyCount); |
| 80 | |
| 81 | /* |
| 82 | * Calculate company competitor count for the specified number of |
| 83 | * customers. Sort of a static method. Used in parallel generation of |
| 84 | * company related tables. |
| 85 | * |
| 86 | * PARAMETERS: |
| 87 | * IN iCustomerCount - number of customers |
| 88 | * |
| 89 | * RETURNS: |
| 90 | * number of company competitors. |
| 91 | */ |
| 92 | TIdent CalculateCompanyCompetitorCount(TIdent iCustomerCount) const; |
| 93 | |
| 94 | /* |
| 95 | * Calculate the first company competitor id (0-based) for the specified |
| 96 | * customer id. |
| 97 | * |
| 98 | * PARAMETERS: |
| 99 | * IN iStartFromCustomer - customer id |
| 100 | * |
| 101 | * RETURNS: |
| 102 | * company competitor id. |
| 103 | */ |
| 104 | TIdent CalculateStartFromCompanyCompetitor(TIdent iStartFromCustomer) const; |
| 105 | |
| 106 | /* |
| 107 | * Return company id for the specified row. |
| 108 | * Index can exceed the size of the Company Competitor input file. |
| 109 | * |
| 110 | * PARAMETERS: |
| 111 | * IN iIndex - row number in the Company Competitor file |
| 112 | * (0-based) |
| 113 | * |
| 114 | * RETURNS: |
| 115 | * company id. |
| 116 | */ |
| 117 | TIdent GetCompanyId(TIdent iIndex) const; |
| 118 | |
| 119 | /* |
| 120 | * Return company competitor id for the specified row. |
| 121 | * Index can exceed the size of the Company Competitor input file. |
| 122 | * |
| 123 | * PARAMETERS: |
| 124 | * IN iIndex - row number in the Company Competitor file |
| 125 | * (0-based) |
| 126 | * |
| 127 | * RETURNS: |
| 128 | * company competitor id. |
| 129 | */ |
| 130 | TIdent GetCompanyCompetitorId(TIdent iIndex) const; |
| 131 | |
| 132 | /* |
| 133 | * Return industry id for the specified row. |
| 134 | * Index can exceed the size of the Company Competitor input file. |
| 135 | * |
| 136 | * PARAMETERS: |
| 137 | * IN iIndex - row number in the Company Competitor file |
| 138 | * (0-based) |
| 139 | * |
| 140 | * RETURNS: |
| 141 | * industry id. |
| 142 | */ |
| 143 | const std::string &GetIndustryId(TIdent iIndex) const; |
| 144 | const char *GetIndustryIdCSTR(TIdent iIndex) const; |
| 145 | |
| 146 | /* |
| 147 | * Return the number of company competitors in the database for |
| 148 | * the configured number of customers. |
| 149 | * |
| 150 | * PARAMETERS: |
| 151 | * none. |
| 152 | * |
| 153 | * RETURNS: |
| 154 | * configured company competitor count. |
| 155 | */ |
| 156 | TIdent GetConfiguredCompanyCompetitorCount() const; |
| 157 | |
| 158 | /* |
| 159 | * Return the number of company competitors in the database for |
| 160 | * the active number of customers. |
| 161 | * |
| 162 | * PARAMETERS: |
| 163 | * none. |
| 164 | * |
| 165 | * RETURNS: |
| 166 | * active company competitor count. |
| 167 | */ |
| 168 | TIdent GetActiveCompanyCompetitorCount() const; |
| 169 | |
| 170 | /* |
| 171 | * Overload GetRecord to wrap around indices that |
| 172 | * are larger than the flat file |
| 173 | * |
| 174 | * PARAMETERS: |
| 175 | * IN iIndex - row number in the Company Competitor file |
| 176 | * (0-based) |
| 177 | * |
| 178 | * RETURNS: |
| 179 | * reference to the row structure in the Company Competitor file. |
| 180 | */ |
| 181 | const CompanyCompetitorDataFileRecord &GetRecord(TIdent index) const; |
| 182 | }; |
| 183 | |
| 184 | } // namespace TPCE |
| 185 | |
| 186 | #endif // COMPANY_COMPETITOR_FILE_H |
| 187 | |