#ifndef H_thevent_H
#define H_thevent_H
/*
  thevent library, a replacement for Acorn's eventlib

  By Tony Houghton <tonyh@tcp.co.uk>
  271 Upper Weston Lane
  Southampton
  SO19 9HY


  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., 59 Temple Place - Suite 330, Boston,
  MA 02111-1307, USA
*/

/*
  Notes
  -----

  handlers can deregister themselves safely even if they return 0

  polling and processing functions are reentrant provided you use
  separate code and block (or 0) for each call

  const is probably rather underused, but you never know when handlers
  might want to alter something for some reason

  Implementation makes almost no attempt at speed eg by hashing, but I bet
  Acorn's doesn't either
*/

/*

$Header: ADFS::Nisu.\044.AcornC_C++.Libraries.thevent.RCS.thevent,v.h 1.1 1998/05/11 21:45:58 root Exp root $

$Log: thevent,v.h $
Revision 1.1  1998/05/11 21:45:58  root
Initial revision


*/

#ifndef __wimp_h
#include "wimp.h"
#endif

#ifndef __toolbox_h
#include "toolbox.h"
#endif

typedef int (thevent_WimpHandler)(int code, WimpPollBlock *event,
                                  IdBlock *id_block, void *handle);

typedef int (thevent_ToolboxHandler)(int code, ToolboxEvent *event,
                                     IdBlock *id_block, void *handle);

typedef int (thevent_MessageHandler)(WimpMessage *message, void *handle);

#ifdef __cplusplus
extern "C" {
#endif

_kernel_oserror *thevent_poll(int *code, WimpPollBlock *block, void *poll_word);
/* code and block may be 0 to use internal copies */

_kernel_oserror *thevent_poll_idle(int *code, WimpPollBlock *block,
                                   unsigned int earliest, void *poll_word);

_kernel_oserror *thevent_process(int code, WimpPollBlock *block,
                                 IdBlock *id_block);


/* Default mask is Wimp_Poll_NullMask */
_kernel_oserror *thevent_set_mask(unsigned int mask, unsigned int value);
_kernel_oserror *thevent_get_mask(unsigned int *mask);


_kernel_oserror *thevent_claim_wimp(ObjectId, int event_code,
                                    thevent_WimpHandler *, void *handle);
_kernel_oserror *thevent_release_wimp(ObjectId, int event_code,
                                      thevent_WimpHandler *, void *handle);

_kernel_oserror *thevent_claim_toolbox(ObjectId, int event_code,
                                       thevent_ToolboxHandler *, void *handle);
_kernel_oserror *thevent_release_toolbox(ObjectId, int event_code,
                                         thevent_ToolboxHandler *,
                                         void *handle);

_kernel_oserror *thevent_claim_message(int message_code,
                                       thevent_MessageHandler *, void *handle);
_kernel_oserror *thevent_release_message(int message_code,
                                         thevent_MessageHandler *,
                                         void *handle);

#ifdef thevent_EXTRA
/*
lp versions ("Low Priority") add/remove handlers at/from the back of the list
instead of the more normal front
*/
_kernel_oserror *thevent_claim_wimp_lp(ObjectId, int event_code,
                                       thevent_WimpHandler *, void *handle);
_kernel_oserror *thevent_release_wimp_lp(ObjectId, int event_code,
                                         thevent_WimpHandler *, void *handle);

_kernel_oserror *thevent_claim_toolbox_lp(ObjectId, int event_code,
                                          thevent_ToolboxHandler *,
                                          void *handle);
_kernel_oserror *thevent_release_toolbox_lp(ObjectId, int event_code,
                                            thevent_ToolboxHandler *,
                                            void *handle);

_kernel_oserror *thevent_claim_message_lp(int message_code,
                                          thevent_MessageHandler *,
                                          void *handle);
_kernel_oserror *thevent_release_message_lp(int message_code,
                                            thevent_MessageHandler *,
                                            void *handle);

_kernel_oserror *thevent_release_object(ObjectId);

#endif

_kernel_oserror *thevent_initialise (IdBlock *);


#ifdef __cplusplus
  }
#endif

#endif
