2004-03-05 21:03:14 +00:00
|
|
|
/* AMX Mod X
|
|
|
|
*
|
|
|
|
* by the AMX Mod X Development Team
|
|
|
|
* originally developed by OLO
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* 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 the
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at
|
|
|
|
* your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
* In addition, as a special exception, the author gives permission to
|
|
|
|
* link the code of this program with the Half-Life Game Engine ("HL
|
|
|
|
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
|
|
|
|
* L.L.C ("Valve"). You must obey the GNU General Public License in all
|
|
|
|
* respects for all of the code used other than the HL Engine and MODs
|
|
|
|
* from Valve. If you modify this file, you may extend this exception
|
|
|
|
* to your version of the file, but you are not obligated to do so. If
|
|
|
|
* you do not wish to do so, delete this exception statement from your
|
|
|
|
* version.
|
|
|
|
*/
|
2004-01-31 20:56:22 +00:00
|
|
|
|
|
|
|
#ifndef LOGEVENTS_H
|
|
|
|
#define LOGEVENTS_H
|
|
|
|
|
|
|
|
#define MAX_LOGARGS 12
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
// *****************************************************
|
|
|
|
// class LogEventsMngr
|
|
|
|
// *****************************************************
|
|
|
|
|
2005-09-10 00:38:42 +00:00
|
|
|
class LogEventsMngr
|
|
|
|
{
|
|
|
|
char logString[256];
|
|
|
|
char logArgs[MAX_LOGARGS][128];
|
|
|
|
int logArgc;
|
|
|
|
int logCounter;
|
|
|
|
int logCurrent;
|
|
|
|
bool arelogevents;
|
2004-01-31 20:56:22 +00:00
|
|
|
|
|
|
|
public:
|
2005-09-10 00:38:42 +00:00
|
|
|
class CLogCmp;
|
|
|
|
class iterator;
|
|
|
|
class CLogEvent;
|
2004-01-31 20:56:22 +00:00
|
|
|
friend class CLogEvent;
|
2005-09-10 00:38:42 +00:00
|
|
|
friend class CLogCmp;
|
|
|
|
friend class iterator;
|
2004-01-31 20:56:22 +00:00
|
|
|
|
2005-09-10 00:38:42 +00:00
|
|
|
class CLogCmp
|
|
|
|
{
|
|
|
|
friend class LogEventsMngr;
|
|
|
|
friend class CLogEvent;
|
2005-09-16 23:48:51 +00:00
|
|
|
|
2005-09-10 00:38:42 +00:00
|
|
|
LogEventsMngr* parent;
|
|
|
|
String text;
|
2005-09-16 23:48:51 +00:00
|
|
|
|
2005-09-10 00:38:42 +00:00
|
|
|
int logid;
|
|
|
|
int pos;
|
|
|
|
int result;
|
|
|
|
bool in;
|
2005-09-16 23:48:51 +00:00
|
|
|
|
2005-09-10 00:38:42 +00:00
|
|
|
CLogCmp *next;
|
|
|
|
|
|
|
|
CLogCmp(const char* s, bool r, int p, CLogCmp *n, LogEventsMngr* mg) : text(s)
|
|
|
|
{
|
|
|
|
logid = result = 0;
|
|
|
|
pos = p;
|
|
|
|
parent = mg;
|
|
|
|
in = r;
|
|
|
|
next = n;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
int compareCondition(const char* string);
|
|
|
|
};
|
2004-01-31 20:56:22 +00:00
|
|
|
|
|
|
|
private:
|
2005-09-10 00:38:42 +00:00
|
|
|
CLogCmp *logcmplist;
|
2004-01-31 20:56:22 +00:00
|
|
|
public:
|
|
|
|
|
2005-09-10 00:38:42 +00:00
|
|
|
class CLogEvent
|
|
|
|
{
|
|
|
|
friend class LogEventsMngr;
|
|
|
|
friend class iterator;
|
|
|
|
|
|
|
|
struct LogCondEle
|
|
|
|
{
|
|
|
|
CLogCmp *cmp;
|
|
|
|
LogCondEle *next;
|
2005-09-16 23:48:51 +00:00
|
|
|
LogCondEle(CLogCmp *c, LogCondEle *n): cmp(c), next(n) {}
|
2005-09-10 00:38:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct LogCond
|
|
|
|
{
|
|
|
|
int argnum;
|
2005-09-16 23:48:51 +00:00
|
|
|
|
2005-09-10 00:38:42 +00:00
|
|
|
LogCondEle *list;
|
|
|
|
LogCond *next;
|
|
|
|
LogCond(int a, LogCondEle* ee, LogCond* n) : argnum(a), list(ee), next(n) {}
|
|
|
|
~LogCond();
|
|
|
|
};
|
|
|
|
|
|
|
|
CPluginMngr::CPlugin *plugin;
|
2005-09-16 23:48:51 +00:00
|
|
|
|
2005-09-10 00:38:42 +00:00
|
|
|
int func;
|
2005-09-16 23:48:51 +00:00
|
|
|
|
2005-09-10 00:38:42 +00:00
|
|
|
LogCond *filters;
|
|
|
|
LogEventsMngr* parent;
|
2005-09-16 23:48:51 +00:00
|
|
|
|
2005-09-10 00:38:42 +00:00
|
|
|
CLogEvent *next;
|
2005-09-16 23:48:51 +00:00
|
|
|
CLogEvent(CPluginMngr::CPlugin *p, int f, LogEventsMngr* ppp) : plugin(p), func(f), filters(0), parent(ppp), next(0) {}
|
2005-09-10 00:38:42 +00:00
|
|
|
~CLogEvent();
|
|
|
|
public:
|
|
|
|
inline CPluginMngr::CPlugin *getPlugin() { return plugin; }
|
|
|
|
void registerFilter(char* filter);
|
|
|
|
inline int getFunction() { return func; }
|
2004-01-31 20:56:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
2005-09-10 20:09:14 +00:00
|
|
|
CLogEvent *logevents[MAX_LOGARGS + 1];
|
2005-09-10 00:38:42 +00:00
|
|
|
CLogEvent *getValidLogEvent(CLogEvent * a);
|
|
|
|
CLogCmp* registerCondition(char* filter);
|
2005-09-16 23:48:51 +00:00
|
|
|
|
2005-09-10 00:38:42 +00:00
|
|
|
void clearConditions();
|
2004-01-31 20:56:22 +00:00
|
|
|
public:
|
2005-09-10 00:38:42 +00:00
|
|
|
LogEventsMngr();
|
|
|
|
~LogEventsMngr();
|
2004-01-31 20:56:22 +00:00
|
|
|
|
|
|
|
// Interface
|
2005-09-10 00:38:42 +00:00
|
|
|
CLogEvent* registerLogEvent(CPluginMngr::CPlugin* plugin, int func, int pos);
|
|
|
|
inline bool logEventsExist() { return arelogevents; }
|
2005-09-16 23:48:51 +00:00
|
|
|
|
2005-09-10 00:38:42 +00:00
|
|
|
void setLogString(char* frmt, va_list& vaptr);
|
|
|
|
void setLogString(char* frmt, ...);
|
|
|
|
void parseLogString();
|
|
|
|
void executeLogEvents();
|
2005-09-16 23:48:51 +00:00
|
|
|
|
2005-09-10 00:38:42 +00:00
|
|
|
inline const char* getLogString() { return logString; }
|
|
|
|
inline int getLogArgNum() { return logArgc; }
|
|
|
|
inline const char* getLogArg(int i) { return (i < 0 || i >= logArgc) ? "" : logArgs[i]; }
|
|
|
|
void clearLogEvents();
|
|
|
|
|
|
|
|
class iterator
|
|
|
|
{
|
|
|
|
CLogEvent* a;
|
|
|
|
LogEventsMngr* b;
|
|
|
|
|
|
|
|
public:
|
2005-09-16 23:48:51 +00:00
|
|
|
inline iterator(CLogEvent*aa, LogEventsMngr* bb) : a(aa), b(bb) {}
|
2005-09-10 00:38:42 +00:00
|
|
|
|
|
|
|
inline iterator& operator++()
|
|
|
|
{
|
|
|
|
a = b->getValidLogEvent(a->next);
|
|
|
|
return *this;
|
|
|
|
}
|
2005-09-16 23:48:51 +00:00
|
|
|
|
2005-09-10 00:38:42 +00:00
|
|
|
inline bool operator==(const iterator& c) const { return a == c.a; }
|
2005-09-16 23:48:51 +00:00
|
|
|
inline bool operator!=(const iterator& c) const { return !operator == (c); }
|
2005-09-10 00:38:42 +00:00
|
|
|
CLogEvent& operator*() { return *a; }
|
|
|
|
operator bool () const { return a ? true : false; }
|
|
|
|
};
|
|
|
|
|
|
|
|
inline iterator begin() { return iterator(getValidLogEvent(logevents[logArgc]), this); }
|
|
|
|
inline iterator end() { return iterator(0, this); }
|
2004-01-31 20:56:22 +00:00
|
|
|
};
|
|
|
|
|
2005-09-10 00:38:42 +00:00
|
|
|
#endif //LOGEVENTS_H
|