Storage Class Reference

#include <storage.hpp>

Inheritance diagram for Storage:

DALStorage List of all members.

Detailed Description

A storage to load and persist dynamic data.

Notes:

Definition at line 48 of file storage.hpp.

Public Member Functions

virtual void open (void)=0
 Open the storage for read/write access.
virtual void close (void)=0
 Close the storage.
bool isOpen (void) const
 Check if the storage is open.
const std::string & getName (void) const
 Get the storage name.
void setUser (const std::string &userName)
 Set a user name for the storage.
const std::string & getUser (void) const
 Get the user name.
void setPassword (const std::string &password)
 Set a user password for the storage.
const std::string & getPassword (void) const
 Get the user password.
virtual AccountPtr getAccount (const std::string &userName)=0
 Get an account by user name.
virtual AccountPtr getAccountByID (int accountID)=0
 Get an account by ID.
virtual CharacterPtr getCharacter (int id)=0
 Gets a character by database ID.
virtual void addAccount (const AccountPtr &account)=0
 Add a new account.
virtual void delAccount (AccountPtr const &account)=0
 Delete an account.
virtual void unloadAccount (AccountPtr const &account)=0
 Flush and unload an account.
virtual std::list< std::string > getEmailList ()=0
 Get the list of Emails in the accounts list.
virtual bool doesEmailAddressExist (std::string const &email)=0
 Tells if the email address already exists.
virtual bool doesCharacterNameExist (std::string const &name)=0
 Tells if the character's name already exists.
virtual bool updateCharacter (CharacterPtr ptr)=0
 Updates the data for a single character, does not update the owning account or the characters name.
virtual std::map< short, ChatChannelgetChannelList ()=0
 Gives the list of opened public channels registered in database.
virtual void updateChannels (std::map< short, ChatChannel > &channelList)=0
 apply channel differences from the list in memory to the one in db.
virtual void flushAll ()=0
 Saves the changes to all the accounts permanently.
virtual void flush (AccountPtr const &account)=0
 Saves the changes to one account permanently.

Static Public Member Functions

Storageinstance (const std::string &name)
 Create a named instance of Storage.
void destroy (void)
 Delete the storage.

Protected Member Functions

 Storage (void) throw ()
 Default constructor.
virtual ~Storage (void) throw ()
 Destructor.
 Storage (const Storage &rhs)
 Copy constructor.
Storageoperator= (const Storage &rhs)
 Assignment operator.

Protected Attributes

Accounts mAccounts
 list of accounts in memory
Characters mCharacters
 the loaded characters
bool mIsOpen
 flag is true if the storage is open

Static Private Attributes

StoragemInstance = 0
 the unique instance of Storage
std::string mName
 the name of the storage
std::string mUser
 the user name
std::string mPassword
 the user password


Constructor & Destructor Documentation

Storage::Storage void   )  throw () [protected]
 

Default constructor.

Definition at line 36 of file storage.cpp.

Storage::~Storage void   )  throw () [protected, virtual]
 

Destructor.

Definition at line 46 of file storage.cpp.

Storage::Storage const Storage rhs  )  [protected]
 

Copy constructor.


Member Function Documentation

virtual void Storage::addAccount const AccountPtr account  )  [pure virtual]
 

Add a new account.

Parameters:
account the new account.

Implemented in DALStorage.

virtual void Storage::close void   )  [pure virtual]
 

Close the storage.

Depending on the underlying implementation of Storage, closing a storage would mean either closing a file or disconnecting from a database.

Implemented in DALStorage.

virtual void Storage::delAccount AccountPtr const &  account  )  [pure virtual]
 

Delete an account.

Parameters:
account the account to delete.

Implemented in DALStorage.

void Storage::destroy void   )  [static]
 

Delete the storage.

Definition at line 74 of file storage.cpp.

virtual bool Storage::doesCharacterNameExist std::string const &  name  )  [pure virtual]
 

Tells if the character's name already exists.

Returns:
true if character's name exists.

Implemented in DALStorage.

virtual bool Storage::doesEmailAddressExist std::string const &  email  )  [pure virtual]
 

Tells if the email address already exists.

Returns:
true if the email address exists.

Implemented in DALStorage.

virtual void Storage::flush AccountPtr const &  account  )  [pure virtual]
 

Saves the changes to one account permanently.

Implemented in DALStorage.

virtual void Storage::flushAll  )  [pure virtual]
 

Saves the changes to all the accounts permanently.

Implemented in DALStorage.

virtual AccountPtr Storage::getAccount const std::string &  userName  )  [pure virtual]
 

Get an account by user name.

