/usr/include/osl/effect/signatureEffect.h is in libosl-dev 0.6.0-3.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | #ifndef _SIGNATURE_EFFECT_H
#define _SIGNATURE_EFFECT_H
#include "osl/effect/moveSignature.h"
#include "osl/piece.h"
#include "osl/misc/carray.h"
namespace osl
{
namespace effect
{
/**
*
*/
class SignatureTable{
CArray<MoveSignature,16*(9+4)> signatures;
public:
template<typename State>
SignatureTable(State& state){
std::fill(signatures.begin(),signatures.end(),signature_EDGE);
for(int y=1;y<=9;y++)
for(int x=1;x<=9;x++){
Square pos(x,y);
PtypeO ptypeO=getPtypeO(state.pieceAt(pos));
set(pos,Move_Signature_Table.getSignature(ptypeO));
}
}
MoveSignature get(Square pos) const{
return signatures[pos.index()];
}
void set(Square pos,MoveSignature signature){
signatures[pos.index()]=signature;
}
};
template <Player P,class State>
struct ApplyDoUndoSimpleMove;
template <Player P,class State>
struct ApplyDoUndoCaptureMove;
template <Player P,class State>
struct ApplyDoUndoDropMove;
/**
* マスごとの利き(MoveSignature)も保持するState.
* Stateの更新の際に少しコストは増えるが,高速化が期待できる
* 特に1マス1byteで表現できるため複数のマスを一度に操作することが可能
* 現在は使われていない
*/
template<class State>
class SignatureEffect: public State{
public:
SignatureTable signatureTable;
/** 継承したクラスから effect を実装した先祖を取り出すために使用する */
typedef SignatureEffect<State> effect_state_t;
public:
template<typename OrigState>
explicit SignatureEffect(OrigState const& st) :State(st),signatureTable(st){}
MoveSignature getSignature(Square pos) const{
return signatureTable.get(pos);
}
void setSignature(Square pos,MoveSignature signature){
signatureTable.set(pos,signature);
}
};
template<Player P,typename BaseState>
struct ApplyDoUndoSimpleMove<P,SignatureEffect<BaseState> >
{
typedef SignatureEffect<BaseState> state_t;
template <typename F>
static void doUndoSimpleMove(state_t& s,
Square from, Square to, int promoteMask,F& func){
/* signatureのset */
Piece oldPiece=s.pieceAt(from);
PtypeO ptypeO=oldPiece.promoteWithMask(promoteMask).ptypeO();
MoveSignature oldSignature=s.getSignature(from);
s.setSignature(from,signature_EMPTY);
s.setSignature(to,Move_Signature_Table.getSignature(ptypeO));
ApplyDoUndoSimpleMove<P,BaseState>::doUndoSimpleMove(s,from,to,promoteMask,func);
/* signatureの書き戻し */
s.setSignature(from,oldSignature);
s.setSignature(to,signature_EMPTY);
}
};
template<Player P,typename BaseState>
struct ApplyDoUndoDropMove<P,SignatureEffect<BaseState> >
{
typedef SignatureEffect<BaseState> state_t;
template <typename F>
static void doUndoDropMove(state_t& s,
Square to, Ptype ptype,F& func){
/* signatureのset */
PtypeO ptypeO=newPtypeO(P,ptype);
s.setSignature(to,Move_Signature_Table.getSignature(ptypeO));
ApplyDoUndoDropMove<P,BaseState>::doUndoDropMove(s,to,ptype,func);
/* signatureのundo */
s.setSignature(to,signature_EMPTY);
}
};
template<Player P,typename BaseState>
struct ApplyDoUndoCaptureMove<P,SignatureEffect<BaseState> >
{
typedef SignatureEffect<BaseState> state_t;
template <typename F>
static void doUndoCaptureMove(state_t& s,
Square from,Square to, Piece p1, int promoteMask,F& func){
/* signatureのset */
Piece oldPiece=s.pieceAt(from);
PtypeO ptypeO=oldPiece.promoteWithMask(promoteMask).ptypeO();
MoveSignature oldSignatureFrom=s.getSignature(from);
s.setSignature(from,signature_EMPTY);
MoveSignature oldSignatureTo=s.getSignature(to);
s.setSignature(to,Move_Signature_Table.getSignature(ptypeO));
/* base classの呼び出し */
ApplyDoUndoCaptureMove<P,BaseState>::doUndoCaptureMove(s,from,to,p1,promoteMask,func);
/* signatureの書き戻し */
s.setSignature(from,oldSignatureFrom);
s.setSignature(to,oldSignatureTo);
}
};
} // namespace effect
} // namespace osl
#endif // _SIGNATURE_EFFECT_H
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
|