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