Doxygen Generated Documentation of Ben-Jose Trainable SAT Solver Library
dbg_config.h
1 
2 
3 /*************************************************************
4 
5 This file is part of ben-jose.
6 
7 ben-jose is free software: you can redistribute it and/or modify
8 it under the terms of the version 3 of the GNU General Public
9 License as published by the Free Software Foundation.
10 
11 ben-jose is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with ben-jose. If not, see <http://www.gnu.org/licenses/>.
18 
19 ------------------------------------------------------------
20 
21 Copyright (C) 2007-2012, 2014-2016. QUIROGA BELTRAN, Jose Luis.
22 Id (cedula): 79523732 de Bogota - Colombia.
23 See https://github.com/joseluisquiroga/ben-jose
24 
25 ben-jose is free software thanks to The Glory of Our Lord
26  Yashua Melej Hamashiaj.
27 Our Resurrected and Living, both in Body and Spirit,
28  Prince of Peace.
29 
30 ------------------------------------------------------------
31 
32 config.h
33 
34 Declaration of functions to read and parse config files.
35 
36 --------------------------------------------------------------*/
37 
38 #ifndef CONFIG_H
39 #define CONFIG_H
40 
41 #include "tools.h"
42 
43 #define CONFIG_DBG(prm) DBG(prm)
44 #define CONFIG_CK(prm) DBG_CK(prm)
45 
46 #define DBG_NUM_LEVS 200
47 
48 class debug_entry;
49 class debug_info;
50 
51 DECLARE_PRINT_FUNCS(debug_entry)
52 DECLARE_PRINT_FUNCS(debug_info)
53 
54 //=================================================================
55 // debug_entry
56 
57 class debug_entry {
58  public:
59  long dbg_recoil;
60  long dbg_id;
61 
62  debug_entry(){
63  dbg_recoil = -1;
64  dbg_id = -1;
65  }
66 
67  ~debug_entry(){
68  }
69 
70  bj_ostream& print_debug_entry(bj_ostream& os, bool from_pt = false){
71  os << "dbg(rc=" << dbg_recoil << ", idx=" << dbg_id << ")";
72  return os;
73  }
74 
75 };
76 
77 inline
78 comparison cmp_dbg_entries(debug_entry const & e1, debug_entry const & e2){
79  return cmp_long(e1.dbg_recoil, e2.dbg_recoil);
80 }
81 
82 //=================================================================
83 // debug_info
84 
85 class debug_info {
86  public:
87  row<debug_entry> dbg_start_dbg_entries;
88  row<debug_entry> dbg_stop_dbg_entries;
89  long dbg_current_start_idx;
90  long dbg_current_stop_idx;
91  row<bool> dbg_levs_arr;
92  bool dbg_bad_cycle1;
93 
94  debug_info(){
95  init_debug_info();
96  }
97 
98  ~debug_info(){
99  }
100 
101  void init_debug_info(){
102  dbg_start_dbg_entries.clear();
103  dbg_stop_dbg_entries.clear();
104  dbg_current_start_idx = 0;
105  dbg_current_stop_idx = 0;
106  dbg_levs_arr.fill(false, DBG_NUM_LEVS);
107  dbg_bad_cycle1 = false;
108  }
109 
110  void dbg_lv_on(long lv_idx){
111  CONFIG_CK(dbg_levs_arr.is_valid_idx(lv_idx));
112  dbg_levs_arr[lv_idx] = true;
113  }
114 
115  void dbg_lv_off(long lv_idx){
116  CONFIG_CK(dbg_levs_arr.is_valid_idx(lv_idx));
117  dbg_levs_arr[lv_idx] = false;
118  }
119 
120  bj_ostream& print_debug_info(bj_ostream& os, bool from_pt = false){
121  os << " dbg_start_dbg_entries=\n";
122  dbg_start_dbg_entries.print_row_data(os, true, "\n");
123  os << " dbg_stop_dbg_entries=\n";
124  dbg_stop_dbg_entries.print_row_data(os, true, "\n");
125  os << " num_lvs=" << dbg_levs_arr.size();
126  return os;
127  }
128 
129 };
130 
131 //=================================================================
132 // config_reader
133 
134 void dbg_read_dbg_conf(debug_info& dbg_inf);
135 void dbg_init_dbg_conf(debug_info& dbg_inf);
136 void dbg_update_config_entries(debug_info& dbg_inf, bj_big_int_t curr_round);
137 
138 class config_reader {
139  public:
140  row<long> dbg_config_line;
141 
142  config_reader(){
143  }
144 
145  ~config_reader(){}
146 
147  void parse_debug_line(row<long>& dbg_line, ch_string& str_ln);
148  void add_config_line(debug_info& dbg_inf, ch_string& str_ln);
149  void read_config(debug_info& dbg_inf, const char* f_name);
150 };
151 
152 //=============================================================================
153 // printing funcs
154 
155 DEFINE_PRINT_FUNCS(debug_entry)
156 DEFINE_PRINT_FUNCS(debug_info)
157 
158 
159 #endif // CONFIG_H
160