Mana
Loading...
Searching...
No Matches
channelmanager.cpp
Go to the documentation of this file.
1/*
2 * The Mana Client
3 * Copyright (C) 2004-2009 The Mana World Development Team
4 * Copyright (C) 2009-2012 The Mana Developers
5 *
6 * This file is part of The Mana Client.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#include "channelmanager.h"
23
24#include "channel.h"
25
26#include "utils/dtor.h"
27
31
37
39{
40 Channel *channel = nullptr;
41 for (auto c : mChannels)
42 {
43 if (c->getId() == id)
44 {
45 channel = c;
46 break;
47 }
48 }
49 return channel;
50}
51
52Channel *ChannelManager::findByName(const std::string &name) const
53{
54 Channel *channel = nullptr;
55 if (!name.empty())
56 {
57 for (auto c : mChannels)
58 {
59 if (c->getName() == name)
60 {
61 channel = c;
62 break;
63 }
64 }
65 }
66 return channel;
67}
68
70{
71 mChannels.push_back(channel);
72}
73
75{
76 mChannels.remove(channel);
77 delete channel;
78}
Channel * findByName(const std::string &name) const
std::list< Channel * > mChannels
void addChannel(Channel *channel)
void removeChannel(Channel *channel)
Channel * findById(int id) const
void delete_all(Container &c)
Definition dtor.h:46