Quiet annoying mutex debug logging messages
[clinton/bobotpp.git] / source / BotInterp.H
index 4929058..1cd3975 100644 (file)
 
 #ifdef USESCRIPTS
 
-#include <ctime>
-#include <map>
-#include <list>
 #include <functional>
+#include <list>
+#include <map>
+#include <string>
+
+#include <ctime>
 
 #include <libguile.h>
 
@@ -44,43 +46,16 @@ struct Hook {
   int priority;
   bool fallthru;
 
-  String regex_str;
-  String name;
+  std::string regex_str;
+  std::string name;
   SCM regex;
   SCM function;
 
-  Hook(int t, String rs, SCM r, SCM f, int p, bool ft, String n="DEFAULT")
+  Hook(int t, std::string rs, SCM r, SCM f, int p, bool ft, std::string n="DEFAULT")
     : type(t), priority (p), fallthru (ft), regex_str(rs), 
       name (n), regex(r), function(f)  { }
 
-  bool operator< (const Hook &h) const
-  {
-    if (priority < h.priority)
-      {
-       return true;
-      }
-    else if (priority > h.priority)
-      {
-       return false;
-      }
-    else if (fallthru && h.fallthru)
-      {
-       return false;
-      }
-    else if (fallthru && !h.fallthru)
-      {
-       return false;
-      }
-    else if (!fallthru && h.fallthru)
-      {
-       return true;
-      }
-    else
-      {
-       // NOTE: This should never be reached
-       return false;
-      }
-  }
+  bool operator< (const Hook & h) const;
 
   enum {
     ACTION, NICKNAME, SIGNOFF, CTCP, CTCP_REPLY,
@@ -109,13 +84,19 @@ struct Timer {
 
 class BotInterp {
   typedef std::list<Timer *> TimerList;
+  typedef std::list<Hook *> HookList;
+  typedef std::map<int, HookList, std::less<int> > HookMap;
   
   Bot * bot;
   SCM logPort;
-  std::map<int, std::list<Hook *>, std::less<int> > hooksMap;
+  int counter;
+
+  HookMap hooks;
   TimerList timers;
+
   Utils::IndirectPred<Timer, std::less<Timer> > timer_sort_p;
-  int counter;
+  Utils::IndirectPred<Hook, std::less<Hook> > hook_sort_p;
+
   BotMutex hook_mutex;
   BotMutex timer_mutex; // NOTE: recursive lock
 
@@ -127,8 +108,8 @@ public:
   void Execute(String);
   void LoadScript(String);
 
-  bool AddHook(int, SCM, SCM, int, bool, String);
-  bool RunHooks(int, String, SCM);
+  bool AddHook(int, SCM, SCM, int, bool, std::string);
+  bool RunHooks(int, std::string, SCM);
 
   SCM AddTimer(int, SCM);
   bool DelTimer(SCM);