2 Copyright (c) 2007 Paolo Capriotti <p.capriotti@gmail.com>
3 (c) 2007 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
11 #ifndef CORE__MOVE_SERIALIZER_H
12 #define CORE__MOVE_SERIALIZER_H
22 * @brief MoveSerializer takes care of converting moves to a displayable form and vice-versa.
24 class TAGUA_EXPORT IMoveSerializer
{
26 virtual ~IMoveSerializer();
29 * Serialize a move given a reference game state.
30 * It is assumed that the move has already been tested against @a ref.
31 * Calling this function on an untested or illegal move is safe but its return
33 * Do not try to call this function on an invalid move.
34 * @param ref The position in which this move shall be executed.
35 * @return A string representation for this move.
37 virtual QString
serialize(const Move
& move
, const IState
* ref
) const = 0;
40 * Convert a string representation of a move back to a move object.
41 * @param ref The position in which this move shall be executed.
42 * @return A move corresponding to the given string representation.
44 virtual Move
deserialize(const QString
& str
, const IState
* ref
) const = 0;
47 * @return The symbol associated to the given type.
49 virtual QString
symbol(const IType
* type
) const = 0;
52 * Compute a move suffix (e.g. to represent checkmate).
53 * @param ref The position in which this move shall be executed.
54 * @return A suffix for the given move.
56 virtual QString
suffix(const Move
& move
, const IState
* ref
) const = 0;
59 * @return Serializer type.
61 virtual QString
type() const = 0;
63 virtual void setDelegator(IMoveSerializer
* delegator
) = 0;
66 #endif // CORE__MOVE_SERIALIZER_H