Inter4ql  5.2
Functions.h
1 #ifndef __FUNCTIONS_H__
2 #define __FUNCTIONS_H__
3 
4 #include <string>
5 
6 #include "LineParser.tab.h"
7 #include "Types.h"
8 #include "VariableSpace.h"
9 
10 namespace Inter4ql {
11  class Valuation;
12 
16  class Result;
17  class AsExpr {
18  public:
22  AsExpr() {
23  this->left_ = nullptr;
24  this->right_ = nullptr;
25  this->type_ = 1;
26  };
31  AsExpr(std::string id) {
32  this->id_ = id;
33  this->left_ = nullptr;
34  this->right_ = nullptr;
35  this->type_ = 0;
36  };
40  ~AsExpr() {
41  if (this->left_) delete this->left_;
42  if (this->right_) delete this->right_;
43  }
44 
45  AsExpr* left_;
46  AsExpr* right_;
47  std::string id_;
48  bool type_; // 0 - id, 1 - connector (left/right)
49  };
50 
56  std::string location2string(LineParser::location_type _location);
62  std::string variable_type2string(Inter4ql::variable_type::type _variable);
68  variable_type::type string2variable_type(std::string s);
69 
77  bool bind_variables(const std::vector<Value*>& query, const std::vector<Value*>& value, std::map<std::string, Value*>& binding);
84  std::vector<Value*> apply_bind(const std::vector<Value*>* query, const std::map<std::string, Value*>& binding);
85 
92  AsExpr* parse_asExpr(std::string toParse, int& pos);
93 
99  std::string print_expression(Expression* expr);
105  void print_constraints(std::string& s, std::vector<Expression*>* constraints);
115  bool check_constraints(Ctraints to_check, bool& disable_constraints, std::vector<Domain*> *domains, std::vector<ModuleGeneric *> *modules, const ModuleGeneric* current_module);
126  Result evaluate_expression_global(Expression* expr, const ModuleGeneric* this_module, std::vector<ModuleGeneric*>* modules, std::vector<Domain*> *domains, int& rating);
137  Result evaluate_expression_global_internal(Expression* expr, const ModuleGeneric* this_module, std::vector<ModuleGeneric*>* modules,
138  Result untill_now, std::vector<Domain*> *domains, int& rating);
144  database* make_snapshot(database* db);
151  void add_to_database(database* database, Fact* fact, Inter4ql::logic_type::type value);
157  void remove_from_database(database* database, Fact* fact);
165  logic_type::type value_in_database(database* database, std::string relation, const std::vector<Value*>& vect);
175  bool ask_for_fact_in_database(const database* db, Fact* term, Result& res, const database* db_to_rm = nullptr, bool check_existance = true);
176 }
177 
178 #endif
type
Enumeration type for four-valued logic.
Definition: Types.h:45
class that implements a fact
Definition: Fact.h:14
Definition: Expression.h:10
AsExpr()
constructor that creates a new AsExpr without an ID
Definition: Functions.h:22
Definition: Result.h:16
~AsExpr()
destructor
Definition: Functions.h:40
Definition: Application.cc:37
Definition: Functions.h:17
Generic class of module (only virtual methods)
Definition: ModuleGeneric.h:21
AsExpr(std::string id)
constructor that creates a new AsExpr
Definition: Functions.h:31
type
Enumeration type for types of values.
Definition: Types.h:26