Initial porting to the new component API.
[tagua/yd.git] / src / entities / icsentity.h
blob6410519d54880cd7593fb154c1918a49e0bc70dd
1 /*
2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@gmail.com>
3 (c) 2006 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 ICSENTITY_H
12 #define ICSENTITY_H
14 #include <core/turnpolicy.h>
15 #include "entity.h"
16 #include "agent.h"
17 #include "agentgroup.h"
18 #include "icsapi_fwd.h"
19 #include "icslistener.h"
21 class IColor;
22 class IMoveSerializer;
23 class IValidator;
24 class ICSConnection;
25 class Move;
26 class Variant;
28 class ICSEntity : public Entity
29 , public Agent
30 , public ICSListener {
31 protected:
32 Variant* m_variant;
33 IValidator* m_validator;
34 ICSAPIPtr m_icsapi;
35 IMoveSerializer* m_serializer;
36 IMoveSerializer* m_san_serializer;
38 boost::shared_ptr<ICSConnection> m_connection;
39 const IColor* m_side;
40 int m_game_number;
41 bool m_editing_mode;
42 AgentGroupDispatcher m_dispatcher;
44 void updateGame(const Index& index, Move& icsMove, const StatePtr& icsPos);
46 enum UpdateType {
47 MoveForward,
48 MoveBack,
49 Forward,
50 Back,
51 NoMove,
52 NonComparableIndexes
55 UpdateType getUpdate(const Index& index);
56 public:
57 ICSEntity(Variant*, const boost::shared_ptr<Game>&,
58 const IColor*, int,
59 const boost::shared_ptr<ICSConnection>&, AgentGroup*);
61 virtual void executeMove(const Move&);
62 virtual void notifyStyle12(const PositionInfo&, bool is_starting);
63 virtual void notifyPool(const PoolInfo&);
64 virtual void notifyMoveList(int, const StatePtr&, const PGN&);
66 virtual StatePtr position() const;
68 virtual void notifyClockUpdate(int, int) { }
69 virtual void notifyMove(const Index&);
70 virtual void notifyBack() { }
71 virtual void notifyForward() { }
72 virtual void notifyGotoFirst() { }
73 virtual void notifyGotoLast() { }
75 void requestMoves();
77 virtual bool canDetach() const;
78 virtual bool attach();
80 bool canEdit() const;
81 bool canEdit(const Index& index) const;
82 void setupTurnTest(TurnTest& test) const;
85 class ObservingEntity : public ICSEntity {
86 protected:
87 bool m_attached;
88 public:
89 ObservingEntity(Variant*, const boost::shared_ptr<Game>&,
90 int gameNumber, const boost::shared_ptr<ICSConnection>&, AgentGroup*);
91 ~ObservingEntity();
93 virtual void detach();
96 #endif // ICSENTITY_H