TEMU  2
The Terma Emulator
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Notifications.h
Go to the documentation of this file.
1 //===-- temu-c/Notifications.h - Untimed Event API --------------*- C++ -*-===//
2 //
3 // T-EMU: 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 
15 // The following interfaces are for non-timed events (or
16 // notifications). Notification 0 is reserved as a special
17 // no-notification handler connected id. Notifications have a name and
18 // are associated with an object. The subscriber can request a
19 // notification with a null object (i.e. will accept all identical
20 // notifications, or a given object, which means the notification
21 // handler will be called only for some objects. There is currently
22 // no way to depublish a notification, but the standard approach is to
23 // set the notification id to 0.
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 typedef void (*temu_NotificationHandler)(void *Arg, void *Source, void *NotInfo);
29 
36 TEMU_API int64_t temu_publishNotification(const char *NotName, void *Obj);
37 
46 TEMU_API int temu_subscribeNotification(const char *NotName, void *Source, void *Arg,
47  temu_NotificationHandler NotFunc);
48 
57 TEMU_API int temu_unsubscribeNotification(const char *NotName, void *Source,
58  temu_NotificationHandler NotFunc);
59 
70 TEMU_API int temu_unsubscribeNotificationArg(const char *NotName, void *Source,
72  void *Arg);
73 
74 
80 TEMU_API void temu_notify(int64_t Id, void *NotInfo);
81 
88 static inline void
89 temu_notifyFast(int64_t *Id, void *NotInfo)
90 {
91  if (*Id) {
92  temu_notify(*Id, NotInfo);
93  }
94 }
95 
96 #ifdef __cplusplus
97 }
98 #endif
99 
100 #endif /* ! TEMU_EVENTS_H */
void(* temu_NotificationHandler)(void *Arg, void *Source, void *NotInfo)
Definition: Notifications.h:28
TEMU_API int64_t temu_publishNotification(const char *NotName, void *Obj)
TEMU_API void temu_notify(int64_t Id, void *NotInfo)
TEMU_API int temu_unsubscribeNotificationArg(const char *NotName, void *Source, temu_NotificationHandler NotFunc, void *Arg)
TEMU_API int temu_subscribeNotification(const char *NotName, void *Source, void *Arg, temu_NotificationHandler NotFunc)
TEMU_API int temu_unsubscribeNotification(const char *NotName, void *Source, temu_NotificationHandler NotFunc)
#define TEMU_API
Definition: Attributes.h:53