Mana
Loading...
Searching...
No Matches
src
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
28
ChannelManager::ChannelManager
()
29
{
30
}
31
32
ChannelManager::~ChannelManager
()
33
{
34
delete_all
(
mChannels
);
35
mChannels
.clear();
36
}
37
38
Channel
*
ChannelManager::findById
(
int
id
)
const
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
52
Channel
*
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
69
void
ChannelManager::addChannel
(
Channel
*channel)
70
{
71
mChannels
.push_back(channel);
72
}
73
74
void
ChannelManager::removeChannel
(
Channel
*channel)
75
{
76
mChannels
.remove(channel);
77
delete
channel;
78
}
channel.h
channelmanager.h
ChannelManager::~ChannelManager
~ChannelManager()
Definition
channelmanager.cpp:32
ChannelManager::findByName
Channel * findByName(const std::string &name) const
Definition
channelmanager.cpp:52
ChannelManager::ChannelManager
ChannelManager()
Definition
channelmanager.cpp:28
ChannelManager::mChannels
std::list< Channel * > mChannels
Definition
channelmanager.h:44
ChannelManager::addChannel
void addChannel(Channel *channel)
Definition
channelmanager.cpp:69
ChannelManager::removeChannel
void removeChannel(Channel *channel)
Definition
channelmanager.cpp:74
ChannelManager::findById
Channel * findById(int id) const
Definition
channelmanager.cpp:38
Channel
Definition
channel.h:29
dtor.h
delete_all
void delete_all(Container &c)
Definition
dtor.h:46
Generated by
1.9.8