obby::user_table Class Reference

#include <user_table.hpp>

List of all members.

Public Types

typedef std::map< unsigned
int, user * > 
user_map
typedef user_map::size_type size_type
typedef user_map::const_iterator base_iterator
typedef sigc::signal< void > signal_deserialised_type

Public Member Functions

 user_table ()
virtual ~user_table ()
void serialise (serialise::object &obj) const
void deserialise (const serialise::object &obj)
void clear ()
const obby::useradd_user (unsigned int id, const net6::user &user, const colour &colour)
const obby::useradd_user (unsigned int id, const std::string &name, const colour &colour)
void remove_user (const user &user_to_remove)
void set_user_password (const user &user, const std::string &password)
void set_user_colour (const user &user, const colour &colour)
unsigned int find_free_id () const
iterator begin (user::flags inc_flags, user::flags exc_flags) const
iterator end (user::flags inc_flags, user::flags exc_flags) const
const userfind (unsigned int id, user::flags inc_flags, user::flags exc_flags) const
const userfind (const net6::user &user, user::flags inc_flags, user::flags exc_flags) const
const userfind (const std::string &name, user::flags inc_flags, user::flags exc_flags) const
size_type count (user::flags inc_flags, user::flags exc_flags) const
signal_deserialised_type deserialised_event () const
 Signal that is emitted after the user table has been deserialised.

Protected Member Functions

userlookup (unsigned int id)
userfind_int (const std::string &name)

Protected Attributes

user_map m_user_map
signal_deserialised_type m_signal_deserialised

Classes

class  iterator


Detailed Description

Table that contains all users.

Definition at line 34 of file user_table.hpp.


Member Typedef Documentation

typedef std::map<unsigned int, user*> obby::user_table::user_map

Definition at line 37 of file user_table.hpp.

typedef user_map::size_type obby::user_table::size_type

Definition at line 38 of file user_table.hpp.

typedef user_map::const_iterator obby::user_table::base_iterator

Definition at line 39 of file user_table.hpp.

typedef sigc::signal<void> obby::user_table::signal_deserialised_type

Definition at line 137 of file user_table.hpp.


Constructor & Destructor Documentation

obby::user_table::user_table (  ) 

Definition at line 23 of file user_table.cpp.

obby::user_table::~user_table (  )  [virtual]

Definition at line 27 of file user_table.cpp.

References clear().


Member Function Documentation

void obby::user_table::serialise ( serialise::object obj  )  const

Serialises a user_table to a serialisation object.

Definition at line 32 of file user_table.cpp.

References obby::serialise::object::add_child(), and m_user_map.

Referenced by obby::basic_buffer< Document, Selector >::serialise().

void obby::user_table::deserialise ( const serialise::object obj  ) 

Deserialises a user_table from a serialisation object.

Definition at line 42 of file user_table.cpp.

References obby::_(), obby::serialise::object::children_begin(), obby::serialise::object::children_end(), m_signal_deserialised, m_user_map, and obby::basic_format_string< string_type, stream_type >::str().

Referenced by obby::basic_server_buffer< Document, Selector >::open().

void obby::user_table::clear (  ) 

Clears all users from the user table.

Definition at line 84 of file user_table.cpp.

References m_user_map.

Referenced by ~user_table().

const obby::user * obby::user_table::add_user ( unsigned int  id,
const net6::user &  user,
const colour colour 
)

Adds a new user to the user list. The name and ID is read from the net6::user object. Because of the fact that a net6::user object exists, the new user will be marked as connected. If a user with the same ID exists, and is not connected, the net6::user will be assigned to this user, the colour is updated. If a user with this ID is already connected, std::logic_error is thrown.

Definition at line 92 of file user_table.cpp.

References obby::user::assign_net6(), obby::user::flags::CONNECTED, find_int(), obby::user::get_flags(), and m_user_map.

Referenced by obby::basic_client_buffer< Document, Selector >::on_join().

const obby::user * obby::user_table::add_user ( unsigned int  id,
const std::string &  name,
const colour colour 
)

Adds a new user to the user list. No net6::user exists, so the connected flag will not be set. If a user with this ID exists already, std::logic_error will be thrown.

Definition at line 125 of file user_table.cpp.

References find_int(), and m_user_map.

void obby::user_table::remove_user ( const user user_to_remove  ) 

Removes a user from the user list. This means that this user gets marked as non-connected and the reference to the underlaying net6::user object is dropped.

Definition at line 147 of file user_table.cpp.

Referenced by obby::basic_buffer< Document, Selector >::user_part().

void obby::user_table::set_user_password ( const user user,
const std::string &  password 
)

Assigns a password to this user.

Definition at line 154 of file user_table.cpp.

