]>
jfr.im git - irc/gameservirc.git/blob - gameserv-2.0/libgameservgldl/include/GameServ/DataLayer/File/FileItemDAO.h
1 #ifndef __GS__FILEITEMDAO_H__
2 #define __GS__FILEITEMDAO_H__
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
;
11 #include <boost/shared_ptr.hpp>
12 using boost::shared_ptr
;
23 namespace GameServ
{ namespace DataLayer
{ namespace File
25 //! File implementation of IItemDAO interface
27 If you're using an File datasource, you will be using this
30 class FileItemDAO
: public IItemDAO
33 // Ctors, Dtors ///////////////////////////////////////////////////////
35 FileItemDAO(const string
&filename
);
36 virtual ~FileItemDAO();
38 // Methods ////////////////////////////////////////////////////////////
39 virtual shared_ptr
<ItemGO
> GetById(const string
&Id
) const;
41 virtual bool IdExists(const string
&Id
) const;
43 void LoadItemCache(void);
45 virtual void Insert(shared_ptr
<ItemGO
> spItem
);
46 virtual void Update(shared_ptr
<ItemGO
> spItem
);
52 // Helper Methods /////////////////////////////////////////////////////
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;
58 //! Get the Item database file path
59 string
GetItemFilePath(void) const;
61 void Initialize(const string
&filename
);
64 map
<string
, shared_ptr
<ItemGO
> > spItemCache
;
66 } } } // GameServ.DataLayer.DataAccessObjects.File
68 #endif // __GS__FILEITEMDAO_H__