]> jfr.im git - irc/gameservirc.git/blob - gameserv-2.0/libgameservgldl/include/GameServ/DataLayer/File/FileItemDAO.h
Adding SQL scripts
[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 void Insert(shared_ptr<ItemGO> spItem);
46 void Update(shared_ptr<ItemGO> spItem);
47
48 private:
49 //! Data file
50 string mFilename;
51
52 // Helper Methods /////////////////////////////////////////////////////
53
54 //! Creates the ItemGO found at iterator position
55 shared_ptr<ItemGO> CreateItemFromLine(const string &line) const;
56 shared_ptr<ItemGO> CreatePotionFromLine(const string &line) const;
57
58 //! Get the Item database file path
59 string GetItemFilePath(void) const;
60
61 void Initialize(const string &filename);
62
63
64 map<string, shared_ptr<ItemGO> > spItemCache;
65 };
66 } } } // GameServ.DataLayer.DataAccessObjects.File
67
68 #endif // __GS__FILEITEMDAO_H__