TEMU  3.0
The Terma Emulator
Notifications.h
Go to the documentation of this file.
1 //===-- temu-c/Notifications.h - Untimed Event API --------------*- C++ -*-===//
2 //
3 // TEMU: The Terma Emulator
4 // (c) Terma 2015
5 // Authors: Mattias Holm <maho (at) terma.com>
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef TEMU_NOTIFICATIONS_H
10 #define TEMU_NOTIFICATIONS_H
11 
12 #include <stdint.h>
14 #include "temu-c/Support/Objsys.h"
15 
16 // The following interfaces are for non-timed events (or
17 // notifications). Notification 0 is reserved as a special
18 // no-notification handler connected id. Notifications have a name and
19 // are associated with an object. The subscriber can request a
20 // notification with a null object (i.e. will accept all identical
21 // notifications, or a given object, which means the notification
22 // handler will be called only for some objects. There is currently
23 // no way to depublish a notification, but the standard approach is to
24 // set the notification id to 0.
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 typedef void (*temu_NotificationHandler)(void *Arg, temu_Object_ *Source, void *NotInfo);
30 
37 TEMU_API int64_t temu_publishNotification(const char *NotName, temu_Object_ *Obj);
38 
47 TEMU_API int temu_subscribeNotification(const char *NotName, temu_Object_ *Source, void *Arg,
48  temu_NotificationHandler NotFunc);
49 
58 TEMU_API int temu_unsubscribeNotification(const char *NotName, temu_Object_ *Source,
59  temu_NotificationHandler NotFunc);
60 
71 TEMU_API int temu_unsubscribeNotificationArg(const char *NotName, temu_Object_ *Source,
73  void *Arg);
74 
75 
81 TEMU_API void temu_notify(int64_t Id, void *NotInfo);
82 
89 static inline void
90 temu_notifyFast(int64_t *Id, void *NotInfo)
91 {
92  if (*Id) {
93  temu_notify(*Id, NotInfo);
94  }
95 }
96 
97 #ifdef __cplusplus
98 }
99 #endif
100 
101 #endif /* ! TEMU_EVENTS_H */
TEMU_API int temu_unsubscribeNotification(const char *NotName, temu_Object_ *Source, temu_NotificationHandler NotFunc)
TEMU_API int temu_unsubscribeNotificationArg(const char *NotName, temu_Object_ *Source, temu_NotificationHandler NotFunc, void *Arg)
#define TEMU_API
Definition: Attributes.h:53
#define temu_Object_
Definition: Temu2Compat.h:13
TEMU_API void temu_notify(int64_t Id, void *NotInfo)
void(* temu_NotificationHandler)(void *Arg, temu_Object_ *Source, void *NotInfo)
Definition: Notifications.h:29
TEMU_API int temu_subscribeNotification(const char *NotName, temu_Object_ *Source, void *Arg, temu_NotificationHandler NotFunc)
TEMU_API int64_t temu_publishNotification(const char *NotName, temu_Object_ *Obj)