BAM
Abstract Machine for Bottom-Up Evaluation with the Push Method
Main Page
Related Pages
Classes
Files
File List
File Members
facts
load.h
Go to the documentation of this file.
1
// ============================================================================
2
// Project: Deductive Database
3
// Filename: load.h
4
// Purpose: Parse and load data.
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) 2015-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
27
//=============================================================================
28
// Include File Frame:
29
//=============================================================================
30
31
#ifndef LOAD_INCLUDED
32
#define LOAD_INCLUDED
33
34
//=============================================================================
35
// Used Types and Macros:
36
//=============================================================================
37
38
#ifndef VER_INCLUDED
39
#include "../base/ver.h"
40
#endif
41
42
#ifndef STR_INCLUDED
43
#include "../base/str.h"
44
#endif
45
46
#ifndef CHECK_INCLUDED
47
#include "../base/check.h"
48
#endif
49
50
#ifndef STRTAB_INCLUDED
51
#include "../dom/strtab.h"
52
#endif
53
54
#ifndef PRED_INCLUDED
55
#include "../pred/pred.h"
56
#endif
57
58
//=============================================================================
59
// Private Constants:
60
//=============================================================================
61
62
//-----------------------------------------------------------------------------
63
// LOAD_MAGIC: Magic number (identifies objects of this class).
64
//-----------------------------------------------------------------------------
65
66
static
const
long
LOAD_MAGIC = 0x4C4F440AL;
// 'LOD\n'
67
68
//-----------------------------------------------------------------------------
69
// LOAD_HASHSIZE: Size of hash table.
70
//-----------------------------------------------------------------------------
71
72
static
const
int
LOAD_HASHSIZE = 251;
// Should be prime number
73
74
//=============================================================================
75
// Forward declaration for private type (predicate data):
76
//=============================================================================
77
78
class
load_pred_c;
79
80
//=============================================================================
81
// Class for Data LOader:
82
//=============================================================================
83
84
class
load_c
{
85
public
:
86
87
//-----------------------------------------------------------------------------
88
// Constructor, Destructor:
89
//-----------------------------------------------------------------------------
90
91
// Constructor:
92
load_c
();
93
94
// Destructor:
95
~
load_c
();
96
97
//-----------------------------------------------------------------------------
98
// (Object) Methods:
99
//-----------------------------------------------------------------------------
100
101
// add: Define predicate.
102
void
add(
pred_t
predicate);
103
104
// Load data:
105
bool
load(
str_t
filename);
106
107
//-----------------------------------------------------------------------------
108
// Debugging Support:
109
//-----------------------------------------------------------------------------
110
111
#if VER_DEBUG
112
public
:
113
// Integrity check:
114
str_t
check()
const
;
115
116
private
:
117
// Magic number (identifies objects of this class for debugging).
118
long
Magic;
// Must be "LOAD_MAGIC".
119
#endif
120
121
#if VER_DUMP
122
public
:
123
// Display data structure:
124
void
dump(
str_t
headline =
STR_NULL
)
const
;
125
#endif
126
127
//-----------------------------------------------------------------------------
128
// Copy-constructor and assignment operator are not supported for this class:
129
//-----------------------------------------------------------------------------
130
131
private
:
132
133
load_c
(
const
load_c
& obj);
// Not implemented
134
load_c
& operator=(
const
load_c
& obj);
// Not implemented
135
136
//-----------------------------------------------------------------------------
137
// Auxiliary Methods:
138
//-----------------------------------------------------------------------------
139
140
private
:
141
142
// hash: Compute hash function for predicate name.
143
int
hash(
str_t
name_start,
str_t
name_end);
144
145
// find_pred: Find predicate data for given predicate name.
146
pred_t
find_pred(
str_t
name_start,
str_t
name_end);
147
148
149
//-----------------------------------------------------------------------------
150
// Private Object Members:
151
//-----------------------------------------------------------------------------
152
153
private
:
154
155
// Hash table:
156
pred_t
HashTab[LOAD_HASHSIZE];
157
158
//=============================================================================
159
// End of Class:
160
//=============================================================================
161
162
};
163
164
165
//=============================================================================
166
// End of Include File:
167
//=============================================================================
168
169
#endif
170
load_c
Definition:
load.h:84
str_t
const char * str_t
Definition:
str.h:41
pred_c
Definition:
pred.h:107
STR_NULL
#define STR_NULL
Definition:
str.h:52
Generated by
1.8.10