Changeset 248 for 06/libkombilo
- Timestamp:
- 04/07/07 00:25:03 (21 months ago)
- Location:
- 06/libkombilo
- Files:
-
- 5 modified
-
abstractboard.cpp (modified) (4 diffs)
-
abstractboard.h (modified) (1 diff)
-
cpptest.cpp (modified) (3 diffs)
-
search.cpp (modified) (31 diffs)
-
search.h (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
06/libkombilo/abstractboard.cpp
r244 r248 164 164 void abstractBoard::clear() { 165 165 for(int i=0; i<boardsize*boardsize; i++) status[i]=' '; 166 undostack = stack<Move>(); 166 undostack = stack<Move>(); 167 167 } 168 168 … … 183 183 undostack.push(m); 184 184 return 1; 185 } 185 } 186 186 return 0; 187 187 } … … 304 304 Move tuple = undostack.top(); 305 305 undostack.pop(); 306 306 307 307 char color = tuple.color; 308 308 vector<p_cc>* captures = tuple.captures; … … 318 318 } 319 319 } 320 } 320 } 321 321 } 322 322 -
06/libkombilo/abstractboard.h
r191 r248 28 28 #include <utility> 29 29 #include <stack> 30 31 const int DEBUG_ABSTRACTBOARD = 0;32 30 33 31 class BoardError { -
06/libkombilo/cpptest.cpp
r244 r248 29 29 gl.start_processing(); 30 30 directory_iterator end_itr; 31 string path = "/home/ug/go/kombilo/06/tests1/libkombilo";31 // string path = "/home/ug/go/kombilo/06/tests1/libkombilo"; 32 32 // string path = "/home/ug/go/gtl/reviews"; 33 //string path = "/home/ug/go/gogod06/1998";33 string path = "/home/ug/go/gogod06/1998"; 34 34 int counter = 0; 35 35 for(directory_iterator it(path); it != end_itr; ++it) { … … 94 94 95 95 // -------------------- do pattern search -------------------------------------- 96 //gl.search(p, &so);96 gl.search(p, &so); 97 97 98 98 // ------------------- print some information about current list of games ------------ 99 //printf("num games: %d, num hits: %d\n", gl.size(), gl.numHits());99 printf("num games: %d, num hits: %d\n", gl.size(), gl.numHits()); 100 100 // vector<string> res = gl.currentEntriesAsStrings(); 101 101 // for(vector<string>::iterator it = res.begin(); it != res.end(); it++) … … 130 130 131 131 // ------------------- check for duplicates --------------------------------- 132 // gl.reset(); 133 // int nd = gl.find_duplicates(19); 134 // printf("duplicates:\n"); 135 // for(int i=0; i<nd; i++) { 136 // // 1st method: retrieve_duplicates_VI 137 // // vector<int> dupl_vector = gl.retrieve_duplicates_VI(i); 138 // // for(vector<int>::iterator it = dupl_vector.begin(); it != dupl_vector.end(); it++) { 139 // // printf("%s%s\n", gl.currentEntryAsString(*it).c_str(), gl.getSignature(*it).c_str()); 140 // // } 141 // 142 // // 2nd method: retrieve_duplicates_PI 143 // int * dupl_vector = gl.retrieve_duplicates_PI(i); 144 // int j = 0; 145 // while(dupl_vector[j] != -1) { 146 // printf("%s%s\n", gl.currentEntryAsString(dupl_vector[j]).c_str(), gl.getSignature(dupl_vector[j]).c_str()); 147 // j++; 148 // } 149 // delete [] dupl_vector; 150 151 // printf("--------------------------------------------------- \n"); 152 // } 153 154 // ------------------- snapshot --------------------------------------------- 155 156 gl.delete_all_snapshots(); 157 int handle = gl.snapshot(); 158 printf("num games: %d, num hits: %d\n", gl.size(), gl.numHits()); 159 132 160 gl.reset(); 133 int nd = gl.find_duplicates(19); 134 printf("duplicates:\n"); 135 for(int i=0; i<nd; i++) { 136 // 1st method: retrieve_duplicates_VI 137 // vector<int> dupl_vector = gl.retrieve_duplicates_VI(i); 138 // for(vector<int>::iterator it = dupl_vector.begin(); it != dupl_vector.end(); it++) { 139 // printf("%s%s\n", gl.currentEntryAsString(*it).c_str(), gl.getSignature(*it).c_str()); 140 // } 141 142 // 2nd method: retrieve_duplicates_PI 143 int * dupl_vector = gl.retrieve_duplicates_PI(i); 144 int j = 0; 145 while(dupl_vector[j] != -1) { 146 printf("%s%s\n", gl.currentEntryAsString(dupl_vector[j]).c_str(), gl.getSignature(dupl_vector[j]).c_str()); 147 j++; 148 } 149 delete [] dupl_vector; 161 printf("num games: %d, num hits: %d\n", gl.size(), gl.numHits()); 150 162 151 printf("--------------------------------------------------- \n");152 }163 gl.restore(handle, true); 164 printf("num games: %d, num hits: %d\n", gl.size(), gl.numHits()); 153 165 154 166 // ------------------- resetFormat ------------------------------------------ -
06/libkombilo/search.cpp
r247 r248 43 43 using std::sort; 44 44 #endif 45 46 SnapshotVector::SnapshotVector() : vector<unsigned char>() { 47 current = begin(); 48 } 49 50 SnapshotVector::SnapshotVector(char* c, int size) : vector<unsigned char>() { 51 for(int i=0; i<size; i++) push_back(c[i]); 52 current = begin(); 53 } 54 55 void SnapshotVector::pb_int(int d) { 56 for(int i = 0; i < 4; i++) { 57 push_back((unsigned char)(d % 256)); 58 d = d >> 8; 59 } 60 } 61 62 void SnapshotVector::pb_charp(char* c, int size) { 63 pb_int(size); 64 for(int i=0; i<size; i++) push_back(c[i]); 65 } 66 67 void SnapshotVector::pb_intp(int* p, int size) { 68 pb_int(size); 69 for(int i=0; i<size; i++) pb_int(p[i]); 70 } 71 72 void SnapshotVector::pb_string(string s) { 73 pb_int(s.size()+1); 74 for(unsigned int i=0; i<s.size(); i++) push_back(s[i]); 75 push_back(0); 76 } 77 78 void SnapshotVector::pb_char(char c) { 79 push_back(c); 80 } 81 82 int SnapshotVector::retrieve_int() { 83 int result = 0; 84 for(int i=0; i<4; i++) { 85 result += *current << (i*8); 86 current++; 87 } 88 return result; 89 } 90 91 int* SnapshotVector::retrieve_intp() { 92 int sz = retrieve_int(); 93 int* result = new int[sz]; 94 for(int i=0; i<sz; i++) 95 result[i] = retrieve_int(); 96 return result; 97 } 98 99 char SnapshotVector::retrieve_char() { 100 char c = *current; 101 current++; 102 return c; 103 } 104 105 char* SnapshotVector::retrieve_charp() { 106 int sz = retrieve_int(); 107 char* result = new char[sz]; 108 for(int i=0; i<sz; i++) { 109 result[i] = *current; 110 current++; 111 } 112 return result; 113 } 114 115 string SnapshotVector::retrieve_string() { 116 char* cp = retrieve_charp(); 117 string s(cp); 118 delete [] cp; 119 return s; 120 } 121 122 char* SnapshotVector::to_charp() { 123 char* result = new char[size()]; 124 int counter = 0; 125 for(SnapshotVector::iterator it = begin(); it != end(); it++) result[counter++] = *it; 126 return result; 127 } 128 45 129 46 130 PatternError::PatternError() {} … … 55 139 wW = 0; 56 140 lW = 0; 141 } 142 143 void Continuation::from_snv(SnapshotVector& snv) { 144 B = snv.retrieve_int(); 145 W = snv.retrieve_int(); 146 tB = snv.retrieve_int(); 147 tW = snv.retrieve_int(); 148 wB = snv.retrieve_int(); 149 lB = snv.retrieve_int(); 150 wW = snv.retrieve_int(); 151 lW = snv.retrieve_int(); 152 } 153 154 void Continuation::to_snv(SnapshotVector& snv) { 155 snv.pb_int(B); 156 snv.pb_int(W); 157 snv.pb_int(tB); 158 snv.pb_int(tW); 159 snv.pb_int(wB); 160 snv.pb_int(lB); 161 snv.pb_int(wW); 162 snv.pb_int(lW); 57 163 } 58 164 … … 143 249 return 0; 144 250 } 145 146 251 147 252 … … 300 405 flip = 0; 301 406 colorSwitch = 0; 302 407 303 408 left = le; 304 409 right = ri; … … 322 427 323 428 contList = CONTLIST; 429 } 430 431 Pattern::Pattern(SnapshotVector& snv) { 432 flip = snv.retrieve_int(); 433 colorSwitch = snv.retrieve_int(); 434 left = snv.retrieve_int(); 435 right = snv.retrieve_int(); 436 top = snv.retrieve_int(); 437 bottom = snv.retrieve_int(); 438 boardsize = snv.retrieve_int(); 439 sizeX = snv.retrieve_int(); 440 sizeY = snv.retrieve_int(); 441 if (snv.retrieve_char()) { // contLabels? 442 contLabels = snv.retrieve_charp(); 443 } else contLabels = 0; 444 initialPos = snv.retrieve_charp(); 445 finalPos = snv.retrieve_charp(); 446 447 int size = snv.retrieve_int(); 448 for(int i=0; i<size; i++) 449 contList.push_back(MoveNC(snv.retrieve_char(), snv.retrieve_char(), snv.retrieve_char())); // x, y, color 450 } 451 452 void Pattern::to_snv(SnapshotVector& snv) { 453 snv.pb_int(flip); 454 snv.pb_int(colorSwitch); 455 snv.pb_int(left); 456 snv.pb_int(right); 457 snv.pb_int(top); 458 snv.pb_int(bottom); 459 snv.pb_int(boardsize); 460 snv.pb_int(sizeX); 461 snv.pb_int(sizeY); 462 if (contLabels) { 463 snv.pb_char(1); 464 snv.pb_charp(contLabels, sizeX*sizeY); 465 } else snv.pb_char(0); 466 snv.pb_charp(initialPos, sizeX*sizeY); 467 snv.pb_charp(finalPos, sizeX*sizeY); 468 snv.pb_int(contList.size()); 469 for(vector<MoveNC>::iterator it = contList.begin(); it != contList.end(); it++) { 470 snv.pb_char(it->x); 471 snv.pb_char(it->y); 472 snv.pb_char(it->color); 473 } 324 474 } 325 475 … … 368 518 if (finalPos) delete [] finalPos; 369 519 if (contLabels) delete [] contLabels; 370 520 371 521 initialPos = new char[sizeX*sizeY]; 372 522 finalPos = new char[sizeX*sizeY]; … … 398 548 if (initialPos) delete [] initialPos; 399 549 if (finalPos) delete [] finalPos; 400 550 401 551 initialPos = new char[sizeX*sizeY]; 402 552 finalPos = new char[sizeX*sizeY]; … … 501 651 return co; 502 652 } 503 653 504 654 void PatternList::patternList() { 505 506 655 vector<Pattern> lCS; 507 656 vector<pair<int,int> > sy; … … 1339 1488 if (rc != SQLITE_OK) throw DBError(); 1340 1489 // printf("init Algo_movelist\n"); 1341 } 1490 } 1342 1491 1343 1492 void Algo_movelist::newgame_process(int game_id) { … … 1348 1497 for(int i=0; i<50; i++) fpC[i] = 0; 1349 1498 } 1350 1499 1351 1500 void Algo_movelist::AB_process(int x, int y) { 1352 1501 movelist.push_back((char)x); … … 1401 1550 } 1402 1551 } 1403 1552 1404 1553 void Algo_movelist::pass_process() { 1405 1554 movelist.push_back(19); … … 1554 1703 return result; 1555 1704 } 1556 1557 1705 1558 1706 int Algo_movelist::search(PatternList& patternList, GameList& gl, SearchOptions& options) { … … 2278 2426 // printf("leave algo_hash_full::initialize_processing\n"); 2279 2427 } 2280 2428 2281 2429 void Algo_hash_full::newgame_process(int game_id) { 2282 2430 numStones = 0; … … 3413 3561 } 3414 3562 3415 Hit::Hit(ExtendedMoveNumber* POS, char* LABEL) { 3563 Hit::Hit(ExtendedMoveNumber* POS, char* LABEL) { // LABEL is a char[3] 3416 3564 pos = POS; // note that we do not copy these! 3417 3565 label = LABEL; … … 3421 3569 delete pos; 3422 3570 delete [] label; 3571 } 3572 3573 Hit::Hit(SnapshotVector& snv) { 3574 int length = snv.retrieve_int(); 3575 int* data = snv.retrieve_intp(); 3576 pos = new ExtendedMoveNumber(length, data); 3577 delete [] data; 3578 label = snv.retrieve_charp(); 3579 } 3580 3581 void Hit::to_snv(SnapshotVector& snv) { 3582 snv.pb_int(pos->length); 3583 snv.pb_intp(pos->data, pos->length); 3584 snv.pb_charp(label, 3); 3423 3585 } 3424 3586 … … 3446 3608 searchInVariations = true; 3447 3609 algos = (1<<30) - 1; // use all available algorithms 3610 } 3611 3612 SearchOptions::SearchOptions(SnapshotVector& snv) { 3613 fixedColor = snv.retrieve_int(); 3614 moveLimit = snv.retrieve_int(); 3615 nextMove = snv.retrieve_int(); 3616 trustHashFull = snv.retrieve_int(); 3617 searchInVariations= snv.retrieve_int(); 3618 algos = snv.retrieve_int(); 3619 } 3620 3621 void SearchOptions::to_snv(SnapshotVector& snv) { 3622 snv.pb_int(fixedColor); 3623 snv.pb_int(moveLimit); 3624 snv.pb_int(nextMove); 3625 snv.pb_int(trustHashFull); 3626 snv.pb_int(searchInVariations); 3627 snv.pb_int(algos); 3448 3628 } 3449 3629 … … 3537 3717 for(vector<Hit* >::iterator it = hits->begin(); it != hits->end(); it++) delete *it; 3538 3718 delete hits; 3719 hits = 0; 3539 3720 } 3540 3721 if (candidates) { 3541 3722 for(vector<Candidate* >::iterator it = candidates->begin(); it != candidates->end(); it++) delete *it; 3542 3723 delete candidates; 3543 } 3544 } 3545 3724 candidates = 0; 3725 } 3726 } 3727 3728 void GameListEntry::hits_from_snv(SnapshotVector& snv) { 3729 int h_size = snv.retrieve_int(); 3730 hits = new vector<Hit* >; 3731 for(int j=0; j<h_size; j++) { 3732 hits->push_back(new Hit(snv)); 3733 } 3734 } 3735 3546 3736 int insertEntry(void *gl, int argc, char **argv, char **azColName) { 3547 3737 char winner = '-'; … … 3591 3781 labels = 0; 3592 3782 continuations = 0; 3783 mrs_pattern = 0; 3784 searchOptions = 0; 3593 3785 dbname = new char[strlen(DBNAME)+2]; 3594 3786 strcpy(dbname, DBNAME); … … 3684 3876 if (rc != SQLITE_OK) throw DBError(); 3685 3877 } 3878 3879 // set up snapshot db 3880 rc = sqlite3_exec(db, "create table if not exists snapshots ( data text );", 0, 0, 0); 3881 if (rc != SQLITE_OK) throw DBError(); 3686 3882 3687 3883 // printf("set up Algorithm instances\n"); … … 3780 3976 currentList = 0; 3781 3977 oldList = 0; 3782 3978 3783 3979 int rc; 3784 3980 rc = sqlite3_exec(db, "begin transaction;", 0, 0, 0); … … 3796 3992 // printf("read.\n"); 3797 3993 // SQLITE_ERROR may occur since table might not yet exist 3798 3994 3799 3995 readPlayersList(); 3800 3996 rc = sqlite3_exec(db, "commit;", 0, 0, 0); … … 3815 4011 GameList::~GameList() { 3816 4012 // printf("enter ~GameList\n"); 4013 if (mrs_pattern) delete mrs_pattern; 4014 if (searchOptions) delete searchOptions; 3817 4015 if (p_op) delete p_op; 3818 4016 if (labels) delete [] labels; 3819 if (continuations) delete [] continuations; 4017 if (continuations) delete [] continuations; // FIXME CHECK whether the Continuation destructor is invoked! 3820 4018 if (duplicates) delete duplicates; 3821 4019 delete [] dbname; … … 3971 4169 currentList->push_back(make_pair((*it)->id, counter++)); 3972 4170 } 4171 num_hits = 0; 4172 num_switched = 0; 4173 Bwins = 0; 4174 Wwins = 0; 3973 4175 } 3974 4176 … … 4218 4420 4219 4421 char GameList::lookupLabel(char x, char y) { 4220 if (!labels ) return '?';4221 return labels[x+y* sizeX];4422 if (!labels || !mrs_pattern || x < 0 || x >= mrs_pattern->sizeX || y < 0 || y >= mrs_pattern->sizeY) return '?'; 4423 return labels[x+y*mrs_pattern->sizeX]; 4222 4424 } 4223 4425 4224 4426 Continuation GameList::lookupContinuation(char x, char y) { 4225 if (!continuations ) return Continuation();4226 return continuations[x+y* sizeX];4427 if (!continuations || !mrs_pattern || x < 0 || x >= mrs_pattern->sizeX || y < 0 || y >= mrs_pattern->sizeY) return Continuation(); 4428 return continuations[x+y*mrs_pattern->sizeX]; 4227 4429 } 4228 4430 … … 4296 4498 4297 4499 void GameList::search(Pattern& pattern, SearchOptions* so) throw(DBError) { 4298 SearchOptions* searchOptions; 4500 if (mrs_pattern) delete mrs_pattern; 4501 mrs_pattern = new Pattern(pattern); 4502 if (searchOptions) delete searchOptions; 4299 4503 if (so) searchOptions = new SearchOptions(*so); 4300 4504 else searchOptions = new SearchOptions(); 4301 sizeX = pattern.sizeX; // need this in lookupLabel4302 4505 PatternList pl(pattern, searchOptions->fixedColor, searchOptions->nextMove); 4303 4506 … … 4310 4513 if (it == boardsizes.end()) { 4311 4514 delete searchOptions; 4515 searchOptions = 0; 4312 4516 if (oldList) delete oldList; 4313 4517 oldList = 0; … … 4360 4564 continuations = pl.continuations; 4361 4565 pl.continuations = new Continuation[pattern.sizeX*pattern.sizeY]; 4362 delete searchOptions; 4566 4567 // FIXME: delete all candidate lists! 4363 4568 } 4364 4569 … … 4457 4662 sql1 = "create table if not exists GAME_TAGS ( id integer primary key, game_id integer, tag_id integer );"; 4458 4663 rc = sqlite3_exec(db, sql1.c_str(), 0, 0, 0); 4459 if ( rc!=SQLITE_OK) throw DBError();4664 if (rc != SQLITE_OK) throw DBError(); 4460 4665 } 4461 4666 4462 4667 void GameList::start_processing(int PROCESSVARIATIONS) throw(DBError) { 4463 4668 // printf("enter start_processing %p\n", p_op); 4669 4670 delete_all_snapshots(); 4671 4464 4672 if (PROCESSVARIATIONS != -1) processVariations = PROCESSVARIATIONS; 4465 4673 else processVariations = p_op->processVariations; … … 4565 4773 if (sz=="") sz = "19"; 4566 4774 int bs = atoi(sz.c_str()); 4567 if (bs < 1) { 4568 return_val |= UNACCEPTABLE_BOARDSIZE; 4775 if (bs < 1) { 4776 return_val |= UNACCEPTABLE_BOARDSIZE; 4569 4777 process_results_vector.push_back(return_val); 4570 4778 delete rootNodeProperties; … … 4941 5149 delete [] sig; 4942 5150 } 4943 5151 4944 5152 if (commit) { 4945 5153 // evaluate tags … … 4985 5193 4986 5194 5195 int GameList::snapshot() throw(DBError) { 5196 // return a handle to a snapshot stored in the main GameList db 5197 // the snapshot contains copies of 5198 // - orderby, format1, format2 5199 // - currentList 5200 // - all hits in the GameListEntry's of currentList 5201 // - pattern, labels, continuations, num_hits, num_switched, Bwins, Wwins 5202 5203 SnapshotVector snapshot; 5204 snapshot.pb_string(orderby); 5205 snapshot.pb_string(format1); 5206 snapshot.pb_string(format2); 5207 5208 snapshot.pb_int(currentList->size()); 5209 for(vector<pair<int,int> >::iterator it = currentList->begin(); it != currentList->end(); it++) { 5210 snapshot.pb_int(it->first); 5211 snapshot.pb_int(it->second); 5212 vector<Hit* >* hits = (*all)[it->second]->hits; 5213 snapshot.pb_int(hits->size()); 5214 for (vector<Hit* >::iterator it_h = hits->begin(); it_h != hits->end(); it_h++) { 5215 (*it_h)->to_snv(snapshot); 5216 } 5217 } 5218 5219 if (mrs_pattern) { 5220 snapshot.pb_char(1); 5221 mrs_pattern->to_snv(snapshot); 5222 } else snapshot.pb_char(0); 5223 if (searchOptions) { 5224 snapshot.pb_char(1); 5225 searchOptions->to_snv(snapshot); 5226 } else snapshot.pb_char(0); 5227 if (mrs_pattern && labels && continuations) { 5228 snapshot.pb_char(1); 5229 snapshot.pb_charp(labels, mrs_pattern->sizeX * mrs_pattern->sizeY); 5230 for(int i=0; i<mrs_pattern->sizeX * mrs_pattern->sizeY; i++) continuations[i].to_snv(snapshot); 5231 } else snapshot.pb_char(0); 5232 snapshot.pb_int(num_hits); 5233 snapshot.pb_int(num_switched); 5234 snapshot.pb_int(Bwins); 5235 snapshot.pb_int(Wwins); 5236 5237 // insert snapshot into database 5238 sqlite3_stmt *ppStmt=0; 5239 int rc = sqlite3_prepare(db, "insert into snapshots (data) values (?)", -1, &ppStmt, 0); 5240 if (rc != SQLITE_OK || ppStmt==0) throw DBError(); 5241 char* snchp = snapshot.to_charp(); 5242 rc = sqlite3_bind_blob(ppStmt, 1, snchp, snapshot.size(), SQLITE_TRANSIENT); 5243 delete [] snchp; 5244 if (rc != SQLITE_OK) throw DBError(); 5245 rc = sqlite3_step(ppStmt); 5246 if (rc != SQLITE_DONE) throw DBError(); 5247 rc = sqlite3_finalize(ppStmt); 5248 if (rc != SQLITE_OK) throw DBError(); 5249 return sqlite3_last_insert_rowid(db); 5250 } 5251 5252 void GameList::restore(int handle, bool del) throw(DBError) { 5253 // restore the state of the GameList associated with handle 5254 5255 // retrieve info associated with handle from db 5256 5257 char* sn = 0; 5258 int sn_size = 0; 5259 sqlite3_stmt *ppStmt=0; 5260 int rc = sqlite3_prepare(db, "select data from snapshots where rowid = ?", -1, &ppStmt, 0); 5261 if (rc != SQLITE_OK || ppStmt==0) { 5262 printf("%d\n", rc); 5263 throw DBError(); 5264 } 5265 rc = sqlite3_bind_int(ppStmt, 1, handle); 5266 if (rc != SQLITE_OK) throw DBError(); 5267 rc = sqlite3_step(ppStmt); 5268 if (rc == SQLITE_ROW) { 5269 sn = (char*)sqlite3_column_blob(ppStmt, 0); 5270 sn_size = sqlite3_column_bytes(ppStmt, 0); 5271 } else throw DBError(); 5272 5273 SnapshotVector snapshot(sn, sn_size); 5274 5275 // parse info 5276 5277 string ob = snapshot.retrieve_string(); 5278 string f1 = snapshot.retrieve_string(); 5279 string f2 = snapshot.retrieve_string(); 5280 if (ob != orderby || f1 != format1 || f2 != format2) resetFormat(); 5281 5282 if (oldList) delete oldList; 5283 oldList = 0; 5284 if (currentList) delete currentList; 5285 currentList = new vector<pair<int,int> >; 5286 for(vector<GameListEntry* >::iterator it = all->begin(); it != all->end(); it++) { 5287 if ((*it)->hits) { 5288 for(vector<Hit* >::iterator ith = (*it)->hits->begin(); ith != (*it)->hits->end(); ith++) 5289 delete *ith; 5290 delete (*it)->hits; 5291 (*it)->hits = 0; 5292 } 5293 if ((*it)->candidates) { 5294 for(vector<Candidate* >::iterator itc = (*it)->candidates->begin(); itc != (*it)->candidates->end(); itc++) 5295 delete *itc; 5296 delete (*it)->candidates; 5297 (*it)->candidates = 0; 5298 } 5299 } 5300 5301 int cl_size = snapshot.retrieve_int(); 5302 for(int i=0; i<cl_size; i++) { 5303 currentList->push_back(make_pair(snapshot.retrieve_int(), snapshot.retrieve_int())); 5304 (*all)[(*currentList)[currentList->size()-1].second]->hits_from_snv(snapshot); 5305 } 5306 5307 if (mrs_pattern) delete mrs_pattern; 5308 if (snapshot.retrieve_char()) mrs_pattern = new Pattern(snapshot); 5309 else mrs_pattern = 0; 5310 5311 if (searchOptions) delete searchOptions; 5312 if (snapshot.retrieve_char()) searchOptions = new SearchOptions(snapshot); 5313 else searchOptions = 0; 5314 5315 if (labels) delete [] labels; 5316 if (continuations) delete [] continuations; // FIXME check (cf. ~GameList) 5317 if (snapshot.retrieve_char()) { 5318 labels = snapshot.retrieve_charp(); 5319 continuations = new Continuation[mrs_pattern->sizeX * mrs_pattern->sizeY]; 5320 for(int i=0; i<mrs_pattern->sizeX * mrs_pattern->sizeY; i++) 5321 continuations[i].from_snv(snapshot); 5322 } else { 5323 labels = 0; 5324 continuations = 0; 5325 } 5326 num_hits = snapshot.retrieve_int(); 5327 num_switched = snapshot.retrieve_int(); 5328 Bwins = snapshot.retrieve_int(); 5329 Wwins = snapshot.retrieve_int(); 5330 5331 rc = sqlite3_finalize(ppStmt); 5332 if (rc != SQLITE_OK) throw DBError(); 5333 if (del) { // delete snapshot from db 5334 char sql[100]; 5335 sprintf(sql, "delete from snapshots where rowid = %d", handle); 5336 rc = sqlite3_exec(db, sql, 0, 0, 0); 5337 if (rc != SQLITE_OK) throw DBError(); 5338 } 5339 } 5340 5341
