Eris  1.4.0
Room.h
1 #ifndef ERIS_ROOM_H
2 #define ERIS_ROOM_H
3 
4 #include "Router.h"
5 
6 #include <sigc++/trackable.h>
7 #include <sigc++/signal.h>
8 
9 #include <vector>
10 #include <unordered_map>
11 #include <string>
12 
13 namespace Eris
14 {
15 
16 // forward decls
17 class Person;
18 class Lobby;
19 
24 class Room : public sigc::trackable, public Router
25 {
26 public:
27  virtual ~Room();
28 
30  void say(const std::string &tk);
31 
34  void emote(const std::string &em);
35 
38  void leave();
39 
44  Room* createRoom(const std::string &name);
45 
47  std::string getName() const
48  {
49  return m_name;
50  }
51 
52  std::string getTopic() const
53  {
54  return m_topic;
55  }
56 
58  std::vector<Person*> getPeople() const;
59 
61  std::vector<Room*> getRooms() const
62  {
63  return m_subrooms;
64  }
65 
68  std::string getId() const
69  {
70  return m_roomId;
71  }
72 
73  Person* getPersonByUID(const std::string& uid);
74 
75 // signals
78  sigc::signal<void, Room*> Entered;
79 
82  sigc::signal<void, Room*, Person*, const std::string&> Speech;
83 
85  sigc::signal<void, Room*, Person*, const std::string&> Emote;
86 
90  sigc::signal<void, Room*, Person*> Appearance;
91 
93  sigc::signal<void, Room*, Person*> Disappearance;
94 
95 
96 protected:
97  friend class Lobby;
98 
99  typedef std::unordered_map<std::string, Person*> IdPersonMap;
100 
103  explicit Room(Lobby *l, const std::string& id);
104 
105  virtual RouterResult handleOperation(const Atlas::Objects::Operation::RootOperation& op);
106  void handleSoundTalk(Person* p, const std::string& speech);
107  void handleEmote(Person* p, const std::string& desc);
108 
109 
110  std::string m_roomId;
111 private:
113  void checkEntry();
114 
115  void sight(const Atlas::Objects::Entity::RootEntity &room);
116 
117  void appearance(const std::string& personId);
118  void disappearance(const std::string& personId);
119 
120  // callback slot when Lobby recives SIGHT(person)
121  void notifyPersonSight(Person *p);
122 
123  std::string m_name;
124  std::string m_topic;
125  bool m_entered;
126  Lobby* m_lobby;
127 
128  IdPersonMap m_members;
129 
130  std::vector<Room*> m_subrooms;
131 };
132 
133 }
134 
135 #endif
Room(Lobby *l, const std::string &id)
standard constructor.
Definition: Room.cpp:29
std::string getId() const
Get the Atlas object ID of the Room; note that this may return an empty value if called prior to ente...
Definition: Room.h:68
sigc::signal< void, Room *, Person *, const std::string & > Emote
Emote (/me) callback.
Definition: Room.h:85
std::string getName() const
Obtain the human-readable name of this room.
Definition: Room.h:47
void emote(const std::string &em)
Send an emote ( /me ) to the room.
Definition: Room.cpp:67
std::vector< Room * > getRooms() const
Obtain a list of rooms within this room.
Definition: Room.h:61
sigc::signal< void, Room *, Person * > Disappearance
Similarly, emitted when the specifed person leaves the room.
Definition: Room.h:93
Every Eris class and type lives inside the Eris namespace; certain utility functions live in the Util...
Definition: Account.cpp:34
sigc::signal< void, Room *, Person * > Appearance
Emitted when a person enters the room; argument is the account ID.
Definition: Room.h:90
sigc::signal< void, Room * > Entered
Emitted when entry into the room (after a Join) is complete, i.e the user list has been transferred a...
Definition: Room.h:78
sigc::signal< void, Room *, Person *, const std::string & > Speech
The primary talk callback.
Definition: Room.h:82
void say(const std::string &tk)
Send a piece of text to this room.
Definition: Room.cpp:46
void leave()
Leave the room - no more signals will be emitted for this room again (validity of Room pointer after ...
Definition: Room.cpp:90
Lobby is the Out-of-Game session object, valid from connection to the server until disconnection...
Definition: Lobby.h:25
The out-of-game (OOG) heirarchy is composed of Rooms, containing Persons and other Rooms...
Definition: Room.h:24
std::vector< Person * > getPeople() const
obtain an array of pointers to everyone in this room
Definition: Room.cpp:139
An Out-of-Game Person (found in a Room / Lobby) As more person data becomes available, this class will be extended, for example to return nicknames, location, the choosen &#39;face&#39; graphic.
Definition: Person.h:15
abstract interface for objects that can route Atlas data.
Definition: Router.h:10
Room * createRoom(const std::string &name)
create a child room of this one, with the specified name.
Definition: Room.cpp:110