]> jfr.im git - irc/gameservirc.git/blob - gameserv-2.0/libgameservgldl/include/GameServ/DataLayer/File/FileMonsterDAO.h
Added the asio framework to start developing a GameServ server
[irc/gameservirc.git] / gameserv-2.0 / libgameservgldl / include / GameServ / DataLayer / File / FileMonsterDAO.h
1 #ifndef __GS__FILEMONSTERDAO_H__
2 #define __GS__FILEMONSTERDAO_H__
3
4 #include <GameServ/GameLayer/GameObjects/MonsterGO.h>
5 #include <GameServ/DataLayer/IMonsterDAO.h>
6 using GameServ::GameLayer::GameObjects::MonsterGO;
7 using GameServ::DataLayer::DataAccessObjects::IMonsterDAO;
8
9 #include <boost/smart_ptr/shared_ptr.hpp>
10
11
12 #include <string>
13 using std::string;
14
15 #include <vector>
16 using std::vector;
17
18 #include <map>
19 using std::map;
20
21 namespace GameServ { namespace DataLayer { namespace File
22 {
23 //! File implementation of IMonsterDAO interface
24 /*!
25 If you're using an File datasource, you will be using this
26 DAO to access Monsters.
27 */
28 class FileMonsterDAO : public IMonsterDAO
29 {
30 public:
31 // Ctors, Dtors ///////////////////////////////////////////////////////
32 FileMonsterDAO(void);
33 FileMonsterDAO(const string &filename);
34 virtual ~FileMonsterDAO();
35
36 // Methods ////////////////////////////////////////////////////////////
37 virtual boost::shared_ptr<MonsterGO> GetById(const string &Id) const;
38
39 virtual vector<string> GetMonsterIdsByLevelId(const string &LevelId) const;
40
41 virtual bool IdExists(const string &Id) const;
42
43 void LoadMonsterCache(void);
44
45
46 void Update(boost::shared_ptr<MonsterGO> spMonster);
47 void Insert(boost::shared_ptr<MonsterGO> spMonster);
48
49 private:
50 //! Data file
51 string mFilename;
52
53 // Helper Methods /////////////////////////////////////////////////////
54
55 //! Creates the MonsterGO found at iterator position
56 boost::shared_ptr<MonsterGO> CreateMonsterFromLine(const string &line) const;
57
58 //! Get the Monster database file path
59 string GetMonsterFilePath(void) const;
60
61 void Initialize(const string &filename);
62
63 map<string, boost::shared_ptr<MonsterGO> > spMonsterCache;
64 };
65 } } } // GameServ.DataLayer.DataAccessObjects.File
66
67 #endif // __GS__FileMonsterDAO_H__