]>
jfr.im git - irc/gameservirc.git/blob - gameserv-2.0/libgameservgldl/include/GameServ/DataLayer/File/FilePlayerDAO.h
1 #ifndef __GS__FilePlayerDAO_H__
2 #define __GS__FilePlayerDAO_H__
4 #include <GameServ/GameLayer/GameObjects/PlayerGO.h>
5 #include <GameServ/DataLayer/IPlayerDAO.h>
6 using GameServ::GameLayer::GameObjects::PlayerGO
;
7 using GameServ::DataLayer::DataAccessObjects::IPlayerDAO
;
9 #include <boost/shared_ptr.hpp>
10 using boost::shared_ptr
;
21 namespace GameServ
{ namespace DataLayer
{ namespace File
23 //! File implementation of IPlayerDAO interface
25 If you're using an File datasource, you will be using this
26 DAO to access Players.
28 class FilePlayerDAO
: public IPlayerDAO
31 // Ctors, Dtors ///////////////////////////////////////////////////////
33 FilePlayerDAO(const string
&filename
);
34 virtual ~FilePlayerDAO();
36 // Methods ////////////////////////////////////////////////////////////
37 virtual shared_ptr
<PlayerGO
> GetById(const string
&Id
) const;
39 virtual list
<string
> GetIdsByName(const string
&Name
) const;
41 virtual bool IdExists(const string
&Id
) const;
43 virtual void Insert(shared_ptr
<PlayerGO
> spPlayer
);
44 virtual void Update(shared_ptr
<PlayerGO
> spPlayer
);
46 virtual void SetFlags(shared_ptr
<PlayerGO
> spPlayer
, const int &flags
) const;
47 virtual int GetFlags(shared_ptr
<PlayerGO
> spPlayer
) const;
53 // Helper Methods /////////////////////////////////////////////////////
54 //! Get control sector information
55 void GetControlInfo(void);
57 //! Creates the PlayerGO found at iterator position
58 shared_ptr
<PlayerGO
> CreatePlayerFromLine(const string
&line
) const;
59 string
CreateLineFromPlayer(shared_ptr
<PlayerGO
> spPlayer
) const;
61 //! Get the Player database file path
62 string
GetPlayerFilePath(void) const;
64 void Initialize(const string
&filename
);
65 void LoadPlayerCache();
66 void WritePlayerCache();
68 //! string is the id and the shared_ptr<PlayerGO> is the player object
69 map
<string
, shared_ptr
<PlayerGO
> > spPlayerCache
;
72 } } } // GameServ.DataLayer.DataAccessObjects.File
74 #endif // __GS__FilePlayerDAO_H__