Encapsulate obscure detail that lower numeric priority is higher queue priority
[clinton/bobotpp.git] / source / TodoList.C
1 // TodoList.C -*- C++ -*-
2 // Copyright (c) 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 // (at your option) 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 "TodoList.H"
20
21 TodoList::TodoList()
22 {
23 #ifdef HAVE_STL_CLEAR
24 todoQueue.clear();
25 #endif
26 }
27
28 TodoList::~TodoList()
29 { }
30
31 void
32 TodoList::addDeban(String channel, String mask, time_t when)
33 {
34 TodoListItem tdli(String("MODE ") + channel +
35 " -b " + mask, when);
36 todoQueue.insert(tdli);
37 }
38
39 String
40 TodoList::getNext()
41 {
42 std::multiset<TodoListItem, std::less<TodoListItem> >::iterator it;
43 std::time_t current_time = time(0);
44
45 it = todoQueue.begin();
46
47 if (it == todoQueue.end() || (*it).when > current_time)
48 return "";
49
50 String result = (*it).line;
51 todoQueue.erase(it);
52
53 return result;
54 }