KVIrc  4.9.2
DeveloperAPIs
KviKvsEventTriggers.h
Go to the documentation of this file.
1 #ifndef _KVI_KVS_EVENTTRIGGERS_H_
2 #define _KVI_KVS_EVENTTRIGGERS_H_
3 //=============================================================================
4 //
5 // File : KviKvsEventTriggers.h
6 // Creation date : Thu Oct 22 2005 04:57:12 by Szymon Stefanek
7 //
8 // This file is part of the KVIrc IRC client distribution
9 // Copyright (C) 2005-2010 Szymon Stefanek <pragma at kvirc dot net>
10 //
11 // This program is FREE software. You can redistribute it and/or
12 // modify it under the terms of the GNU General Public License
13 // as published by the Free Software Foundation; either version 2
14 // of the License, or (at your option) any later version.
15 //
16 // This program is distributed in the HOPE that it will be USEFUL,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 // See the GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, write to the Free Software Foundation,
23 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 //
25 //=============================================================================
26 
27 #include "kvi_settings.h"
28 
29 #include "KviKvsEventTable.h"
30 #include "KviKvsEventManager.h"
31 #include "KviKvsVariantList.h"
32 
33 //
34 // KVS Macros for triggering events
35 //
36 // KviKvsVariantList vParams;
37 // vParams.append(bSomething);
38 // vParams.append(iSomething);
39 // vParams.append(szSomething);
40 // KVS_TRIGGER_EVENT(KviEvent_OnSomething,pSomeWindow,&vParams)
41 //
42 // if(KVS_TRIGGER_EVENT_HALTED(KviEvent_OnSomething,pSomeWindow,&vParams))
43 // msg->haltOutput()
44 //
45 //
46 
47 // These two allow reusing the parameter lists (but may require more code)
48 #define KVS_TRIGGER_EVENT(__idx, __wnd, __parms) \
49  if(KviKvsEventManager::instance()->hasAppHandlers(__idx)) \
50  KviKvsEventManager::instance()->trigger(__idx, __wnd, __parms);
51 
52 #define KVS_TRIGGER_EVENT_HALTED(__idx, __wnd, __parms) \
53  (KviKvsEventManager::instance()->hasAppHandlers(__idx) ? KviKvsEventManager::instance()->trigger(__idx, __wnd, __parms) : false)
54 
55 // These require less code (but param lists can't be reused)
56 #define KVS_TRIGGER_EVENT_0(__idx, __wnd) \
57  if(KviKvsEventManager::instance()->hasAppHandlers(__idx)) \
58  { \
59  KviKvsVariantList _vLocalParamList; \
60  KviKvsEventManager::instance()->trigger(__idx, __wnd, &_vLocalParamList); \
61  }
62 
63 #define KVS_TRIGGER_EVENT_1(__idx, __wnd, __param1) \
64  if(KviKvsEventManager::instance()->hasAppHandlers(__idx)) \
65  { \
66  KviKvsVariantList _vLocalParamList( \
67  new KviKvsVariant(__param1)); \
68  KviKvsEventManager::instance()->trigger(__idx, __wnd, &_vLocalParamList); \
69  }
70 
71 #define KVS_TRIGGER_EVENT_2(__idx, __wnd, __param1, __param2) \
72  if(KviKvsEventManager::instance()->hasAppHandlers(__idx)) \
73  { \
74  KviKvsVariantList _vLocalParamList( \
75  new KviKvsVariant(__param1), \
76  new KviKvsVariant(__param2)); \
77  KviKvsEventManager::instance()->trigger(__idx, __wnd, &_vLocalParamList); \
78  }
79 
80 #define KVS_TRIGGER_EVENT_3(__idx, __wnd, __param1, __param2, __param3) \
81  if(KviKvsEventManager::instance()->hasAppHandlers(__idx)) \
82  { \
83  KviKvsVariantList _vLocalParamList( \
84  new KviKvsVariant(__param1), \
85  new KviKvsVariant(__param2), \
86  new KviKvsVariant(__param3)); \
87  KviKvsEventManager::instance()->trigger(__idx, __wnd, &_vLocalParamList); \
88  }
89 
90 #define KVS_TRIGGER_EVENT_4(__idx, __wnd, __param1, __param2, __param3, __param4) \
91  if(KviKvsEventManager::instance()->hasAppHandlers(__idx)) \
92  { \
93  KviKvsVariantList _vLocalParamList( \
94  new KviKvsVariant(__param1), \
95  new KviKvsVariant(__param2), \
96  new KviKvsVariant(__param3), \
97  new KviKvsVariant(__param4)); \
98  KviKvsEventManager::instance()->trigger(__idx, __wnd, &_vLocalParamList); \
99  }
100 
101 #define KVS_TRIGGER_EVENT_5(__idx, __wnd, __param1, __param2, __param3, __param4, __param5) \
102  if(KviKvsEventManager::instance()->hasAppHandlers(__idx)) \
103  { \
104  KviKvsVariantList _vLocalParamList( \
105  new KviKvsVariant(__param1), \
106  new KviKvsVariant(__param2), \
107  new KviKvsVariant(__param3), \
108  new KviKvsVariant(__param4), \
109  new KviKvsVariant(__param5)); \
110  KviKvsEventManager::instance()->trigger(__idx, __wnd, &_vLocalParamList); \
111  }
112 
113 #define KVS_TRIGGER_EVENT_6(__idx, __wnd, __param1, __param2, __param3, __param4, __param5, __param6) \
114  if(KviKvsEventManager::instance()->hasAppHandlers(__idx)) \
115  { \
116  KviKvsVariantList _vLocalParamList( \
117  new KviKvsVariant(__param1), \
118  new KviKvsVariant(__param2), \
119  new KviKvsVariant(__param3), \
120  new KviKvsVariant(__param4), \
121  new KviKvsVariant(__param5), \
122  new KviKvsVariant(__param6)); \
123  KviKvsEventManager::instance()->trigger(__idx, __wnd, &_vLocalParamList); \
124  }
125 
126 #define KVS_TRIGGER_EVENT_7(__idx, __wnd, __param1, __param2, __param3, __param4, __param5, __param6, __param7) \
127  if(KviKvsEventManager::instance()->hasAppHandlers(__idx)) \
128  { \
129  KviKvsVariantList _vLocalParamList( \
130  new KviKvsVariant(__param1), \
131  new KviKvsVariant(__param2), \
132  new KviKvsVariant(__param3), \
133  new KviKvsVariant(__param4), \
134  new KviKvsVariant(__param5), \
135  new KviKvsVariant(__param6), \
136  new KviKvsVariant(__param7)); \
137  KviKvsEventManager::instance()->trigger(__idx, __wnd, &_vLocalParamList); \
138  }
139 
140 #define KVS_TRIGGER_EVENT_0_HALTED(__idx, __wnd) \
141  ( \
142  KviKvsEventManager::instance()->hasAppHandlers(__idx) \
143  ? KviKvsEventManager::instance()->triggerDeleteParams( \
144  __idx, \
145  __wnd, \
146  new KviKvsVariantList()) \
147  : false)
148 
149 #define KVS_TRIGGER_EVENT_1_HALTED(__idx, __wnd, __param1) \
150  ( \
151  KviKvsEventManager::instance()->hasAppHandlers(__idx) \
152  ? KviKvsEventManager::instance()->triggerDeleteParams( \
153  __idx, \
154  __wnd, \
155  new KviKvsVariantList( \
156  new KviKvsVariant(__param1))) \
157  : false)
158 
159 #define KVS_TRIGGER_EVENT_2_HALTED(__idx, __wnd, __param1, __param2) \
160  ( \
161  KviKvsEventManager::instance()->hasAppHandlers(__idx) \
162  ? KviKvsEventManager::instance()->triggerDeleteParams( \
163  __idx, \
164  __wnd, \
165  new KviKvsVariantList( \
166  new KviKvsVariant(__param1), \
167  new KviKvsVariant(__param2))) \
168  : false)
169 
170 #define KVS_TRIGGER_EVENT_3_HALTED(__idx, __wnd, __param1, __param2, __param3) \
171  ( \
172  KviKvsEventManager::instance()->hasAppHandlers(__idx) \
173  ? KviKvsEventManager::instance()->triggerDeleteParams( \
174  __idx, \
175  __wnd, \
176  new KviKvsVariantList( \
177  new KviKvsVariant(__param1), \
178  new KviKvsVariant(__param2), \
179  new KviKvsVariant(__param3))) \
180  : false)
181 
182 #define KVS_TRIGGER_EVENT_4_HALTED(__idx, __wnd, __param1, __param2, __param3, __param4) \
183  ( \
184  KviKvsEventManager::instance()->hasAppHandlers(__idx) \
185  ? KviKvsEventManager::instance()->triggerDeleteParams( \
186  __idx, \
187  __wnd, \
188  new KviKvsVariantList( \
189  new KviKvsVariant(__param1), \
190  new KviKvsVariant(__param2), \
191  new KviKvsVariant(__param3), \
192  new KviKvsVariant(__param4))) \
193  : false)
194 
195 #define KVS_TRIGGER_EVENT_5_HALTED(__idx, __wnd, __param1, __param2, __param3, __param4, __param5) \
196  ( \
197  KviKvsEventManager::instance()->hasAppHandlers(__idx) \
198  ? KviKvsEventManager::instance()->triggerDeleteParams( \
199  __idx, \
200  __wnd, \
201  new KviKvsVariantList( \
202  new KviKvsVariant(__param1), \
203  new KviKvsVariant(__param2), \
204  new KviKvsVariant(__param3), \
205  new KviKvsVariant(__param4), \
206  new KviKvsVariant(__param5))) \
207  : false)
208 
209 #define KVS_TRIGGER_EVENT_6_HALTED(__idx, __wnd, __param1, __param2, __param3, __param4, __param5, __param6) \
210  ( \
211  KviKvsEventManager::instance()->hasAppHandlers(__idx) \
212  ? KviKvsEventManager::instance()->triggerDeleteParams( \
213  __idx, \
214  __wnd, \
215  new KviKvsVariantList( \
216  new KviKvsVariant(__param1), \
217  new KviKvsVariant(__param2), \
218  new KviKvsVariant(__param3), \
219  new KviKvsVariant(__param4), \
220  new KviKvsVariant(__param5), \
221  new KviKvsVariant(__param6))) \
222  : false)
223 
224 #define KVS_TRIGGER_EVENT_7_HALTED(__idx, __wnd, __param1, __param2, __param3, __param4, __param5, __param6, __param7) \
225  ( \
226  KviKvsEventManager::instance()->hasAppHandlers(__idx) \
227  ? KviKvsEventManager::instance()->triggerDeleteParams( \
228  __idx, \
229  __wnd, \
230  new KviKvsVariantList( \
231  new KviKvsVariant(__param1), \
232  new KviKvsVariant(__param2), \
233  new KviKvsVariant(__param3), \
234  new KviKvsVariant(__param4), \
235  new KviKvsVariant(__param5), \
236  new KviKvsVariant(__param6), \
237  new KviKvsVariant(__param7))) \
238  : false)
239 
240 #endif
Events table.
Parser class to handle variant variables lists.
This file contains compile time settings.