Add MoveSerializer::type.
[tagua/yd.git] / src / core / moveserializer.h
blob57acba5d77bc7e7f75a6e51a7ad3d83e9fa97d85
1 /*
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.
9 */
11 #ifndef CORE__MOVE_SERIALIZER_H
12 #define CORE__MOVE_SERIALIZER_H
14 #include <QString>
15 #include "export.h"
17 class IState;
18 class Move;
20 /**
21 * @brief MoveSerializer takes care of converting moves to a displayable form and vice-versa.
23 class TAGUA_EXPORT IMoveSerializer {
24 public:
25 virtual ~IMoveSerializer();
27 /**
28 * Serialize a move given a reference game state.
29 * It is assumed that the move has already been tested against @a ref.
30 * Calling this function on an untested or illegal move is safe but its return
31 * value is undefined.
32 * Do not try to call this function on an invalid move.
33 * @param ref The position in which this move shall be executed.
34 * @return A string representation for this move.
36 virtual QString serialize(const Move& move, const IState* ref) const = 0;
38 /**
39 * Convert a string representation of a move back to a move object.
40 * @param ref The position in which this move shall be executed.
41 * @return A move corresponding to the given string representation.
43 virtual Move deserialize(const QString& str, const IState* ref) const = 0;
45 /**
46 * @return Serializer type.
48 virtual QString type() const = 0;
51 #endif // CORE__MOVE_SERIALIZER_H