]> jfr.im git - irc/gameservirc.git/blame - gameserv-2.0/libgameservgldl/include/GameServ/DataLayer/File/FilePlayerDAO.h
More exciting additions to FilePlayerDAO!
[irc/gameservirc.git] / gameserv-2.0 / libgameservgldl / include / GameServ / DataLayer / File / FilePlayerDAO.h
CommitLineData
ce4e8c42 1#ifndef __GS__FilePlayerDAO_H__\r
2#define __GS__FilePlayerDAO_H__\r
3\r
4#include <GameServ/GameLayer/GameObjects/PlayerGO.h>\r
5#include <GameServ/DataLayer/IPlayerDAO.h>\r
6using GameServ::GameLayer::GameObjects::PlayerGO;\r
7using GameServ::DataLayer::DataAccessObjects::IPlayerDAO;\r
8\r
9#include <boost/shared_ptr.hpp>\r
10using boost::shared_ptr;\r
11\r
12#include <string>\r
13using std::string;\r
14\r
f4f0d89d 15#include <list>\r
16using std::list;\r
17\r
18#include <map>\r
19using std::map;\r
20\r
ce4e8c42 21namespace GameServ { namespace DataLayer { namespace File\r
22{\r
23 //! File implementation of IPlayerDAO interface\r
24 /*!\r
25 If you're using an File datasource, you will be using this\r
26 DAO to access Players.\r
27 */\r
28 class FilePlayerDAO : public IPlayerDAO\r
29 {\r
30 public:\r
31 // Ctors, Dtors ///////////////////////////////////////////////////////\r
32 FilePlayerDAO(void);\r
33 FilePlayerDAO(const string &filename);\r
34 virtual ~FilePlayerDAO();\r
35\r
36 // Methods ////////////////////////////////////////////////////////////\r
37 virtual shared_ptr<PlayerGO> GetById(const string &Id) const;\r
38\r
39 virtual list<string> GetIdsByName(const string &Name) const;\r
40\r
41 virtual bool IdExists(const string &Id) const;\r
42\r
43 virtual void Insert(shared_ptr<PlayerGO> spPlayer);\r
44 virtual void Update(shared_ptr<PlayerGO> spPlayer);\r
45\r
2a8a990d 46 virtual void SetFlags(shared_ptr<PlayerGO> spPlayer, const int &flags) const;\r
f4f0d89d 47 virtual int GetFlags(shared_ptr<PlayerGO> spPlayer) const;\r
2a8a990d 48\r
ce4e8c42 49 private:\r
50 //! Data file\r
51 string mFilename;\r
52\r
ce4e8c42 53 // Helper Methods /////////////////////////////////////////////////////\r
54 //! Get control sector information\r
55 void GetControlInfo(void);\r
56\r
57 //! Creates the PlayerGO found at iterator position\r
58 shared_ptr<PlayerGO> CreatePlayerFromLine(const string &line) const;\r
f4f0d89d 59 string CreateLineFromPlayer(shared_ptr<PlayerGO> spPlayer) const;\r
ce4e8c42 60\r
61 //! Get the Player database file path\r
62 string GetPlayerFilePath(void) const;\r
63\r
64 void Initialize(const string &filename);\r
f4f0d89d 65 void LoadPlayerCache();\r
66 void WritePlayerCache();\r
67\r
68 //! string is the id and the shared_ptr<PlayerGO> is the player object\r
69 map<string, shared_ptr<PlayerGO> > spPlayerCache;\r
ce4e8c42 70\r
71 };\r
72} } } // GameServ.DataLayer.DataAccessObjects.File\r
73\r
74#endif // __GS__FilePlayerDAO_H__\r