CrystalSpace

Public API Reference

iutil/eventh.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2001 by Jorrit Tyberghein
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
00008     
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013     
00014     You should have received a copy of the GNU Library General Public
00015     License along with this library; if not, write to the Free
00016     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017 */
00018 
00019 #ifndef __CS_IUTIL_EVENTH_H__
00020 #define __CS_IUTIL_EVENTH_H__
00021 
00029 #include "csutil/scf_interface.h"
00030 #include "iutil/eventnames.h"
00031 #include "iutil/eventhandlers.h"
00032 
00033 struct iEvent;
00034 
00035 
00039 struct iEventHandler : public virtual iBase
00040 {
00041   SCF_INTERFACE(iEventHandler, 2,0,0);
00054   virtual bool HandleEvent (iEvent&) = 0;
00055 
00080   CS_CONST_METHOD virtual const char * GenericName() const = 0; /* really is "static" */
00081 
00093   CS_CONST_METHOD virtual csHandlerID GenericID (
00094     csRef<iEventHandlerRegistry> &) const = 0; 
00095   // wish the above could be "virtual static"
00096 
00108   CS_CONST_METHOD virtual const csHandlerID * GenericPrec (
00109     csRef<iEventHandlerRegistry> &, csRef<iEventNameRegistry> &, 
00110     csEventID) const = 0;
00111 
00123   CS_CONST_METHOD virtual const csHandlerID * GenericSucc (
00124     csRef<iEventHandlerRegistry> &, csRef<iEventNameRegistry> &,
00125     csEventID) const = 0;
00126 
00139   CS_PURE_METHOD virtual const csHandlerID * InstancePrec (
00140     csRef<iEventHandlerRegistry> &, csRef<iEventNameRegistry> &,
00141     csEventID) const = 0;
00142 
00155   CS_PURE_METHOD virtual const csHandlerID * InstanceSucc (
00156     csRef<iEventHandlerRegistry> &, csRef<iEventNameRegistry> &,
00157     csEventID) const = 0;
00158 };
00159 
00165 #define CS_EVENTHANDLER_NAMES(x)                                        \
00166   CS_CONST_METHOD static const char * StaticHandlerName()               \
00167   { return (x); }                                                       \
00168   CS_CONST_METHOD static const csHandlerID StaticID(csRef<iEventHandlerRegistry> &reg) \
00169   {return reg->GetGenericID(StaticHandlerName()); }                     \
00170   CS_CONST_METHOD virtual const char * GenericName() const              \
00171   { return StaticHandlerName(); }                                       \
00172   CS_CONST_METHOD virtual csHandlerID GenericID(csRef<iEventHandlerRegistry> &reg) const \
00173   { return StaticID(reg); }
00174 
00178 #define CS_EVENTHANDLER_NIL_CONSTRAINTS                 \
00179         CS_EVENTHANDLER_NIL_GENERIC_CONSTRAINTS         \
00180         CS_EVENTHANDLER_DEFAULT_INSTANCE_CONSTRAINTS 
00181 
00185 #define CS_EVENTHANDLER_NIL_GENERIC_CONSTRAINTS                         \
00186   CS_CONST_METHOD virtual const csHandlerID * GenericPrec (             \
00187     csRef<iEventHandlerRegistry> &, csRef<iEventNameRegistry> &,        \
00188     csEventID) const { return 0; }      \
00189   CS_CONST_METHOD virtual const csHandlerID * GenericSucc (             \
00190     csRef<iEventHandlerRegistry> &, csRef<iEventNameRegistry> &,        \
00191     csEventID) const { return 0; }
00192 
00196 #define CS_EVENTHANDLER_DEFAULT_INSTANCE_CONSTRAINTS                    \
00197   CS_CONST_METHOD virtual const csHandlerID * InstancePrec (            \
00198     csRef<iEventHandlerRegistry> &r1, csRef<iEventNameRegistry> &r2,    \
00199     csEventID e) const { return GenericPrec(r1, r2, e); } \
00200   CS_CONST_METHOD virtual const csHandlerID * InstanceSucc (            \
00201     csRef<iEventHandlerRegistry> &r1, csRef<iEventNameRegistry> &r2,    \
00202     csEventID e) const { return GenericSucc(r1, r2, e); }
00203 
00206 #endif // __CS_IUTIL_EVENTH_H__

Generated for Crystal Space 1.2.1 by doxygen 1.5.3