initial commit, lordsawar source, slightly modified
[lordsawar] / src / game-station.h
1 // Copyright (C) 2008 Ben Asselstine
2 //
3 //  This program is free software; you can redistribute it and/or modify
4 //  it under the terms of the GNU General Public License as published by
5 //  the Free Software Foundation; either version 3 of the License, or
6 //  (at your option) any later version.
7 //
8 //  This program is distributed in the hope that it will be useful,
9 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 //  GNU Library General Public License for more details.
12 //
13 //  You should have received a copy of the GNU General Public License
14 //  along with this program; if not, write to the Free Software
15 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
16 //  02110-1301, USA.
17
18 #ifndef GAME_STATION_H
19 #define GAME_STATION_H
20
21 #include "config.h"
22
23 #include <memory>
24 #include <list>
25 #include <map>
26 #include <sigc++/trackable.h>
27 #include <sigc++/signal.h>
28 #include <sigc++/connection.h>
29
30 #include "game-client-decoder.h"
31
32 class GameStation: public GameClientDecoder 
33 {
34 public:
35         
36   sigc::signal<void, std::string> remote_participant_joins;
37   sigc::signal<void, Player*, std::string> player_sits;
38   sigc::signal<void, Player*, std::string> player_stands;
39   sigc::signal<void, std::string> remote_participant_departs;
40   sigc::signal<void> playerlist_reorder_received;
41   sigc::signal<void, Player*> local_player_moved;
42   sigc::signal<void, Player*> local_player_died;
43   sigc::signal<void, Player*> local_player_starts_move;
44   sigc::signal<void> round_begins;
45
46   void listenForLocalEvents(Player *p);
47 protected:
48   GameStation();
49   virtual ~GameStation();
50
51   virtual void onActionDone(NetworkAction *action) = 0;
52   virtual void onHistoryDone(NetworkHistory *history) = 0;
53
54   void clearNetworkActionlist(std::list<NetworkAction*> &actions);
55   void clearNetworkHistorylist(std::list<NetworkHistory*> &histories);
56
57   void stopListeningForLocalEvents(Player *p);
58
59 private:
60   std::map<guint32, sigc::connection> action_listeners;
61   std::map<guint32, sigc::connection> history_listeners;
62 };
63
64 #endif