dvbd / connectionmanager.cpp @ bfdb7446
History | View | Annotate | Download (1.76 KB)
1 |
/*
|
---|---|
2 |
Copyright 2003 John Knottenbelt
|
3 |
|
4 |
This program is free software; you can redistribute it and/or modify
|
5 |
it under the terms of the GNU General Public License as published by
|
6 |
the Free Software Foundation; either version 2 of the License, or
|
7 |
(at your option) any later version.
|
8 |
|
9 |
This program is distributed in the hope that it will be useful,
|
10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12 |
GNU General Public License for more details.
|
13 |
|
14 |
You should have received a copy of the GNU General Public License
|
15 |
along with this program; if not, write to the Free Software
|
16 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
|
17 |
*/
|
18 |
|
19 |
#include "config.h" |
20 |
#include "connectionmanager.h" |
21 |
#include "connection.h" |
22 |
|
23 |
ConnectionManager::~ConnectionManager() |
24 |
{ |
25 |
for (ConnectionList::iterator i = connections.begin(); i != connections.end();) {
|
26 |
Connection *c = *i; |
27 |
i = connections.erase(i); |
28 |
delete c;
|
29 |
} |
30 |
} |
31 |
|
32 |
void ConnectionManager::add(Connection *c)
|
33 |
{ |
34 |
connections.push_back(c); |
35 |
} |
36 |
|
37 |
void ConnectionManager::addSelectFDs(Select &s) const |
38 |
{ |
39 |
for (ConnectionList::const_iterator i = connections.begin(); i != connections.end(); i++)
|
40 |
(*i)->addSelectFDs(s); |
41 |
} |
42 |
|
43 |
bool ConnectionManager::isReady(const Select &s) const |
44 |
{ |
45 |
for (ConnectionList::const_iterator i = connections.begin(); i != connections.end(); i++)
|
46 |
if ((*i)->isReady(s))
|
47 |
return true; |
48 |
return false; |
49 |
} |
50 |
|
51 |
void ConnectionManager::processReady(Select &s)
|
52 |
{ |
53 |
for (ConnectionList::iterator i = connections.begin(); i != connections.end(); ) {
|
54 |
Connection *c = *i; |
55 |
if (!c->processReady(s)) {
|
56 |
// Close terminated connections
|
57 |
i = connections.erase(i); |
58 |
delete c;
|
59 |
continue;
|
60 |
} |
61 |
i++; |
62 |
} |
63 |
} |