-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGlobals.cpp
More file actions
182 lines (133 loc) · 4.14 KB
/
Globals.cpp
File metadata and controls
182 lines (133 loc) · 4.14 KB
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/***************************************************************************
* 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 Globals.h
* @author Roman Schindlauer, Mushthofa
*
* @brief Global parameter class
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif // HAVE_CONFIG_H
#include <boost/algorithm/string/trim.hpp>
#include "Globals.h"
Globals* Globals::_instance = 0;
Globals::Globals()
{
//put default options here
//
strOpt["DLVPath"] = DLVPATH;
intOpt["EvalMethod"] = 4;
intOpt["maxNumGround"] = 10000;
intOpt["verboseLevel"] = 0;
intOpt["minRuleVar"] = 4;
intOpt["smallConstraintMaxVar"] = 10000;
intOpt["smallRuleMaxVar"] = 10000;
//strOpt["DLVArgs"] = "-silent --";
}
Globals* Globals::Instance()
{
if(_instance == 0)
_instance = new Globals;
return _instance;
}
void Globals::processArgs(GetPot cl)
{
/* Get the options from the command line */
bool showHelp = cl.search("--help") || cl.options_contain("h");
std::string dlvpath = cl("--dlv", DLVPATH);
const int evalmethod = cl("-m", 4);
const int maxNumAS = cl("-n", 0);
const int maxNumGround = cl("-gr", 10);
const int smallConstraintMaxVar = cl("-scv", 10);
const int smallRuleMaxVar = cl("-grmax", 10);
const int minRuleVar = cl("-vmax", 4);
bool noscc = cl.search("-no-scc");
bool ruleml = cl.search("-ruleml");
const bool verbose_f = cl.options_contain("vV");
std::string filter = cl("-filter", "");
/* Save the options in the internal records */
strOpt["DLVPath"] = dlvpath;
intOpt["EvalMethod"] = evalmethod;
intOpt["maxNumAS"] = maxNumAS;
//std::cout << maxNumAS;
intOpt["maxNumGround"] = maxNumGround * 1000;
intOpt["smallConstraintMaxVar"] = smallConstraintMaxVar * 1000;
intOpt["smallRuleMaxVar"] = smallRuleMaxVar * 1000;
intOpt["minRuleVar"] = minRuleVar;
if(intOpt["maxNumAS"] > 0)
{
boolOpt["limitAS"] = true;
}
else
boolOpt["limitAS"] = false;
boolOpt["no-scc"] = noscc;
boolOpt["ruleml"] = ruleml;
if(verbose_f)
intOpt["verboseLevel"] = 1;
strOpt["filter"] = filter;
/* Determine the input file */
std::string f (cl.next_nominus());
boost::trim(f);
if(f.size()>0)
{
filename = f;
boolOpt["fromSTDIN"] = false;
}
else
{
filename = "<STDIN>";
boolOpt["fromSTDIN"] = true;
}
}
bool Globals::boolOption(const std::string& o)
{
return boolOpt[o];
}
unsigned long Globals::intOption(const std::string& o)
{
return intOpt[o];
}
std::string Globals::strOption(const std::string& o)
{
return strOpt[o];
}
void Globals::setOption(const std::string& key, bool val)
{
boolOpt[key] = val;
}
void Globals::setOption(const std::string& key, unsigned val)
{
intOpt[key] = val;
}
void Globals::setOption(const std::string& key, const std::string& val)
{
strOpt[key] = val;
}
const std::string& Globals::getFileName()
{
return filename;
}
void Globals::setFileName(const std::string& f)
{
filename = f;
}
// End