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 * Base interface for all loader classes.
40 */
41
42#ifndef BASE_LOADER_H
43#define BASE_LOADER_H
44
45namespace TPCE {
46
47template <typename T> class CBaseLoader {
48
49public:
50 /*
51 * Virtual destructor. Provided so that a sponsor-specific
52 * destructor can be called on destruction from the base-class pointer.
53 *
54 * PARAMETERS:
55 * none.
56 *
57 * RETURNS:
58 * not applicable.
59 */
60 virtual ~CBaseLoader(){};
61
62 /*
63 * This function is provided to reset the loader to
64 * a clean state. "Clean state" here means a sequence of
65 * WriteNextRecord(), followed by Commit(), followed by FinishLoad()
66 * can be called.
67 *
68 * PARAMETERS:
69 * none.
70 *
71 * RETURNS:
72 * none.
73 */
74 virtual void Init(){}; // default implementation is empty
75
76 /*
77 * Receive a new record to be loaded into the database.
78 * This is the main function that is called
79 * for every generated record.
80 *
81 * Note: the records are not guaranteed to actually be inserted
82 * into the database after this call. It is Commit() that ensures that
83 * all records received by WriteNextRecord are persisted in the database.
84 *
85 * PARAMETERS:
86 * IN next_record - a pointer to a structure, containing
87 * the record
88 *
89 * RETURNS:
90 * none.
91 */
92 virtual void WriteNextRecord(const T &next_record) {
93 printf("BaseLoader - const ref\n");
94 };
95
96 /*
97 * Commit any records that might have been kept in temporary
98 * storage to the database. After this call, all records received
99 * by WriteNextRecord should be present in the database.
100 *
101 * PARAMETERS:
102 * none.
103 *
104 * RETURNS:
105 * none.
106 */
107 virtual void Commit(){}; // default implementation is empty
108
109 /*
110 * Release any resources held for loading.
111 * Also, commit any records that might have been kept in temporary
112 * storage to the database.
113 * This function is called once, after the last record has been loaded.
114 *
115 * PARAMETERS:
116 * none.
117 *
118 * RETURNS:
119 * none.
120 */
121 virtual void FinishLoad() = 0; // must be defined in subclasses
122};
123
124} // namespace TPCE
125
126#endif // #ifndef BASE_LOADER_H
127