Add config dir to default load path
[clinton/bobotpp.git] / source / ServerList.C
1 // ServerList.C -*- C++ -*-
2 // Copyright (c) 1997, 1998 Etienne BERNARD
3 // Copyright (C) 2002 Clinton Ebadi
4
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // any later version.
9
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
19 #include "ServerList.H"
20
21 #include "Server.H"
22
23 ServerList::ServerList()
24 : it(v.end()), current(0), currentNumber(0)
25 { }
26
27 ServerList::~ServerList()
28 {
29 Server *s;
30 for (it = v.begin(); it != v.end(); ++it) {
31 s = *it;
32 delete s;
33 }
34 }
35
36 void
37 ServerList::addServer(Server *s)
38 {
39 v.push_back(s);
40 it = v.end(); // move to end because iterators are invalidated
41 }
42
43 void
44 ServerList::delServer(int n)
45 {
46 v.erase(v.begin () + n);
47 }
48
49 Server *
50 ServerList::nextServer()
51 {
52 if (v.empty())
53 return 0;
54
55 if (it == v.end()) {
56 it = v.begin();
57 currentNumber = 0;
58 } else
59 currentNumber++;
60
61 return current = *(it++);
62 }
63
64 Server *
65 ServerList::currentServer()
66 {
67 return current;
68 }