References obby::user::get_id(), and lookup().

void obby::user_table::set_user_colour ( const user user,
const colour colour 
)

Changes this user's colour.

Definition at line 160 of file user_table.cpp.

References obby::user::get_id(), and lookup().

Referenced by obby::basic_server_buffer< Document, Selector >::user_colour_impl().

unsigned int obby::user_table::find_free_id (  )  const

Looks for a new user ID that is currently not in use by another user.

Definition at line 166 of file user_table.cpp.

References m_user_map.

obby::user_table::iterator obby::user_table::begin ( user::flags  inc_flags,
user::flags  exc_flags 
) const

Returns the beginning of the user list.

Definition at line 176 of file user_table.cpp.

References m_user_map.

Referenced by obby::basic_buffer< Document, Selector >::check_colour(), count(), obby::basic_server_buffer< Document, Selector >::document_create_impl(), obby::basic_server_buffer< Document, Selector >::on_command_emote(), obby::basic_server_buffer< Document, Selector >::on_join(), obby::basic_server_buffer< Document, Selector >::session_close_impl(), obby::basic_local_buffer< Document, Selector >::session_close_impl(), and obby::basic_server_buffer< Document, Selector >::set_enable_keepalives().

obby::user_table::iterator obby::user_table::end ( user::flags  inc_flags,
user::flags  exc_flags 
) const

Returns the end of the user list.

TODO: No need for flags here?

Definition at line 182 of file user_table.cpp.

References m_user_map.

Referenced by obby::basic_buffer< Document, Selector >::check_colour(), count(), obby::basic_server_buffer< Document, Selector >::document_create_impl(), obby::basic_server_buffer< Document, Selector >::on_command_emote(), obby::basic_server_buffer< Document, Selector >::on_join(), obby::basic_server_buffer< Document, Selector >::session_close_impl(), obby::basic_local_buffer< Document, Selector >::session_close_impl(), and obby::basic_server_buffer< Document, Selector >::set_enable_keepalives().

const obby::user * obby::user_table::find ( unsigned int  id,
user::flags  inc_flags,
user::flags  exc_flags 
) const

Searches a user with the given flags that has the given ID.

Definition at line 188 of file user_table.cpp.

References obby::user_table::iterator::check_flags(), and m_user_map.

Referenced by serialise::user_table_find().

const obby::user * obby::user_table::find ( const net6::user &  user,
user::flags  inc_flags,
user::flags  exc_flags 
) const

Searches a user which represents the given underlaying net6::user object.

Definition at line 200 of file user_table.cpp.

References obby::user_table::iterator::check_flags(), obby::user::flags::CONNECTED, obby::user::get_flags(), and m_user_map.

const obby::user * obby::user_table::find ( const std::string &  name,
user::flags  inc_flags,
user::flags  exc_flags 
) const

Searches for a user with the given name.

Definition at line 219 of file user_table.cpp.

References obby::user_table::iterator::check_flags(), obby::user::get_flags(), and m_user_map.

obby::user_table::size_type obby::user_table::count ( user::flags  inc_flags,
user::flags  exc_flags 
) const

Counts users.

Definition at line 236 of file user_table.cpp.

References begin(), end(), m_user_map, and obby::user::flags::NONE.

Referenced by obby::basic_server_buffer< Document, Selector >::on_login().

obby::user_table::signal_deserialised_type obby::user_table::deserialised_event (  )  const

Signal that is emitted after the user table has been deserialised.

Definition at line 255 of file user_table.cpp.

References m_signal_deserialised.

Referenced by obby::basic_host_buffer< Document, Selector >::init_impl().

obby::user & obby::user_table::lookup ( unsigned int  id  )  [protected]

Internal function to find a user with the given ID that has to be in the user table.

Definition at line 260 of file user_table.cpp.

References m_user_map.

Referenced by set_user_colour(), and set_user_password().

obby::user * obby::user_table::find_int ( const std::string &  name  )  [protected]

Internal function to find a non-const user with the given name.

Definition at line 269 of file user_table.cpp.

References m_user_map.

Referenced by add_user().


Member Data Documentation

user_map obby::user_table::m_user_map [protected]

List holding the users.

Definition at line 244 of file user_table.hpp.

Referenced by add_user(), begin(), clear(), count(), deserialise(), end(), find(), find_free_id(), find_int(), lookup(), and serialise().

signal_deserialised_type obby::user_table::m_signal_deserialised [protected]

Definition at line 246 of file user_table.hpp.

Referenced by deserialise(), and deserialised_event().


The documentation for this class was generated from the following files:
Generated on Fri Jan 11 10:01:33 2008 for obby by  doxygen 1.5.1