// BotInterp.H -*- C++ -*-
// Copyright (c) 1998 Etienne BERNARD
-// Copyright (C) 2002 Clinton Ebadi
+// Copyright (C) 2002,2005,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
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+// 02110-1301, USA.
#ifndef BOTINTERP_H
#define BOTINTERP_H
#ifdef USESCRIPTS
#include <ctime>
+#include <map>
+#include <list>
+#include <functional>
+
#include <libguile.h>
+
+#include "BotThreading.H"
#include "String.H"
+#include "Utils.H"
class Bot;
PUBLIC_NOTICE, RAW, TIMER, TOPIC,
// send hooks
SEND_ACTION, SEND_CTCP, SEND_PUBLIC, SEND_MESSAGE,
+ SEND_WHO, SEND_WHOIS,
// DCC hooks
DCC_CHAT_BEGIN, DCC_CHAT_END, DCC_CHAT_MESSAGE
};
Timer(int c, std::time_t t, SCM f)
: count(c), when(t), function(f) { }
+
+ bool operator< (const Timer & other) const
+ { return when < other.when; }
};
class BotInterp {
+ typedef std::list<Timer *> TimerList;
+
Bot * bot;
SCM logPort;
std::map<int, std::list<Hook *>, std::less<int> > hooksMap;
- std::list<Timer *> timersList;
+ TimerList timers;
+ Utils::IndirectPred<Timer, std::less<Timer> > timer_sort_p;
int counter;
+ BotMutex hook_mutex;
+ BotMutex timer_mutex; // NOTE: recursive lock
public:
BotInterp(Bot *, String);