summaryrefslogtreecommitdiff
path: root/src/storage.h
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-06-12 22:44:11 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-06-12 22:44:11 +0000
commit7c7a1348faa3867f6f2e5fcaf2b671774b1b018a (patch)
treee2a8e67d76547f0d83e07687fefdee65aee3497b /src/storage.h
parent9fa9cb8fa13049fa4ba28d31159b4e1a0c6c0432 (diff)
downloadmanaserv-7c7a1348faa3867f6f2e5fcaf2b671774b1b018a.tar.gz
manaserv-7c7a1348faa3867f6f2e5fcaf2b671774b1b018a.tar.bz2
manaserv-7c7a1348faa3867f6f2e5fcaf2b671774b1b018a.tar.xz
manaserv-7c7a1348faa3867f6f2e5fcaf2b671774b1b018a.zip
Moved SQLiteStorage to subclass of Storage, made Storage a singleton and
updated SQL tables a bit.
Diffstat (limited to 'src/storage.h')
-rw-r--r--src/storage.h63
1 files changed, 23 insertions, 40 deletions
diff --git a/src/storage.h b/src/storage.h
index 5cf96eb4..e5be589d 100644
--- a/src/storage.h
+++ b/src/storage.h
@@ -20,66 +20,49 @@
*
* $Id$
*/
-#ifndef STORAGE_H
-#define STORAGE_H
-
-#ifdef SQLITE_SUPPORT
-#include "sqlite/SQLiteWrapper.h"
-#endif
+#ifndef TMWSERV_STORAGE_H
+#define TMWSERV_STORAGE_H
#include "object.h"
#include "account.h"
-/*
- * Storage
- * Storage is the resource manager
- */
-class Storage {
- //make storage singleton
- Storage(const Storage &n) { }
-
-#ifdef SQLITE_SUPPORT
- SQLiteWrapper sqlite; /**< Database */
-#endif
- std::vector<Account*> accounts; /**< Loaded account data */
- std::vector<Being*> characters; /**< Loaded account data */
-
+/**
+ * A storage of persistent dynamic data.
+ */
+class Storage
+{
public:
- /**
- * Constructor.
- */
- Storage();
+ static Storage *getInstance();
+ static void deleteInstance();
/**
- * Destructor.
+ * Make sure any changes are saved.
*/
- ~Storage();
+ virtual void flush() = 0;
/**
- * Create tables if master is empty
+ * Account count (test function).
*/
- void create_tables_if_necessary();
+ virtual unsigned int getAccountCount() = 0;
/**
- * Save changes to database
+ * Get account by username.
*/
- void save();
+ virtual Account *getAccount(const std::string &username) = 0;
+ protected:
/**
- * Account count (test function)
+ * Constructor.
*/
- unsigned int accountCount();
+ Storage();
/**
- * Get account & associated data
+ * Destructor.
*/
- Account* getAccount(const std::string &username);
+ virtual ~Storage();
- /**
- * Get character of username
- */
- Being* getCharacter(const std::string &username);
+ private:
+ static Storage *instance;
};
-#endif /* STORAGE_H */
-
+#endif /* TMWSERV_STORAGE_H */