TheChess

chess/cached_moves.hpp

00001 /*
00002  * thechess, chess game web application written in C++ and based on Wt
00003  * Copyright (C) 2010 Boris Nagaev
00004  *
00005  * thechess is licensed under the GNU GPL Version 2.
00006  * Other versions of the GPL do not apply.
00007  * See the LICENSE file for terms of use.
00008  */
00009 
00010 //
00011 #ifndef THECHESS_CACHED_MOVES_H_
00012 #define THECHESS_CACHED_MOVES_H_
00013 
00014 #include "chess/moves.hpp"
00015 #include "chess/board.hpp"
00016 #include <vector>
00017 
00018 namespace thechess {
00019 namespace chess {
00020 class CachedMoves;
00021 }
00022 }
00023 
00024 namespace thechess {
00025 namespace chess {
00026 
00027 class CachedMoves : public Moves {
00028 public:
00029     CachedMoves(int moves_count=0);
00030     //CachedMoves(std::string moves);
00031     CachedMoves(const Moves& moves);
00032 
00033     void push_move(Move move);
00034     void pop_move();
00035     void pop_moves(int number);
00036     void reset_move(int n, Move move);
00037 
00038     Move move_at(int n) const;
00039     const Board& board_at(int n) const;
00040 
00041     void foreach(void *func(Move move, const Board& board),
00042                  int from=0, int to=-1) const;
00043 
00044 private:
00045     std::vector<Board> boards_; // stores boards before this move
00046 
00047     void boards_rebuild_();
00048     void set_move(int n, Move move); // to forbid this
00049 };
00050 
00051 }
00052 }
00053 
00054 
00055 #endif // THECHESS_CACHED_MOVES_H_
 All Classes Functions Enumerations Enumerator