summaryrefslogtreecommitdiff
path: root/src/account-server/dalstorage.hpp
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-08-30 16:20:33 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-08-30 16:20:33 +0000
commit25914cddf606e683a4226f46b56f800400d633d3 (patch)
tree58a95b50fc59a45459906d109b4768aa4124951d /src/account-server/dalstorage.hpp
parent5af1c90d2f86e10de74285d89ee975bd959a6556 (diff)
downloadmanaserv-25914cddf606e683a4226f46b56f800400d633d3.tar.gz
manaserv-25914cddf606e683a4226f46b56f800400d633d3.tar.bz2
manaserv-25914cddf606e683a4226f46b56f800400d633d3.tar.xz
manaserv-25914cddf606e683a4226f46b56f800400d633d3.zip
Got rid of abstract storage and reference-counted pointers. Fixed lifetime of accounts and characters in server memory. Cleaned some code.
Diffstat (limited to 'src/account-server/dalstorage.hpp')
-rw-r--r--src/account-server/dalstorage.hpp82
1 files changed, 40 insertions, 42 deletions
diff --git a/src/account-server/dalstorage.hpp b/src/account-server/dalstorage.hpp
index c25b3fc2..00ba58cc 100644
--- a/src/account-server/dalstorage.hpp
+++ b/src/account-server/dalstorage.hpp
@@ -24,10 +24,14 @@
#ifndef _TMWSERV_DALSTORAGE_H_
#define _TMWSERV_DALSTORAGE_H_
-#include "account-server/characterdata.hpp"
-#include "account-server/storage.hpp"
+#include <list>
+#include <map>
+
#include "dal/dataprovider.h"
+class Account;
+class Character;
+class ChatChannel;
class Guild;
/**
@@ -37,13 +41,21 @@ class Guild;
* - this class cannot be instanciated nor duplicated in order to force
* a user class to use the Storage singleton.
*/
-class DALStorage: public Storage
+class DALStorage
{
- // friend so that Storage can call the constructor.
- friend class Storage;
+ public:
+ /**
+ * Constructor.
+ */
+ DALStorage();
+
+
+ /**
+ * Destructor.
+ */
+ ~DALStorage();
- public:
/**
* Connect to the database and initialize it if necessary.
*/
@@ -63,8 +75,7 @@ class DALStorage: public Storage
*
* @return the account associated to the user name.
*/
- AccountPtr
- getAccount(const std::string& userName);
+ Account *getAccount(const std::string& userName);
/**
* Get an account by ID.
@@ -73,18 +84,19 @@ class DALStorage: public Storage
*
* @return the account associated with the ID.
*/
- AccountPtr
- getAccountByID(int accountID);
+ Account *getAccount(int accountID);
/**
* Gets a character by database ID.
*
* @param id the ID of the character.
+ * @param owner the account the character is in.
*
* @return the character associated to the ID.
*/
- CharacterPtr getCharacter(int id);
-
+ Character *getCharacter(int id, Account *owner);
+
+#if 0
/**
* Gets a character by character name.
*
@@ -92,7 +104,8 @@ class DALStorage: public Storage
*
* @return the character associated to the name
*/
- CharacterPtr getCharacter(const std::string &name);
+ Character *getCharacter(const std::string &name);
+#endif
/**
* Add a new account.
@@ -100,7 +113,7 @@ class DALStorage: public Storage
* @param account the new account.
*/
void
- addAccount(const AccountPtr& account);
+ addAccount(Account *account);
/**
@@ -108,21 +121,16 @@ class DALStorage: public Storage
*
* @param account the account to delete.
*/
- void delAccount(AccountPtr const &account);
-
- /**
- * Flush and unload an account.
- *
- * @param account the account to unload.
- */
- void unloadAccount(AccountPtr const &account);
+ void delAccount(Account *account);
+#if 0
/**
* Get the list of Emails in the accounts list.
* @return the list of Email's Addresses.
*/
std::list<std::string>
getEmailList();
+#endif
/**
* Tells if the email address already exists.
@@ -144,7 +152,7 @@ class DALStorage: public Storage
* returns true if succefull, false otherwise.
*/
bool
- updateCharacter(CharacterPtr ptr);
+ updateCharacter(Character *ptr);
/**
* Gives the list of opened public channels registered in database
@@ -201,7 +209,7 @@ class DALStorage: public Storage
* @exception tmwserv::dal::DbSqlQueryExecFailure.
*/
void flushAll();
- void flush(AccountPtr const &);
+ void flush(Account *);
/**
* Gets the value of a quest variable.
@@ -216,18 +224,6 @@ class DALStorage: public Storage
private:
/**
- * Constructor.
- */
- DALStorage();
-
-
- /**
- * Destructor.
- */
- ~DALStorage();
-
-
- /**
* Copy constructor.
*/
DALStorage(const DALStorage& rhs);
@@ -260,20 +256,22 @@ class DALStorage: public Storage
*
* @return the account found by the query
*/
- AccountPtr getAccountBySQL(std::string const &query);
+ Account *getAccountBySQL(std::string const &query);
/**
* Gets a character by character name.
*
- * @param query the query for the character
+ * @param query the query for the character.
+ * @param owner the account the character is in.
*
- * @return the character found by the query
+ * @return the character found by the query.
*/
- CharacterPtr getCharacterBySQL(const std::string &query);
+ Character *getCharacterBySQL(std::string const &query, Account *owner);
-
- std::auto_ptr<dal::DataProvider> mDb; /**< the data provider */
+ dal::DataProvider *mDb; /**< the data provider */
};
+extern DALStorage *storage;
+
#endif // _TMWSERV_DALSTORAGE_H_