This file is indexed.

/usr/include/crystalspace-2.0/csutil/csbaseeventh.h is in libcrystalspace-dev 2.0+dfsg-1build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
/*
    Copyright (C) 2003 by Odes B. Boatwright.

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library 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
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public
    License along with this library; if not, write to the Free
    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#ifndef __CS_CSBASEEVENTH_H__
#define __CS_CSBASEEVENTH_H__

#include "csextern.h"

/**\file
 * Base implementation of a generic event handler.
 */
/**
 * \addtogroup event_handling
 * @{ */

#include "csutil/eventhandlers.h"
#include "csutil/ref.h"
#include "csutil/scf_implementation.h"
#include "iutil/event.h"
#include "iutil/eventh.h"
#include "iutil/eventq.h"

#include <limits.h>

struct iEventQueue;
struct iObjectRegistry;

// Max event type (in event type enumeration) that will be handled.
#define _CSBASEEVENT_MAXARRAYINDEX csevFrameStart

/**
 * Base implementation of a generic event handler.
 * \par
 * This class provides a base object which does absolutely nothing with the
 * events that are sent to it. In order to properly use, you must derive a
 * class from this one and override the specific \c OnFoo() trigger methods you
 * are interested in processing.
 * \remarks
 * Although this class is derived from iEventHandler, you should not attempt
 * to overload the HandleEvent() method. Always override the specific
 * \c On... trigger function.
 */
class CS_CRYSTALSPACE_EXPORT csBaseEventHandler
{
private:
  csRef<iEventQueue> queue;

protected:
  iObjectRegistry *object_registry;
  csHandlerID self;
  csEventID FrameEvent;

  /**
   * Actual iEventHandler implementation.
   * This is in a wrapper class so it can be properly refcounted and
   * the csBaseEventHandler can be used in co-inheritance with 
   * non-refcounted classes.
   */
  class CS_CRYSTALSPACE_EXPORT EventHandlerImpl : public 
    scfImplementation1<EventHandlerImpl, iEventHandler>
  {
    friend class csBaseEventHandler;
    csBaseEventHandler* parent;
  public:
    EventHandlerImpl (csBaseEventHandler* parent);
    virtual bool HandleEvent (iEvent &event)
    {
      if (!parent) return false;
      return parent->HandleEvent (event);
    }
    virtual const char *GenericName() const 
    { 
      if (!parent) return "application"; 
      return parent->GenericName();
    }
    virtual csHandlerID GenericID(
      csRef<iEventHandlerRegistry>& reg) const 
    { 
      if (!parent) return CS_HANDLER_INVALID;
      return parent->GenericID (reg);
    }
    virtual const csHandlerID *GenericPrec (
      csRef<iEventHandlerRegistry>& hreg, csRef<iEventNameRegistry>& nreg, 
      csEventID id) const 
    { 
      if (!parent) return 0; 
      return parent->GenericPrec (hreg, nreg, id);
    }
    virtual const csHandlerID *GenericSucc (
      csRef<iEventHandlerRegistry>& hreg, csRef<iEventNameRegistry>& nreg, 
      csEventID id) const 
    { 
      if (!parent) return 0; 
      return parent->GenericSucc (hreg, nreg, id);
    }
    virtual const csHandlerID *InstancePrec (
      csRef<iEventHandlerRegistry>& hreg, csRef<iEventNameRegistry>& nreg, 
      csEventID id) const 
    { 
      if (!parent) return 0; 
      return parent->InstancePrec (hreg, nreg, id);
    }
    virtual const csHandlerID *InstanceSucc(
      csRef<iEventHandlerRegistry>& hreg, csRef<iEventNameRegistry>& nreg, 
      csEventID id) const 
    { 
      if (!parent) return 0; 
      return parent->InstanceSucc (hreg, nreg, id);
    }
  };
  csRef<EventHandlerImpl> eventh;

  /**
   * Constructor.<p>
   * \remarks
   * When deriving a class from csBaseEventHandler, you must call this
   * constructor in order to initialize reference counting for the interface.
   * \par
   * The constructor is declared as protected to prevent a developer from
   * using this class directly.
   */
  csBaseEventHandler ();

public:
  /// Destructor.
  virtual ~csBaseEventHandler ();

  /**
   * Perform basic initialization.  This function MUST be called before
   * invoking any of the RegisterQueue() methods.
   */
  void Initialize (iObjectRegistry *registry);

  /**
   * Register the event handler with the event queue registered with the
   * object registry.
   * \param registry The application's object registry
   * \param name An event name handle.  May be a token from iutil/evdefs.h or
   * the result of a call to csEventNameRegistry::GetID.
   * \see iEventQueue::RegisterListener()
   */
  bool RegisterQueue (iObjectRegistry* registry, csEventID name);

  /**
   * Register the event handler with the event queue registered with the
   * object registry.
   * \param registry The application's object registry
   * \param names An array of event name handles.  Each may be a tokens from 
   * iutil/evdefs.h or the result of a call to csEventNameRegistry::GetID.
   * List must be terminated with CS_EVENTLIST_END.
   * \see iEventQueue::RegisterListener()
   */
  bool RegisterQueue (iObjectRegistry* registry, csEventID names[]);

