-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgramBuilder.h
154 lines (115 loc) · 3.96 KB
/
ProgramBuilder.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/***************************************************************************
* 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 ProgramBuilder.h
* @author Roman Schindlauer, Mushthofa
*
* @brief Builders for logic program representations.
*
*
*/
#ifndef _PROGRAMBUILDER_H
#define _PROGRAMBUILDER_H
#include "Program.h"
#include "PrintVisitor.h"
#include "AtomSet.h"
#include <string>
#include <sstream>
class ProgramBuilder
{
protected:
std::ostringstream stream;
public:
ProgramBuilder();
virtual ~ProgramBuilder();
virtual void buildRule(const Rule* rule) = 0;
virtual void buildFacts(const AtomSet&) = 0;
virtual void buildProgram(const Program&) = 0;
virtual void buildQuery(const AtomSet&) {}
virtual void buildMinCheck(bool withDebug = false){};
virtual void buildModel(const AtomSet&){};
virtual void buildSubset(const AtomSet&){};
std::string getString() const;
void clearString();
};
class DLVProgramBuilder : public ProgramBuilder
{
public:
DLVProgramBuilder();
~DLVProgramBuilder();
virtual void buildRule(const Rule*);
virtual void buildFacts(const AtomSet&);
virtual void buildProgram(const Program&);
protected:
PrintVisitor* pv;
};
class PositiveProgramBuilder : public ProgramBuilder
{
public:
PositiveProgramBuilder();
~PositiveProgramBuilder();
virtual void buildRule(const Rule*);
virtual void buildFacts(const AtomSet&);
virtual void buildProgram(const Program&);
protected:
PrintVisitor* pv;
};
class PrologProgramBuilder: public ProgramBuilder
{
public:
PrologProgramBuilder();
~PrologProgramBuilder();
virtual void buildRule(const Rule*);
virtual void buildFacts(const AtomSet&);
virtual void buildProgram(const Program&);
protected:
PrintVisitor* pv;
};
class PrologGrProgramBuilder : public ProgramBuilder
{
public:
PrologGrProgramBuilder(bool withNeg = 0);
~PrologGrProgramBuilder();
virtual void buildRule(const Rule*);
virtual void buildFacts(const AtomSet&);
virtual void buildProgram(const Program&);
virtual void buildQuery(const AtomSet&);
protected:
PrintVisitor* pv;
std::set<struct PredicateSign> predicates;
};
class PrologMinCheckProgramBuilder : public ProgramBuilder
{
public:
PrologMinCheckProgramBuilder();
~PrologMinCheckProgramBuilder();
virtual void buildRule(const Rule*);
virtual void buildFacts(const AtomSet&);
virtual void buildProgram(const Program&);
virtual void buildModel(const AtomSet&);
virtual void buildSubset(const AtomSet&);
virtual void buildQuery(const AtomSet&);
virtual void buildMinCheck(bool withDebug = false);
protected:
PrintVisitor* pv;
std::set<struct PredicateSign> predicates;
};
#endif
//End