]> jfr.im git - irc/gameservirc.git/blob - gameserv-2.0/libgameservgldl/include/GameServ/DataLayer/MySQL/MySQLItemDAO.h
Scrapping work on the File DAOs and going straight for MySQL for now. The file based...
[irc/gameservirc.git] / gameserv-2.0 / libgameservgldl / include / GameServ / DataLayer / MySQL / MySQLItemDAO.h
1 #ifndef __GS__MYSQLITEMDAO_H__
2 #define __GS__MYSQLITEMDAO_H__
3
4 #include <GameServ/GameLayer/GameObjects/ItemGO.h>
5 using GameServ::GameLayer::GameObjects::ItemGO;
6 #include <GameServ/DataLayer/IItemDAO.h>
7 using GameServ::DataLayer::DataAccessObjects::IItemDAO;
8
9 #include <boost/shared_ptr.hpp>
10 using boost::shared_ptr;
11
12 #include <string>
13 using std::string;
14
15 #include <mysql++.h>
16 #include <ssqls.h>
17
18 namespace GameServ { namespace DataLayer { namespace MySQL
19 {
20 //! MySQL implementation of IItemDAO interface
21 /*!
22 If you're using an MySQL datasource, you will be using this
23 DAO to access Items.
24 */
25 sql_create_22(item, 1, 0,
26 mysqlpp::sql_varchar, id,
27 mysqlpp::sql_varchar, name,
28 mysqlpp::sql_int, strengthhigh,
29 mysqlpp::sql_int, strengthlow,
30 mysqlpp::sql_int, defensehigh,
31 mysqlpp::sql_int, defenselow,
32 mysqlpp::sql_int, healthhigh,
33 mysqlpp::sql_int, healthlow,
34 mysqlpp::sql_int, goldhigh,
35 mysqlpp::sql_int, goldlow,
36 mysqlpp::sql_int, experiencehigh,
37 mysqlpp::sql_int, experiencelow,
38 mysqlpp::sql_int, startinguses,
39 mysqlpp::sql_varchar, type,
40 mysqlpp::sql_int, bankhigh,
41 mysqlpp::sql_int, banklow,
42 mysqlpp::sql_int, forestfightshigh,
43 mysqlpp::sql_int, forestfightslow,
44 mysqlpp::sql_int, playerfightshigh,
45 mysqlpp::sql_int, playerfightslow,
46 mysqlpp::sql_int, maxhealthhigh,
47 mysqlpp::sql_int, maxhealthlow);
48
49 class MySQLItemDAO : public IItemDAO
50 {
51 public:
52 // Ctors, Dtors ///////////////////////////////////////////////////////
53 MySQLItemDAO(void);
54 virtual ~MySQLItemDAO();
55
56 // Methods ////////////////////////////////////////////////////////////
57 virtual shared_ptr<ItemGO> GetById(const string &Id) const;
58
59 virtual bool IdExists(const string &Id) const;
60
61 private:
62 //! Data mysql
63 string mTableName;
64
65 // Helper Methods /////////////////////////////////////////////////////
66
67 //! Creates the ItemGO found at iterator position
68 shared_ptr<ItemGO> CreateItemFromItemSSQLS(const item &i) const;
69
70 //! Get the Item database mysql path
71 string GetItemTableName(void) const;
72
73 void Initialize(const string &tablename);
74 };
75 } } } // GameServ.DataLayer.DataAccessObjects.MySQL
76
77 #endif // __GS__MYSQLITEMDAO_H__