moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / kstars / kstars / indi / eventloop.h
blob67884c0d491e54d2afa4dee3b42452c7cfa08b31
1 #if 0
2 INDI
3 Copyright (C) 2003 Elwood C. Downey
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library 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 GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #endif
21 #ifndef EVENT_LOOP_H
22 #define EVENT_LOOP_H
24 /** \file eventloop.h
25 \brief Public interface to INDI's eventloop mechanism.
26 \author Elwood C. Downey
29 /* signature of a callback, workproc and timer function */
31 /** \typedef CBF
32 \brief Signature of a callback function.
34 typedef void (CBF) (int fd, void *);
36 /** \typedef WPF
37 \brief Signature of a work procedure function.
39 typedef void (WPF) (void *);
41 /** \typedef TCF
42 \brief Signature of a timer function.
44 typedef void (TCF) (void *);
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
50 /** \fn void eventLoop(void)
51 \brief Main calls this when ready to hand over control.
53 extern void eventLoop(void);
55 /**
56 * \defgroup utilFunctions Utility functions to add and remove callbacks, workprocs, and timers.
58 /*@{*/
60 /** Register a new callback, \e fp, to be called with \e ud as argument when \e fd is ready.
62 * \param fd file descriptor.
63 * \param fp a pointer to the callback function.
64 * \param ud a pointer to be passed to the callback function when called.
65 * \return a unique callback id for use with rmCallback().
67 extern int addCallback (int fd, CBF *fp, void *ud);
69 /** Remove a callback function.
71 * \param cid the callback ID returned from addCallback().
73 extern void rmCallback (int cid);
75 /** Add a new work procedure, fp, to be called with ud when nothing else to do.
77 * \param fp a pointer to the work procedure callback function.
78 * \param ud a pointer to be passed to the callback function when called.
79 * \return a unique id for use with rmWorkProc().
81 extern int addWorkProc (WPF *fp, void *ud);
83 /** Remove the work procedure with the given \e id, as returned from addWorkProc().
85 * \param wid the work procedure callback ID returned from addWorkProc().
87 extern void rmWorkProc (int wid);
89 /** Register a new timer function, \e fp, to be called with \e ud as argument after \e ms. Add to list in order of decreasing time from epoch, ie, last entry runs soonest. The timer will only invoke the callback function \b once. You need to call addTimer again if you want to repeat the process.
91 * \param ms timer period in milliseconds.
92 * \param fp a pointer to the callback function.
93 * \param ud a pointer to be passed to the callback function when called.
94 * \return a unique id for use with rmTimer().
96 extern int addTimer (int ms, TCF *fp, void *ud);
98 /** Remove the timer with the given \e id, as returned from addTimer().
100 * \param tid the timer callback ID returned from addTimer().
102 extern void rmTimer (int tid);
104 /*@}*/
106 #ifdef __cplusplus
108 #endif
110 #endif