Planeshift
genericevent.h
Go to the documentation of this file.
1 /*
2  * genericevent.h
3  *
4  * Copyright (C) 2006 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 
20 #ifndef _PS_GENERIC_EVENT_HANDLER_
21 #define _PS_GENERIC_EVENT_HANDLER_
22 
23 #include <csutil/scf_implementation.h>
24 #include <iutil/eventh.h>
25 
37 #define DeclareGenericEventHandler(handlerName,parentType,eventName) \
38 class handlerName : public scfImplementation1<handlerName,iEventHandler> \
39 { \
40 private: \
41  parentType* parent; \
42  \
43 public: \
44  handlerName(parentType* p) \
45  : scfImplementationType(this), parent(p) {} \
46  \
47  virtual ~handlerName() {} \
48  \
49  virtual bool HandleEvent(iEvent& event) \
50  { \
51  return parent->HandleEvent(event); \
52  } \
53  \
54  CS_EVENTHANDLER_NAMES(eventName); \
55  CS_EVENTHANDLER_NIL_CONSTRAINTS; \
56 }
57 
60 #endif
61