Show
Ignore:
Timestamp:
04/07/07 00:25:03 (1 year ago)
Author:
ug
Message:

Snapshot/restore functionality for GameList class.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • 06/libkombilo/search.h

    r239 r248  
    4242 
    4343const char NO_CONT = 255; 
     44 
     45class SnapshotVector : public std::vector<unsigned char> { 
     46  public: 
     47    SnapshotVector(); 
     48    SnapshotVector(char* c, int size); 
     49 
     50    void pb_int(int d); 
     51    void pb_charp(char* c, int size); 
     52    void pb_char(char c); 
     53    void pb_string(std::string s); 
     54    void pb_intp(int* p, int size); 
     55 
     56    int retrieve_int(); 
     57    int* retrieve_intp(); 
     58    char retrieve_char(); 
     59    char* retrieve_charp(); 
     60    std::string retrieve_string(); 
     61 
     62    char* to_charp(); 
     63 
     64  private: 
     65    SnapshotVector::iterator current; 
     66}; 
     67 
    4468 
    4569class PatternError { 
     
    113137    Pattern(int type, int BOARDSIZE, int sX, int sY, char* iPos, char* CONTLABELS = 0); 
    114138    Pattern(const Pattern& p); 
     139    Pattern(SnapshotVector& snv); 
    115140    ~Pattern(); 
    116141    Pattern& operator=(const Pattern& p); 
     
    123148    int operator==(const Pattern& p); 
    124149    std::string printPattern(); 
     150    void to_snv(SnapshotVector& snv); 
    125151 
    126152    static int flipsX(int i, int x, int y, int XX, int YY); 
     
    141167    int lW; // black loses (where cont. is W) 
    142168    Continuation(); 
     169    void from_snv(SnapshotVector& snv); 
     170    void to_snv(SnapshotVector& snv); 
    143171}; 
    144172 
     
    179207    char* label; // this does not really contain the label, but rather the position of the continuation move 
    180208    Hit(ExtendedMoveNumber* POS, char* LABEL); 
     209    Hit(SnapshotVector& snv); // takes a SnapshotVector and reads information produced by Hit::to_snv() 
    181210    ~Hit(); 
    182211    static bool cmp_pts(Hit* a, Hit* b); 
     212    void to_snv(SnapshotVector& snv); 
    183213}; 
    184214 
     
    564594    SearchOptions(); 
    565595    SearchOptions(int FIXEDCOLOR, int NEXTMOVE, int MOVELIMIT=10000); 
     596    SearchOptions(SnapshotVector& snv); 
     597    void to_snv(SnapshotVector& snv); 
    566598}; 
    567599 
     
    576608    GameListEntry(int ID, char WINNER, std::string GAMEINFOSTR); 
    577609    ~GameListEntry(); 
     610 
     611    void hits_from_snv(SnapshotVector& snv); 
    578612}; 
    579613 
     
    596630const int OMIT_DUPLICATES = 4; 
    597631const int OMIT_GAMES_WITH_SGF_ERRORS = 8;  
    598 const int INDEX_OUT_OF_RANGE = 16; 
    599632 
    600633// process return values 
     
    612645const int IS_DUPLICATE = 4; 
    613646const int NOT_INSERTED_INTO_DB = 8; 
     647const int INDEX_OUT_OF_RANGE = 16; 
    614648 
    615649 
     
    640674    int Bwins; 
    641675    int Wwins; 
    642  
     676    Pattern* mrs_pattern; // most recent search pattern 
     677    SearchOptions* searchOptions; 
    643678    // ---------------------------------------------------------------------------- 
    644679    // the following methods provide the user interface 
     
    678713    void deleteTag(int tag, int i = -1) throw(DBError); 
    679714    std::vector<int> getTags(int i, int tag=0) throw(DBError); // note the order of arguments! 
    680      
     715 
    681716    // ------- duplicates --------------------------------------------------------- 
    682717    int find_duplicates(int bs, bool strict=false) throw(DBError); // return number of duplicate array 
     
    686721                                                 // The caller must free the pointer himself 
    687722                                                 // (before calling find_duplicates again). 
     723 
     724    // ------- snapshot, restore -------------------------------------------------- 
     725 
     726    int snapshot() throw(DBError); 
     727    void restore(int handle, bool del) throw(DBError); 
     728    void delete_snapshot(int handle) throw(DBError); 
     729    void delete_all_snapshots() throw(DBError); 
    688730 
    689731    // ------- misc --------------------------------------------------------------- 
     
    733775    int posHA; 
    734776    int SGFtagsSize; 
    735     int sizeX; // keeps track of width of search pattern during search 
    736777    sqlite3* algo_db1; 
    737778    sqlite3* algo_db2;