obby::chat Class Reference

#include <chat.hpp>

List of all members.

Public Types

typedef ptr_iterator< message,
std::list< message * >, std::list<
message * >::const_iterator > 
message_iterator
typedef sigc::signal< void,
const message & > 
signal_message_type

Public Member Functions

template<typename Buffer>
 chat (const Buffer &buffer, unsigned int max_messages)
 ~chat ()
void serialise (serialise::object &obj) const
void deserialise (const serialise::object &obj, const user_table &user_table)
void clear ()
void add_user_message (const std::string &text, const user &from)
void add_emote_message (const std::string &text, const user &from)
 Adds a new emote message to the history.
void add_server_message (const std::string &text)
message_iterator message_begin () const
message_iterator message_end () const
signal_message_type message_event () const

Protected Member Functions

void add_message (message *msg)
void on_sync_init (unsigned int)
void on_sync_final ()
void on_user_join (const user &user)
void on_user_part (const user &user)
template<typename DocumentInfo>
void on_document_insert (DocumentInfo &document)
template<typename DocumentInfo>
void on_document_remove (DocumentInfo &document)

Protected Attributes

unsigned int m_max_messages
std::list< message * > m_messages
signal_message_type m_signal_message
sigc::connection m_user_join_conn
sigc::connection m_user_part_conn
sigc::connection m_document_insert_conn
sigc::connection m_document_remove_conn

Classes

class  emote_message
 Emote message by /me command. More...
class  message
class  server_message
class  system_message
class  user_message


Detailed Description

Handles obby chat messages.

Definition at line 35 of file chat.hpp.


Member Typedef Documentation

typedef ptr_iterator< message, std::list<message*>, std::list<message*>::const_iterator > obby::chat::message_iterator

Definition at line 125 of file chat.hpp.

typedef sigc::signal<void, const message&> obby::chat::signal_message_type

Definition at line 128 of file chat.hpp.


Constructor & Destructor Documentation

template<typename Buffer>
obby::chat::chat ( const Buffer &  buffer,
unsigned int  max_messages 
)

Chat constructor.

Parameters:
buffer Buffer owning this chat. TODO: Just take user_table and connect to user_table's signals
max_messages How many messages to store before deleting old ones.

Definition at line 209 of file chat.hpp.

References m_document_insert_conn, m_document_remove_conn, m_user_join_conn, m_user_part_conn, on_sync_final(), on_sync_init(), on_user_join(), and on_user_part().

obby::chat::~chat (  ) 

Definition at line 192 of file chat.cpp.

References clear().


Member Function Documentation

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

Serialises the chat history to a serialisation object.

Parameters:
obj Object to serialise to.

Definition at line 197 of file chat.cpp.

References obby::serialise::object::add_child(), message_begin(), message_end(), and obby::serialise::object::set_name().

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

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

Deserialises a chat history from a serialisation object.

Parameters:
obj Object to deserialise from.
user_table user_table where to read user information from.

Definition at line 223 of file chat.cpp.

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

void obby::chat::clear (  ) 

Clears the whole history.

Definition at line 260 of file chat.cpp.

References m_messages.

Referenced by deserialise(), and ~chat().

void obby::chat::add_user_message ( const std::string &  text,
const user from 
)

Adds a new user message to the history.

Definition at line 272 of file chat.cpp.

References add_message().

void obby::chat::add_emote_message ( const std::string &  text,
const user from 
)

Adds a new emote message to the history.

Definition at line 278 of file chat.cpp.

References add_message().

void obby::chat::add_server_message ( const std::string &  text  ) 

Adds a new server message to the history.

Definition at line 284 of file chat.cpp.

References add_message().

obby::chat::message_iterator obby::chat::message_begin (  )  const

Returns an iterator pointing at the beginning of the chat history.

Definition at line 289 of file chat.cpp.

References m_messages.

Referenced by serialise().

obby::chat::message_iterator obby::chat::message_end (  )  const

Returns an iterator pointing at the end of the chat history.

Definition at line 294 of file chat.cpp.

References m_messages.

Referenced by serialise().

obby::chat::signal_message_type obby::chat::message_event (  )  const

Signal that will be emitted if a user message arrived.

Definition at line 299 of file chat.cpp.

References m_signal_message.

void obby::chat::add_message ( message msg  )  [protected]

Definition at line 304 of file chat.cpp.

References m_max_messages, m_messages, and m_signal_message.

Referenced by add_emote_message(), add_server_message(), add_user_message(), deserialise(), on_document_insert(), on_document_remove(), on_user_join(), and on_user_part().

void obby::chat::on_sync_init ( unsigned  int  )  [protected]

Definition at line 311 of file chat.cpp.

References m_document_insert_conn, m_document_remove_conn, m_user_join_conn, and m_user_part_conn.

Referenced by chat().

void obby::chat::on_sync_final (  )  [protected]

Definition at line 319 of file chat.cpp.

References m_document_insert_conn, m_document_remove_conn, m_user_join_conn, and m_user_part_conn.

Referenced by chat().

void obby::chat::on_user_join ( const user user  )  [protected]

Definition at line 327 of file chat.cpp.

References obby::_(), add_message(), obby::user::flags::CONNECTED, obby::user::get_flags(), obby::user::get_name(), and obby::basic_format_string< string_type, stream_type >::str().

Referenced by chat().

void obby::chat::on_user_part ( const user user  )  [protected]

Definition at line 337 of file chat.cpp.

References obby::_(), add_message(), obby::user::get_name(), and obby::basic_format_string< string_type, stream_type >::str().

Referenced by chat().

template<typename DocumentInfo>
void obby::chat::on_document_insert ( DocumentInfo &  document  )  [protected]

Definition at line 239 of file chat.hpp.

References obby::_(), add_message(), and obby::basic_format_string< string_type, stream_type >::str().

template<typename DocumentInfo>
void obby::chat::on_document_remove ( DocumentInfo &  document  )  [protected]

Definition at line 263 of file chat.hpp.

References obby::_(), add_message(), and obby::basic_format_string< string_type, stream_type >::str().


Member Data Documentation

unsigned int obby::chat::m_max_messages [protected]

Definition at line 197 of file chat.hpp.

Referenced by add_message().

std::list<message*> obby::chat::m_messages [protected]

Definition at line 198 of file chat.hpp.

Referenced by add_message(), clear(), message_begin(), and message_end().

signal_message_type obby::chat::m_signal_message [protected]

Definition at line 200 of file chat.hpp.

Referenced by add_message(), and message_event().

sigc::connection obby::chat::m_user_join_conn [protected]

Definition at line 202 of file chat.hpp.

Referenced by chat(), on_sync_final(), and on_sync_init().

sigc::connection obby::chat::m_user_part_conn [protected]

Definition at line 203 of file chat.hpp.

Referenced by chat(), on_sync_final(), and on_sync_init().

sigc::connection obby::chat::m_document_insert_conn [protected]

Definition at line 204 of file chat.hpp.

Referenced by chat(), on_sync_final(), and on_sync_init().

sigc::connection obby::chat::m_document_remove_conn [protected]

Definition at line 205 of file chat.hpp.

Referenced by chat(), on_sync_final(), and on_sync_init().


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