T-EMU  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>
13 
14 // The following interfaces are for non-timed events (or
15 // notifications). Notification 0 is reserved as a special
16 // no-notification handler connected id. Notifications have a name and
17 // are associated with an object. The subscriber can request a
18 // notification with a null object (i.e. will accept all identical
19 // notifications, or a given object, which means the notification
20 // handler will be called only for some objects. There is currently
21 // no way to depublish a notification, but the standard approach is to
22 // set the notification id to 0.
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 typedef void (*temu_NotificationHandler)(void *Arg, void *Source, void *NotInfo);
28 
32 int64_t temu_publishNotification(const char *NotName, void *Obj);
33 
35 
38 
39 int temu_subscribeNotification(const char *NotName, void *Source, void *Arg,
40  temu_NotificationHandler NotFunc);
41 
45 int temu_unsubscribeNotification(const char *NotName, void *Source,
46  temu_NotificationHandler NotFunc);
47 
50 void temu_notify(int64_t Id, void *NotInfo);
51 
55 static inline void
56 temu_notifyFast(int64_t *Id, void *NotInfo)
57 {
58  if (*Id) {
59  temu_notify(*Id, NotInfo);
60  }
61 }
62 
63 #ifdef __cplusplus
64 }
65 #endif
66 
67 #endif /* ! TEMU_EVENTS_H */
void(* temu_NotificationHandler)(void *Arg, void *Source, void *NotInfo)
Definition: Notifications.h:27
int64_t temu_publishNotification(const char *NotName, void *Obj)
void temu_notify(int64_t Id, void *NotInfo)
int temu_unsubscribeNotification(const char *NotName, void *Source, temu_NotificationHandler NotFunc)
int temu_subscribeNotification(const char *NotName, void *Source, void *Arg, temu_NotificationHandler NotFunc)
Install notification functions for the given event generated by source.