diff options
author | Huynh Tran <nthuynh75@gmail.com> | 2005-06-21 19:46:40 +0000 |
---|---|---|
committer | Huynh Tran <nthuynh75@gmail.com> | 2005-06-21 19:46:40 +0000 |
commit | 49d79a345c8c4929d9bb787af9f4f0090c888537 (patch) | |
tree | 387b3a8d738d570ad1493be0273751c7a145cf20 /src/storage.cpp | |
parent | 816d8acd16faeb20713c3d09466003a444940f6f (diff) | |
download | manaserv-49d79a345c8c4929d9bb787af9f4f0090c888537.tar.gz manaserv-49d79a345c8c4929d9bb787af9f4f0090c888537.tar.bz2 manaserv-49d79a345c8c4929d9bb787af9f4f0090c888537.tar.xz manaserv-49d79a345c8c4929d9bb787af9f4f0090c888537.zip |
Improved Storage APIs and moved debug code to unit tests.
Diffstat (limited to 'src/storage.cpp')
-rw-r--r-- | src/storage.cpp | 76 |
1 files changed, 74 insertions, 2 deletions
diff --git a/src/storage.cpp b/src/storage.cpp index b5476426..adea90e6 100644 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -31,8 +31,11 @@ namespace tmwserv { -// initialize the static attribute. +// initialize the static attributes. Storage* Storage::mInstance = 0; +std::string Storage::mName(""); +std::string Storage::mUser(""); +std::string Storage::mPassword(""); /** @@ -59,10 +62,13 @@ Storage::~Storage(void) * Create an instance of Storage. */ Storage& -Storage::instance(void) +Storage::instance(const std::string& name) { if (mInstance == 0) { mInstance = new DALStorage(); + + // set the name of the storage. + mName = name; } // check that the instance has been created. @@ -82,7 +88,73 @@ Storage::destroy(void) { if (mInstance != 0) { delete mInstance; + mInstance = 0; } + + // reset the attributes. + mName = ""; + mUser = ""; + mPassword = ""; +} + + +/** + * Check if the storage is open. + */ +bool +Storage::isOpen(void) const +{ + return mIsOpen; +} + + +/** + * Get the storage name. + */ +const std::string& +Storage::getName(void) const +{ + return mName; +} + + +/** + * Set a user name for the storage. + */ +void +Storage::setUser(const std::string& userName) +{ + mUser = userName; +} + + +/** + * Get the user name. + */ +const std::string& +Storage::getUser(void) const +{ + return mUser; +} + + +/** + * Set a user password for the storage. + */ +void +Storage::setPassword(const std::string& password) +{ + mPassword = password; +} + + +/** + * Get the user password. + */ +const std::string& +Storage::getPassword(void) const +{ + return mPassword; } |