  /**
   * Register the event handler with an event queue.
   * \param queue The event queue to register with
   * \param name An event name handle.  May be a token from iutil/evdefs.h or
   * the result of a call to csEventNameRegistry::GetID.
   * \see iEventQueue::RegisterListener()
   */
  bool RegisterQueue (iEventQueue* queue, csEventID name);
  /**
   * Register the event handler with an event queue.
   * \param queue The event queue to register with
   * \param names An array of event name handles.  Each may be a tokens from 
   * iutil/evdefs.h or the result of a call to csEventNameRegistry::GetID.
   * List must be terminated with CS_EVENTLIST_END.
   * \see iEventQueue::RegisterListener()
   */
  bool RegisterQueue (iEventQueue* queue, csEventID names[]);
  /**
   * Unregister the event handler with the event queue that it
   * is currently registered with.
   */
  void UnregisterQueue ();

protected:
  /**
   * Implementation of the event handling mechanism. This low-level method
   * examines the event dispatches it to the appropriate OnFoo() or FooFrame()
   * method.
   * \remarks
   * You should almost never need to override this function. Doing so breaks
   * the message-oriented nature of this utility class. In almost all cases,
   * should should simply override the various OnFoo() and FooFrame() methods
   * which are applicable to your situation. Typically, the only valid reason
   * to override this method is when you need to optionally delegate the event
   * handling to some foreign mechanism. (For instance, iAWS::HandleEvent()
   * expects to be handed the event under all circumstances, regardless of the
   * event's type.) If you do override this method in order to optionally
   * delegate event handling to some other entity, then you must remember to
   * invoke csBaseEventHandler::HandleEvent() if the other entity did not
   * handle the event. (Given the AWS example, this means that if
   * iAWS::HandleEvent() returns false, the event should be passed along to
   * csBaseEventHandler::HandleEvent() so that csBaseEventHandler can dispatch
   * it to the appropriate OnFoo() or FooFrame() method as usual.)
   */
  virtual bool HandleEvent (iEvent &event);

  /**
   * Override this if you want to refer to your csBaseEventHandler derived
   * event handler as anything besides "application" for purposes of
   * event subscription scheduling.
   */
  virtual const char *GenericName() const 
  { return "application"; }
  
  virtual csHandlerID GenericID (
    csRef<iEventHandlerRegistry>& reg) const 
  { 
    return reg->GetGenericID (GenericName ()); 
  }

  /**
   * Override this if you want to force some modules to always handle some 
   * events before csBaseEventHandler.
   */
  virtual const csHandlerID *GenericPrec (
    csRef<iEventHandlerRegistry>&, csRef<iEventNameRegistry>&, 
    csEventID) const 
  { return 0; }

  /**
   * Override this if you want to force some modules to always handle some 
   * events after csBaseEventHandler.
   */
  virtual const csHandlerID *GenericSucc (
    csRef<iEventHandlerRegistry>&, csRef<iEventNameRegistry>&, 
    csEventID) const 
  { return 0; }

  /**
   * Override this if you want to force some modules to always handle some 
   * events before this instance of csBaseEventHandler.
   */
  virtual const csHandlerID *InstancePrec (
    csRef<iEventHandlerRegistry>&, csRef<iEventNameRegistry>&, 
    csEventID) const 
  { return 0; }

  /**
   * Override this if you want to force some modules to always handle some 
   * events before this instance of csBaseEventHandler.
   */
  virtual const csHandlerID *InstanceSucc (
    csRef<iEventHandlerRegistry>&, csRef<iEventNameRegistry>&, 
    csEventID) const 
  { return 0; }

  /// Invoked by the event handler when a joystick movement event is received.
  virtual bool OnJoystickMove (iEvent &event);

  /**
   * Invoked by the event handler when a joystick button down event is
   * received.
   */
  virtual bool OnJoystickDown (iEvent &event);

  /// Invoked by the event handler when a joystick button up event is received.
  virtual bool OnJoystickUp (iEvent &event);

  /// Invoked by the event handler when a keyboard event is received.
  virtual bool OnKeyboard (iEvent &event);

  /// Invoked by the event handler when a mouse move event is received.
  virtual bool OnMouseMove (iEvent &event);

  /// Invoked by the event handler when a mouse down event is received.
  virtual bool OnMouseDown (iEvent &event);

  /// Invoked by the event handler when a mouse up event is received.
  virtual bool OnMouseUp (iEvent &event);

  /// Invoked by the event handler when a mouse button click event is received.
  virtual bool OnMouseClick (iEvent &event);

  /**
   * Invoked by the event handler when a mouse button double-click event
   * is received.
   */
  virtual bool OnMouseDoubleClick (iEvent &event);

  /**
   * Invoked by the event handler when an unknown event is received.
   * \remarks
   * Also, this function will be called when a broadcast event was not
   * processed by OnBroadcast().
   */
  virtual bool OnUnhandledEvent (iEvent &event);

  /// Invoked by the handler for the crystalspace.frame event.
  virtual void Frame ();
  
  // Compatibility methods
  CS_DEPRECATED_METHOD_MSG("Use signpost event handlers for frame preprocessing")
  virtual void PreProcessFrame () {}
  CS_DEPRECATED_METHOD_MSG("Use Frame() method for main frame processing")
  virtual void ProcessFrame () {}
  CS_DEPRECATED_METHOD_MSG("Use signpost event handlers for frame postprocessing")
  virtual void PostProcessFrame () {}
  CS_DEPRECATED_METHOD_MSG("Use FramePrinter for frame finishing or "
    "signpost event handlers for frame finalization")
  virtual void FinishFrame () {}
};

/** @} */

#endif //__CS_CSBASEEVENTH_H__