]> jfr.im git - irc/gameservirc.git/blob - gameserv-2.0/libgameservgldl/include/GameServ/DataLayer/File/FileLevelDAO.h
47be872dd7a2a686d0dac3fc3971fab2715e77b5
[irc/gameservirc.git] / gameserv-2.0 / libgameservgldl / include / GameServ / DataLayer / File / FileLevelDAO.h
1 #ifndef __GS__FILELEVELDAO_H__
2 #define __GS__FILELEVELDAO_H__
3
4 #include <GameServ/GameLayer/GameObjects/LevelGO.h>
5 #include <GameServ/DataLayer/ILevelDAO.h>
6 using GameServ::GameLayer::GameObjects::LevelGO;
7 using GameServ::DataLayer::DataAccessObjects::ILevelDAO;
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 ILevelDAO interface
24 /*!
25 If you're using an File datasource, you will be using this
26 DAO to access Levels.
27 */
28 class FileLevelDAO : public ILevelDAO
29 {
30 public:
31 // Ctors, Dtors ///////////////////////////////////////////////////////
32 FileLevelDAO(void);
33 FileLevelDAO(const string &filename);
34 virtual ~FileLevelDAO();
35
36 // Methods ////////////////////////////////////////////////////////////
37 virtual shared_ptr<LevelGO> GetById(const string &Id) const;
38
39 virtual bool IdExists(const string &Id) const;
40
41 virtual void Insert(shared_ptr<LevelGO> spLevel);
42 virtual void Update(shared_ptr<LevelGO> spLevel);
43
44 void LoadLevelCache(void);
45
46 private:
47 //! Data file
48 string mFilename;
49
50 // Helper Methods /////////////////////////////////////////////////////
51
52 //! Creates the LevelGO found at iterator position
53 shared_ptr<LevelGO> CreateLevelFromLine(const string &line) const;
54
55 //! Get the Level database file path
56 string GetLevelFilePath(void) const;
57
58 void Initialize(const string &filename);
59
60 map<string, shared_ptr<LevelGO> > spLevelCache;
61 };
62 } } } // GameServ.DataLayer.DataAccessObjects.File
63
64 #endif // __GS__FileLevelDAO_H__