-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwolmgr.h
More file actions
105 lines (82 loc) · 2.57 KB
/
wolmgr.h
File metadata and controls
105 lines (82 loc) · 2.57 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
#ifndef WOLMGR_H_CLUDED
#define WOLMGR_H_INCLUDED
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <memory>
#include <sstream>
#include "common.h"
namespace wolver {
using namespace std;
class WolValueFactory;
class WolEvalFactory;
class WolVarSelStrategy;
class WolStack;
class WolNode;
struct sliceExpHash
: std::unary_function<WolNodeSptr, std::size_t>
{
std::size_t operator()(WolNodeSptr const& x) const;
};
struct sliceExpEqualTo
: std::binary_function<WolNodeSptr, WolNodeSptr, bool>
{
bool operator()(WolNodeSptr const& x, WolNodeSptr const& y) const;
};
struct expEqualTo
: std::binary_function<WolNodeSptr, WolNodeSptr, bool>
{
bool operator()(WolNodeSptr const& x, WolNodeSptr const& y) const;
};
struct expHash
: std::unary_function<WolNodeSptr, std::size_t>
{
std::size_t operator()(WolNodeSptr const& x) const;
};
class WolMgr {
public: //singleton
static WolMgr& getInstance()
{
static WolMgr instance;
return instance;
}
private:
WolMgr();
~WolMgr();
WolMgr(WolMgr const&);
void operator= (WolMgr const&);
public: // methods
void insertUniqueSliceExpr(WolNodeSptr exp){ _uniqSliceExpTable.insert(exp); }
WolNodeSptr findSliceExpr(WolNodeSptr exp);
void insertUniqueExpr(WolNodeSptr exp) {_uniqExpTable.insert(exp);}
WolNodeSptr findUniqueExpr(WolNodeSptr exp);
void insertConstExpr(WolNodeSptr exp);
WolNodeSptr findConstExpr(std::string string);
void insertIdExpr(WolNodeSptr exp);
WolNodeSptr findExpr(int id);
void setWolValueFactory(WolValueFactory *valueFactory) {_valueFactory = valueFactory;}
void setWolEvalFactory(WolEvalFactory *evalFactory) {_evalFactory = evalFactory;}
WolValueFactory *getValueFactory() {return _valueFactory;}
WolEvalFactory *getEvalFactory() {return _evalFactory;}
bool solve(nodeVec inputs, nodeVec outputs);
std::ostringstream& getOutputStream() { return _os;}
void printgv();
void setOutputNodes(nodeVec outputsVec);
private: // methods
bool initializeOutputNodes(nodeVec outputs);
private: // data
std::unordered_map<std::string, WolNodeSptr> _uniqConstTable;
std::unordered_set<WolNodeSptr, sliceExpHash, sliceExpEqualTo> _uniqSliceExpTable;
std::unordered_set<WolNodeSptr, expHash, expEqualTo> _uniqExpTable;
std::unordered_map<int, WolNodeSptr> _idToExpMap;
int _globalId;
WolValueFactory *_valueFactory;
WolEvalFactory *_evalFactory;
WolStack *_backtrackStack;
nodeVec _outputs;
std::ostringstream _os;
};
#define OUTPUT_MSG WolMgr::getInstance().getOutputStream()
//#define OUTPUT_MSG std::cout
}
#endif