forked from Mudlet/Mudlet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTriggerUnit.h
More file actions
109 lines (95 loc) · 3.93 KB
/
TriggerUnit.h
File metadata and controls
109 lines (95 loc) · 3.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#ifndef MUDLET_TRIGGERUNIT_H
#define MUDLET_TRIGGERUNIT_H
/***************************************************************************
* Copyright (C) 2008-2013 by Heiko Koehn - KoehnHeiko@googlemail.com *
* Copyright (C) 2014 by Ahmed Charles - acharles@outlook.com *
* *
* 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. *
***************************************************************************/
#include "pre_guard.h"
#include <QMultiMap>
#include <QMutex>
#include <QPointer>
#include <QString>
#include "post_guard.h"
#include <list>
class Host;
class TTrigger;
class TriggerUnit
{
friend class XMLexport;
friend class XMLimport;
public:
TriggerUnit(Host* pHost) : mpHost(pHost), mMaxID(0), statsPatterns(), mModuleMember() { initStats(); }
std::list<TTrigger*> getTriggerRootNodeList()
{
QMutexLocker locker(&mTriggerUnitLock);
return mTriggerRootNodeList;
}
TTrigger* getTrigger(int id);
void removeAllTempTriggers();
void reorderTriggersAfterPackageImport();
TTrigger* findTrigger(const QString&);
bool enableTrigger(const QString&);
bool disableTrigger(const QString&);
bool killTrigger(const QString& name);
bool registerTrigger(TTrigger* pT);
void unregisterTrigger(TTrigger* pT);
void reParentTrigger(int childID, int oldParentID, int newParentID, int parentPosition = -1, int childPosition = -1);
void processDataStream(const QString&, int);
void compileAll();
void setTriggerStayOpen(const QString&, int);
void stopAllTriggers();
void reenableAllTriggers();
QString assembleReport();
std::list<TTrigger*> mCleanupList;
int getNewID();
QMultiMap<QString, TTrigger*> mLookupTable;
QMutex mTriggerUnitLock;
void markCleanup(TTrigger* pT);
void doCleanup();
void uninstall(const QString&);
void _uninstall(TTrigger* pChild, QString packageName);
int statsTriggerTotal;
int statsTempTriggers;
int statsPatterns;
int statsActiveTriggers;
int statsActiveTriggersMax;
int statsActiveTriggersMin;
int statsActiveTriggersAverage;
int statsTempTriggersCreated;
int statsTempTriggersKilled;
int statsAverageLineProcessingTime;
int statsMaxLineProcessingTime;
int statsMinLineProcessingTime;
int statsRegexTriggers;
QList<TTrigger*> uninstallList;
private:
TriggerUnit() {}
void initStats();
void _assembleReport(TTrigger*);
TTrigger* getTriggerPrivate(int id);
void addTriggerRootNode(TTrigger* pT, int parentPosition = -1, int childPosition = -1, bool moveTrigger = false);
void addTrigger(TTrigger* pT);
void removeTriggerRootNode(TTrigger* pT);
void removeTrigger(TTrigger*);
QPointer<Host> mpHost;
QMap<int, TTrigger*> mTriggerMap;
std::list<TTrigger*> mTriggerRootNodeList;
int mMaxID;
bool mModuleMember;
};
#endif // MUDLET_TRIGGERUNIT_H