]> jfr.im git - irc/gameservirc.git/blob - gameserv-2.0/libgameservgldl/include/GameServ/DataLayer/File/FileMonsterDAO.h
75515bb44e5b0d6dedc3ffcb8dcb29b6b43a8750
[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 using boost::shared_ptr;
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 shared_ptr<MonsterGO> GetById(const string &Id) const;
38
39 virtual vector< shared_ptr<MonsterGO> > GetMonstersByLevelId(const string &LevelId) const;
40
41 virtual bool IdExists(const string &Id) const;
42
43 void LoadMonsterCache(void);
44
45 private:
46 //! Data file
47 string mFilename;
48
49 // Helper Methods /////////////////////////////////////////////////////
50
51 //! Creates the MonsterGO found at iterator position
52 shared_ptr<MonsterGO> CreateMonsterFromLine(const string &line) const;
53
54 //! Get the Monster database file path
55 string GetMonsterFilePath(void) const;
56
57 void Initialize(const string &filename);
58
59 map<string, shared_ptr<MonsterGO> > spMonsterCache;
60 };
61 } } } // GameServ.DataLayer.DataAccessObjects.File
62
63 #endif // __GS__FileMonsterDAO_H__