-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrologEngine.h
121 lines (90 loc) · 3.19 KB
/
PrologEngine.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/***************************************************************************
* Copyright (C) 2009 by Mushthofa *
* unintendedchoice@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
/**
* @file PrologEngine.h
* @author Mushthofa
* @date Tue 24 06 2009
*
* @brief Prolog Engine base interface class
*
*
*/
#ifndef _PROLOGENGINE_H
#define _PROLOGENGINE_H
#include <vector>
#include <string>
#include "Program.h"
class PrologThread
{
public:
PrologThread()
:answersleft(false), query_opened(false)
{}
virtual ~PrologThread ()
{
}
/* Do assert */
virtual void doAssert(const std::string&) = 0;
/* Do retract */
virtual void doRetract(const std::string&) = 0;
/* Load a program */
virtual void consult(const std::string&) = 0;
/* Open a query to Prolog */
virtual void openQuery(const std::string& ) = 0;
/* Is query open? */
virtual bool isQueryOpen() const = 0;
/* Get the next answer from the last query of the thread */
virtual void getNextAnswer(std::string& ) = 0;
/* Still more answers remaining ? */
bool answersLeft() const
{
return answersleft;
}
/* Asserts the facts to the context thread */
virtual void addFacts(const std::string& ) = 0;
/* Retract the thread from the context thread */
virtual void delFacts(const std::string& ) = 0;
/* Declare predicates as dynamic predicates */
virtual void declareDynamic(const std::set<PredicateSign>& ) = 0;
/* Check whether a ground query is true in the current database */
virtual bool checkQuery(const std::string&) = 0;
/* Close the currently open query */
virtual void closeQuery() = 0;
protected:
bool answersleft;
std::string curr_answer;
std::string next_answer;
bool ready;
bool query_opened;
};
class PrologEngine
{
public:
PrologEngine()
:initialised(false)
{}
virtual ~PrologEngine() {};
/* Create a new thread */
virtual PrologThread* createThread() const = 0;
protected:
bool initialised;
};
#endif
//End