boardBitEffect.h Source File

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
boardBitEffect.h
Go to the documentation of this file.
1 /* boardBitEffect.h
2 */
3 #ifndef _BOARD_BIT_EFFECT_H
4 #define _BOARD_BIT_EFFECT_H
5 #include "osl/applyDoUndoXMove.h"
6 #include "osl/boardBitMask.h"
7 namespace osl
8 {
9 namespace effect
10 {
17 template<class State>
18 class BoardBitEffect : public State{
19 typedef BoardBitEffect<State> BoardBitState;
20 friend class ApplyDoUndoSimpleMove<BLACK,BoardBitState>;
21 friend class ApplyDoUndoCaptureMove<BLACK,BoardBitState>;
22 friend class ApplyDoUndoDropMove<BLACK,BoardBitState>;
23 friend class ApplyDoUndoSimpleMove<WHITE,BoardBitState>;
24 friend class ApplyDoUndoCaptureMove<WHITE,BoardBitState>;
25 friend class ApplyDoUndoDropMove<WHITE,BoardBitState>;
26 public:
27 BoardBitMask emptyMask;
28 typedef BoardBitEffect effect_state_t;
29 template<typename OrigState>
30 explicit BoardBitEffect(OrigState& st) :State(st),emptyMask(st){
31 }
35 explicit BoardBitEffect() {
36 }
37 };
38
39 template<Player P,typename BaseState>
40 struct ApplyDoUndoSimpleMove<P,BoardBitEffect<BaseState> >
41 {
42 typedef BoardBitEffect<BaseState> state_t;
43 template <typename F>
44 static void doUndoSimpleMove(state_t& s,
45 Square from, Square to, int promoteMask,F& func){
46 BoardBitMask oldMask=s.emptyMask;
47 s.emptyMask^=(boardBitMaskTable.getMask(from)^boardBitMaskTable.getMask(to));
48 ApplyDoUndoSimpleMove<P,BaseState>::doUndoSimpleMove(s,from,to,promoteMask,func);
49 s.emptyMask=oldMask;
50 }
51 };
52
53 template<Player P,typename BaseState>
54 struct ApplyDoUndoDropMove<P,BoardBitEffect<BaseState> >
55 {
56 typedef BoardBitEffect<BaseState> state_t;
57 template <typename F>
58 static void doUndoDropMove(state_t& s,
59 Square to, Ptype ptype,F& func){
60 BoardBitMask oldMask=s.emptyMask;
61 s.emptyMask^=boardBitMaskTable.getMask(to);
62 ApplyDoUndoDropMove<P,BaseState>::doUndoDropMove(s,to,ptype,func);
63 s.emptyMask=oldMask;
64 }
65 };
66
67 template<Player P,typename BaseState>
68 struct ApplyDoUndoCaptureMove<P,BoardBitEffect<BaseState> >
69 {
70 typedef BoardBitEffect<BaseState> state_t;
71 template <typename F>
72 static void doUndoCaptureMove(state_t& s,
73 Square from,Square to, Piece p1, int promoteMask,F& func){
74 BoardBitMask oldMask=s.emptyMask;
75 s.emptyMask^=boardBitMaskTable.getMask(from);
76 ApplyDoUndoCaptureMove<P,BaseState>::doUndoCaptureMove(s,from,to,p1,promoteMask,func);
77 s.emptyMask=oldMask;
78 }
79 };
80
81 } // namespace effect
82 } // namespace osl
83
84 #endif // _BOARD_BIT_EFFECT_H
85 // ;;; Local Variables:
86 // ;;; mode:c++
87 // ;;; c-basic-offset:2
88 // ;;; End: