hlswmaster-ng/gamelist.h

56 lines
870 B
C
Raw Normal View History

2006-02-02 16:55:44 +01:00
#ifndef _GAMELIST_H_
#define _GAMELIST_H_
2006-02-19 18:45:56 +01:00
#include "config.h"
#include "list.h"
2006-02-20 12:31:34 +01:00
#include "netpkt.h"
2006-02-19 18:45:56 +01:00
#include "timerservice.h"
2006-02-02 16:55:44 +01:00
class GameEntry {
public:
2006-02-20 21:58:59 +01:00
GameEntry() {};
~GameEntry() {};
2006-02-02 16:55:44 +01:00
2006-02-20 21:58:59 +01:00
struct in_addr addr;
2006-02-02 16:55:44 +01:00
int port1;
int port2;
int gameid;
2006-02-20 21:58:59 +01:00
protected:
GameEntry(const GameEntry& ge);
GameEntry& operator=(const GameEntry& ge);
2006-02-02 16:55:44 +01:00
};
class GameList {
public:
2006-02-19 18:45:56 +01:00
GameList(Config& conf);
~GameList();
void cleanup();
2006-02-20 12:31:34 +01:00
void addGame(int gameid, NetPkt* pkt);
2006-02-02 16:55:44 +01:00
2006-02-20 21:58:59 +01:00
long getLastUpdate();
2006-02-19 18:45:56 +01:00
Iterator<GameEntry>* createIterator();
2006-02-02 16:55:44 +01:00
protected:
2006-02-19 18:45:56 +01:00
GameList(const GameList& gl);
GameList& operator=(const GameList& gl);
private:
2006-02-20 21:58:59 +01:00
class CleanupEvent : public Event {
2006-02-19 18:45:56 +01:00
public:
2006-02-20 21:58:59 +01:00
CleanupEvent(GameList& gl) : gl(gl) {}
2006-02-19 18:45:56 +01:00
~CleanupEvent() {}
2006-02-20 21:58:59 +01:00
void execute() { gl.cleanup(); }
2006-02-19 18:45:56 +01:00
private:
2006-02-20 21:58:59 +01:00
GameList& gl;
2006-02-19 18:45:56 +01:00
};
List<GameEntry> glist;
2006-02-20 21:58:59 +01:00
long lastUpdate;
2006-02-02 16:55:44 +01:00
};
#endif // _GAMELIST_H_