]> jfr.im git - irc/gameservirc.git/blob - gameserv-2.0/libgameservgldl/include/GameServ/DataLayer/File/FileItemDAO.h
Added all old gameserv data files with some modifications to work better with 2.0...
[irc/gameservirc.git] / gameserv-2.0 / libgameservgldl / include / GameServ / DataLayer / File / FileItemDAO.h
1 #ifndef __GS__FILEITEMDAO_H__
2 #define __GS__FILEITEMDAO_H__
3
4
5
6 #include <GameServ/GameLayer/GameObjects/ItemGO.h>
7 using GameServ::GameLayer::GameObjects::ItemGO;
8 #include <GameServ/DataLayer/IItemDAO.h>
9 using GameServ::DataLayer::DataAccessObjects::IItemDAO;
10
11 #include <boost/shared_ptr.hpp>
12 using boost::shared_ptr;
13
14 #include <string>
15 using std::string;
16
17 #include <list>
18 using std::list;
19
20 #include <map>
21 using std::map;
22
23 namespace GameServ { namespace DataLayer { namespace File
24 {
25 //! File implementation of IItemDAO interface
26 /*!
27 If you're using an File datasource, you will be using this
28 DAO to access Items.
29 */
30 class FileItemDAO : public IItemDAO
31 {
32 public:
33 // Ctors, Dtors ///////////////////////////////////////////////////////
34 FileItemDAO(void);
35 FileItemDAO(const string &filename);
36 virtual ~FileItemDAO();
37
38 // Methods ////////////////////////////////////////////////////////////
39 virtual shared_ptr<ItemGO> GetById(const string &Id) const;
40
41 virtual bool IdExists(const string &Id) const;
42
43 void LoadItemCache(void);
44
45 private:
46 //! Data file
47 string mFilename;
48
49 // Helper Methods /////////////////////////////////////////////////////
50
51 //! Creates the ItemGO found at iterator position
52 shared_ptr<ItemGO> CreateItemFromLine(const string &line) const;
53
54 //! Get the Item database file path
55 string GetItemFilePath(void) const;
56
57 void Initialize(const string &filename);
58
59
60 map<string, shared_ptr<ItemGO> > spItemCache;
61 };
62 } } } // GameServ.DataLayer.DataAccessObjects.File
63
64 #endif // __GS__FILEITEMDAO_H__