HoverRace  2.0
Roster.h
Go to the documentation of this file.
1 
2 // Roster.h
3 //
4 // Copyright (c) 2014, 2016 Michael Imamura.
5 //
6 // Licensed under GrokkSoft HoverRace SourceCode License v1.0(the "License");
7 // you may not use this file except in compliance with the License.
8 //
9 // A copy of the license should have been attached to the package from which
10 // you have taken this file. If you can not find the license you can not use
11 // this file.
12 //
13 //
14 // The author makes no representations about the suitability of
15 // this software for any purpose. It is provided "as is" "AS IS",
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17 // implied.
18 //
19 // See the License for the specific language governing permissions
20 // and limitations under the License.
21 
22 #pragma once
23 
24 namespace HoverRace {
25  namespace Player {
26  class Player;
27  }
28 }
29 
30 namespace HoverRace {
31 namespace Client {
32 
37 class Roster
38 {
39 public:
40  Roster();
41 
42 public:
43  using playerAddedSignal_t =
44  boost::signals2::signal<void(std::shared_ptr<Player::Player>)>;
45  playerAddedSignal_t &GetPlayerAddedSignal() { return playerAddedSignal; }
46 
47  void AddPlayer(std::shared_ptr<Player::Player> player);
48 
49  std::shared_ptr<Player::Player> ShareFirst() const;
50 
51  template<typename Fn>
52  void ForEach(Fn fn)
53  {
54  std::for_each(players.begin(), players.end(), fn);
55  }
56 
57 private:
58  std::list<std::shared_ptr<Player::Player>> players;
60 };
61 
62 } // namespace Client
63 } // namespace HoverRace
void ForEach(Fn fn)
Definition: Roster.h:52
playerAddedSignal_t & GetPlayerAddedSignal()
Definition: Roster.h:45
A list of players.
Definition: Roster.h:37
std::list< std::shared_ptr< Player::Player > > players
Definition: Roster.h:58
Definition: Announcement.h:24
boost::signals2::signal< void(std::shared_ptr< Player::Player >)> playerAddedSignal_t
Definition: Roster.h:44
playerAddedSignal_t playerAddedSignal
Definition: Roster.h:59