ManaPlus
Public Member Functions | Static Public Member Functions | Data Fields | Static Public Attributes
ChatObject Struct Reference

#include <chatobject.h>

Public Member Functions

 ChatObject ()
 
 ~ChatObject ()
 
void update ()
 

Static Public Member Functions

static ChatObjectfindByName (const std::string &name)
 
static ChatObjectfindById (const int id)
 

Data Fields

BeingId ownerId
 
int chatId
 
uint16_t maxUsers
 
uint16_t currentUsers
 
uint8_t type
 
std::string title
 

Static Public Attributes

static std::map< std::string, ChatObject * > chatNameMap
 
static std::map< int, ChatObject * > chatIdMap
 

Detailed Description

Definition at line 32 of file chatobject.h.

Constructor & Destructor Documentation

◆ ChatObject()

ChatObject::ChatObject ( )

Definition at line 29 of file chatobject.cpp.

29  :
31  chatId(0),
32  maxUsers(0),
33  currentUsers(0),
34  type(0),
35  title()
36 {
37 }
const BeingId BeingId_zero
Definition: beingid.h:30
std::string title
Definition: chatobject.h:51
uint16_t maxUsers
Definition: chatobject.h:48
int chatId
Definition: chatobject.h:47
uint8_t type
Definition: chatobject.h:50
BeingId ownerId
Definition: chatobject.h:46
uint16_t currentUsers
Definition: chatobject.h:49

◆ ~ChatObject()

ChatObject::~ChatObject ( )

Definition at line 39 of file chatobject.cpp.

40 {
41  std::map<std::string, ChatObject*>::iterator it = chatNameMap.find(title);
42  if (it != chatNameMap.end() && (*it).second == this)
43  chatNameMap.erase(it);
44  std::map<int, ChatObject*>::iterator it2 = chatIdMap.find(chatId);
45  if (it2 != chatIdMap.end() && (*it2).second == this)
46  chatIdMap.erase(it2);
47 }
static std::map< int, ChatObject * > chatIdMap
Definition: chatobject.h:54
static std::map< std::string, ChatObject * > chatNameMap
Definition: chatobject.h:53

References chatId, chatIdMap, chatNameMap, and title.

Member Function Documentation

◆ findById()

ChatObject * ChatObject::findById ( const int  id)
static

Definition at line 64 of file chatobject.cpp.

65 {
66  const std::map<int, ChatObject*>::iterator it = chatIdMap.find(id);
67  if (it == chatIdMap.end())
68  return nullptr;
69  return (*it).second;
70 }

References chatIdMap.

Referenced by EAthena::ChatRecv::processChatRoomJoinAck().

◆ findByName()

ChatObject * ChatObject::findByName ( const std::string &  name)
static

Definition at line 55 of file chatobject.cpp.

56 {
57  const std::map<std::string, ChatObject*>::iterator it =
58  chatNameMap.find(name);
59  if (it == chatNameMap.end())
60  return nullptr;
61  return (*it).second;
62 }

References chatNameMap.

◆ update()

void ChatObject::update ( )

Definition at line 49 of file chatobject.cpp.

50 {
51  chatNameMap[title] = this;
52  chatIdMap[chatId] = this;
53 }

References chatId, chatIdMap, chatNameMap, and title.

Referenced by EAthena::ChatRecv::processChatDisplay(), and EAthena::ChatRecv::processChatRoomCreateAck().

Field Documentation

◆ chatId

int ChatObject::chatId

◆ chatIdMap

std::map< int, ChatObject * > ChatObject::chatIdMap
static

Definition at line 54 of file chatobject.h.

Referenced by findById(), update(), and ~ChatObject().

◆ chatNameMap

std::map< std::string, ChatObject * > ChatObject::chatNameMap
static

Definition at line 53 of file chatobject.h.

Referenced by findByName(), update(), and ~ChatObject().

◆ currentUsers

uint16_t ChatObject::currentUsers

◆ maxUsers

uint16_t ChatObject::maxUsers

◆ ownerId

BeingId ChatObject::ownerId

◆ title

std::string ChatObject::title

◆ type

uint8_t ChatObject::type

The documentation for this struct was generated from the following files: