]> jfr.im git - irc/gameservirc.git/blob - gameserv-2.0/libgameservgldl/include/GameServ/DataLayer/File/FilePlayerDAO.h
Finished some work on FilePlayerDAO
[irc/gameservirc.git] / gameserv-2.0 / libgameservgldl / include / GameServ / DataLayer / File / FilePlayerDAO.h
1 #ifndef __GS__FilePlayerDAO_H__
2 #define __GS__FilePlayerDAO_H__
3
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;
8
9 #include <boost/shared_ptr.hpp>
10 using boost::shared_ptr;
11
12 #include <string>
13 using std::string;
14
15 namespace GameServ { namespace DataLayer { namespace File
16 {
17 //! File implementation of IPlayerDAO interface
18 /*!
19 If you're using an File datasource, you will be using this
20 DAO to access Players.
21 */
22 class FilePlayerDAO : public IPlayerDAO
23 {
24 public:
25 // Ctors, Dtors ///////////////////////////////////////////////////////
26 FilePlayerDAO(void);
27 FilePlayerDAO(const string &filename);
28 virtual ~FilePlayerDAO();
29
30 // Methods ////////////////////////////////////////////////////////////
31 virtual shared_ptr<PlayerGO> GetById(const string &Id) const;
32
33 virtual list<string> GetIdsByName(const string &Name) const;
34
35 virtual bool IdExists(const string &Id) const;
36
37 virtual void Insert(shared_ptr<PlayerGO> spPlayer);
38 virtual void Update(shared_ptr<PlayerGO> spPlayer);
39
40 virtual void SetFlags(shared_ptr<PlayerGO> spPlayer, const int &flags) const;
41
42 private:
43 //! Data file
44 string mFilename;
45
46 // Constants //////////////////////////////////////////////////////////
47
48 // Helper Methods /////////////////////////////////////////////////////
49 //! Get control sector information
50 void GetControlInfo(void);
51
52 //! Creates the PlayerGO found at iterator position
53 shared_ptr<PlayerGO> CreatePlayerFromLine(const string &line) const;
54
55 //! Get the Player database file path
56 string GetPlayerFilePath(void) const;
57
58 void Initialize(const string &filename);
59
60 };
61 } } } // GameServ.DataLayer.DataAccessObjects.File
62
63 #endif // __GS__FilePlayerDAO_H__