BAM
Abstract Machine for Bottom-Up Evaluation with the Push Method
bench.h
Go to the documentation of this file.
1 // ============================================================================
2 // Project: Deductive Database
3 // Filename: bench.h
4 // Purpose: Superclass for Standard Benchmark with load() and eval()
5 // Last Change: 04.08.2017
6 // Language: C++
7 // EMail: brass@informatik.uni-halle.de
8 // WWW: http://www.informatik.uni-halle.de/~brass/
9 // Address: Feldschloesschen 15, D-06120 Halle (Saale), GERMANY
10 // Copyright: (c) 2016-2017 by Stefan Brass
11 // License: See file "LICENSE" for copying conditions.
12 // Note: There is no warranty at all - this code may contain bugs.
13 // ============================================================================
14 
15 
22 //=============================================================================
23 // Include File Frame:
24 //=============================================================================
25 
26 #ifndef BENCH_INCLUDED
27 #define BENCH_INCLUDED
28 
29 //=============================================================================
30 // Used Types and Macros:
31 //=============================================================================
32 
33 #ifndef VER_INCLUDED
34 #include "../base/ver.h"
35 #endif
36 
37 #ifndef STR_INCLUDED
38 #include "../base/str.h"
39 #endif
40 
41 #ifndef CHECK_INCLUDED
42 #include "../base/check.h"
43 #endif
44 
45 
46 //=============================================================================
47 // Private Constants:
48 //=============================================================================
49 
50 //-----------------------------------------------------------------------------
51 // BENCH_MAGIC: Magic number (identifies objects of this class).
52 //-----------------------------------------------------------------------------
53 
54 static const long BENCH_MAGIC = 0x42454E0AL; // 'BEN\n'
55 
56 
57 //=============================================================================
58 // Class Declaration:
59 //=============================================================================
60 
67 class bench_c {
68  public:
69 
70 //-----------------------------------------------------------------------------
71 // Constructor, Destructor:
72 //-----------------------------------------------------------------------------
73 
74  // Constructor:
75  bench_c();
76 
77  // Destructor:
78  ~bench_c();
79 
80 //-----------------------------------------------------------------------------
81 // Abstract Methods Required by this Class:
82 //-----------------------------------------------------------------------------
83 
89  virtual bool load(str_t filename) = 0;
90 
91  // Do bottom-up evaluation.
92  virtual long eval() = 0;
93 
94  // name: Name of this benchmark.
95  virtual str_t name() const = 0;
96 
97  // file: List of data files.
98  virtual str_t file(int i) const = 0;
99 
100  // result: List of correct results of eval method.
101  virtual long result(int i) const = 0;
102 
103 
104 //-----------------------------------------------------------------------------
105 // Debugging Support:
106 //-----------------------------------------------------------------------------
107 
108 #if VER_DEBUG
109  public:
110  // Integrity check:
111  str_t check() const;
112 
113  private:
114  // Magic number (identifies objects of this class for debugging).
115  long Magic; // Must be "BENCH_MAGIC".
116 #endif
117 
118 #if VER_DUMP
119  public:
120  // Display data structure:
121  virtual void dump(str_t headline = STR_NULL) const;
122 #endif
123 
124 //-----------------------------------------------------------------------------
125 // Copy-constructor and assignment operator are not supported for this class:
126 //-----------------------------------------------------------------------------
127 
128  private:
129 
130  bench_c(const bench_c& obj); // Not implemented
131  bench_c& operator=(const bench_c& obj); // Not implemented
132 
133 
134 //=============================================================================
135 // End of Class:
136 //=============================================================================
137 
138 };
139 
140 //-----------------------------------------------------------------------------
141 // Define pointer type:
142 //-----------------------------------------------------------------------------
143 
144 typedef bench_c *bench_t;
145 
146 //-----------------------------------------------------------------------------
147 // Define null pointer:
148 //-----------------------------------------------------------------------------
149 
150 #define BENCH_NULL (static_cast<bench_t>(0))
151 
152 //=============================================================================
153 // End of Include File:
154 //=============================================================================
155 
156 #endif
157 
Abstract superclass for Standard Benchmarks with load() and eval() Methods.
Definition: bench.h:67
virtual bool load(str_t filename)=0
const char * str_t
Definition: str.h:41
#define STR_NULL
Definition: str.h:52