Parameters:
userName the owner of the account.
Returns:
the account associated to the user name.

Implemented in DALStorage.

virtual AccountPtr Storage::getAccountByID int  accountID  )  [pure virtual]
 

Get an account by ID.

Parameters:
accountID the ID of the account.
Returns:
the account associated with the ID.

Implemented in DALStorage.

virtual std::map<short, ChatChannel> Storage::getChannelList  )  [pure virtual]
 

Gives the list of opened public channels registered in database.

Returns:
a map of the public channels

Implemented in DALStorage.

virtual CharacterPtr Storage::getCharacter int  id  )  [pure virtual]
 

Gets a character by database ID.

Parameters:
id the ID of the character.
Returns:
the character associated to the ID.

Implemented in DALStorage.

virtual std::list<std::string> Storage::getEmailList  )  [pure virtual]
 

Get the list of Emails in the accounts list.

Returns:
the list of Email's Addresses.

Deprecated:
The only purpose of using this list inside the server is for checking for existing email addresses, which is covered by Storage::getSameEmailNumber(). It could later be used for mailing list announcement.

Implemented in DALStorage.

const std::string & Storage::getName void   )  const
 

Get the storage name.

Returns:
the storage name.

Definition at line 102 of file storage.cpp.

const std::string & Storage::getPassword void   )  const
 

Get the user password.

Returns:
the user password (it may be an empty string if not set previously).

Definition at line 142 of file storage.cpp.

const std::string & Storage::getUser void   )  const
 

Get the user name.

Returns:
the user name (it may be an empty string if not set previously).

Definition at line 122 of file storage.cpp.

Storage & Storage::instance const std::string &  name  )  [static]
 

Create a named instance of Storage.

Parameters:
name the name of the storage.
Returns:
the unique instance of Storage.
Exceptions:
std::bad_alloc if the instance cannot be created.
Notes:
  • it is up to the underlying implementation of Storage to decide about what to do with the name, it could serve as the name of the database or the name of the file into which the storage will be dumped to.
  • the name of the storage is saved only when it's the first invocation of instance() or only when instance() is invoked after destroy().

Definition at line 57 of file storage.cpp.

bool Storage::isOpen void   )  const
 

Check if the storage is open.

Returns:
true if the storage is open.

Definition at line 92 of file storage.cpp.

virtual void Storage::open void   )  [pure virtual]
 

Open the storage for read/write access.

Depending on the underlying implementation of Storage, opening a storage would mean either opening a file or connecting to a database.

Implemented in DALStorage.

Storage& Storage::operator= const Storage rhs  )  [protected]
 

Assignment operator.

void Storage::setPassword const std::string &  password  ) 
 

Set a user password for the storage.

Depending on the underlying implementation of Storage, setting the user password may have no effect (e.g. DALStorage running on SQLite).

Parameters:
password the user password.

Definition at line 132 of file storage.cpp.

void Storage::setUser const std::string &  userName  ) 
 

Set a user name for the storage.

Depending on the underlying implementation of Storage, setting the user name may have no effect (e.g. DALStorage running on SQLite).

Parameters:
userName the user name.

Definition at line 112 of file storage.cpp.

virtual void Storage::unloadAccount AccountPtr const &  account  )  [pure virtual]
 

Flush and unload an account.

Parameters:
account the account to unload.

Implemented in DALStorage.

virtual void Storage::updateChannels std::map< short, ChatChannel > &  channelList  )  [pure virtual]
 

apply channel differences from the list in memory to the one in db.

Implemented in DALStorage.

virtual bool Storage::updateCharacter CharacterPtr  ptr  )  [pure virtual]
 

Updates the data for a single character, does not update the owning account or the characters name.

Primary usage should be storing characterdata received from a game server. returns true if succefull, false otherwise.

Implemented in DALStorage.


Member Data Documentation

Accounts Storage::mAccounts [protected]
 

list of accounts in memory

Definition at line 308 of file storage.hpp.

Characters Storage::mCharacters [protected]
 

the loaded characters

Definition at line 309 of file storage.hpp.

Storage * Storage::mInstance = 0 [static, private]
 

the unique instance of Storage

Definition at line 27 of file storage.cpp.

bool Storage::mIsOpen [protected]
 

flag is true if the storage is open

Definition at line 310 of file storage.hpp.

std::string Storage::mName [static, private]
 

the name of the storage

std::string Storage::mPassword [static, private]
 

the user password

std::string Storage::mUser [static, private]
 

the user name


The documentation for this class was generated from the following files:
Generated on Fri Mar 30 15:39:18 2007 for TMW Server by  doxygen 1.3.9.1