Implement threadsafe banlist and make maintenance of bans cleaner
[clinton/bobotpp.git] / source / Channel.H
index 348b943..40caad9 100644 (file)
@@ -1,6 +1,6 @@
 // Channel.H  -*- C++ -*-
 // Copyright (c) 1997, 1998 Etienne BERNARD
-// Copyright (C) 2002 Clinton Ebadi
+// Copyright (C) 2002,2008 Clinton Ebadi
 
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
 #ifndef CHANNEL_H
 #define CHANNEL_H
 
-#include <ctime>
+#include <algorithm>
+#include <functional>
 #include <map>
 #include <vector>
 
+#include <ctime>
+
+#include "BanList.H"
 #include "String.H"
 
 class BanEntry;
 class Bot;
 class Commands;
+class Mask;
 class Parser;
 class Person;
 class ServerConnection;
@@ -68,7 +73,7 @@ class Channel {
   bool doMode;
   bool gotWho;
   std::map<String, User *, std::less<String> > channelMemory;
-  std::vector<BanEntry *> channelBanlist;
+  BanList channelBanlist;
   ServerConnection * cnx;
 
 public:
@@ -93,8 +98,11 @@ public:
   bool hasNick(String);
   User * getUser(String);
   
-  void addBan(String, std::time_t = -1);
-  void delBan(String);
+  void addBan(const Mask&, std::time_t = -1);
+  void delBan(const Mask&);
+  void purge_expired_bans ();
+  template<typename T>  void for_each_ban_entry (const T & fun)
+  { channelBanlist.foreach (fun); }
   
   void parseMode(Person *, String);
   void resynchModes();