1.1 --- a/libnotifier/include/notifier/notifier.h Tue Mar 21 19:23:34 2023 +0100
1.2 +++ b/libnotifier/include/notifier/notifier.h Tue Mar 21 21:49:00 2023 +0100
1.3 @@ -26,8 +26,11 @@
1.4 #include <map>
1.5 #include <mutex>
1.6
1.7 +#include <fsserver/resource.h>
1.8 #include <systypes/base.h>
1.9
1.10 +#include "notifier_interface.h"
1.11 +
1.12
1.13
1.14 /* Object-specific notification details. */
1.15 @@ -78,9 +81,9 @@
1.16
1.17 ObjectNotificationStates _state;
1.18
1.19 - /* Notifier thread details. */
1.20 + /* Notifier resource details. */
1.21
1.22 - l4_cap_idx_t _thread = L4_INVALID_CAP;
1.23 + ipc_server_config_type *_config = NULL;
1.24 bool _started = false;
1.25
1.26 /* Convenience method to access object state. */
1.27 @@ -89,9 +92,6 @@
1.28
1.29 /* Helper methods. */
1.30
1.31 - virtual void _notify(notifiable_t *object, notify_flags_t flags,
1.32 - notify_values_t values) = 0;
1.33 -
1.34 virtual bool _transfer(ObjectNotificationState &state, notifiable_t *object);
1.35
1.36 public:
1.37 @@ -105,13 +105,12 @@
1.38
1.39 virtual long unsubscribe(notifiable_t *object);
1.40
1.41 - virtual long get_endpoint(notifiable_t *object, l4_cap_idx_t *endpoint, bool create);
1.42 -
1.43 virtual long remove_endpoint(notifiable_t *object, l4_cap_idx_t endpoint);
1.44
1.45 - /* Event handling support. */
1.46 + /* Helper methods. */
1.47
1.48 - virtual void mainloop();
1.49 + virtual void notify(notifiable_t *object, notify_flags_t flags,
1.50 + notify_values_t values) = 0;
1.51 };
1.52
1.53
1.54 @@ -136,15 +135,17 @@
1.55
1.56 /* Helper methods. */
1.57
1.58 - virtual void _notify(notifiable_t *object, notify_flags_t flags,
1.59 - notify_values_t values);
1.60 -
1.61 virtual bool _retrieve(notifiable_t **object);
1.62
1.63 virtual bool _retrieve_for_object(notifiable_t *object);
1.64
1.65 public:
1.66 virtual long wait(notifiable_t **object);
1.67 +
1.68 + /* Helper methods. */
1.69 +
1.70 + virtual void notify(notifiable_t *object, notify_flags_t flags,
1.71 + notify_values_t values);
1.72 };
1.73
1.74
1.75 @@ -153,14 +154,46 @@
1.76
1.77 class SpecificObjectNotifier : public ObjectNotifier
1.78 {
1.79 -protected:
1.80 +public:
1.81 + virtual long wait_object(notifiable_t *object);
1.82 +
1.83 /* Helper methods. */
1.84
1.85 - virtual void _notify(notifiable_t *object, notify_flags_t flags,
1.86 - notify_values_t values);
1.87 + virtual void notify(notifiable_t *object, notify_flags_t flags,
1.88 + notify_values_t values);
1.89 +};
1.90 +
1.91 +
1.92 +
1.93 +/* Object-specific notifier resource. */
1.94 +
1.95 +class NotifierResource : public Notifier, public Resource
1.96 +{
1.97 +protected:
1.98 + ObjectNotifier *_notifier;
1.99 + notifiable_t *_object;
1.100
1.101 public:
1.102 - virtual long wait_object(notifiable_t *object);
1.103 + explicit NotifierResource(ObjectNotifier *notifier, notifiable_t *object)
1.104 + : _notifier(notifier), _object(object)
1.105 + {
1.106 + }
1.107 +
1.108 + explicit NotifierResource()
1.109 + : _notifier(NULL), _object(NULL)
1.110 + {
1.111 + }
1.112 +
1.113 + /* Server details. */
1.114 +
1.115 + virtual ipc_server_default_config_type config();
1.116 +
1.117 + virtual void *interface()
1.118 + { return static_cast<Notifier *>(this); }
1.119 +
1.120 + /* Notifier methods. */
1.121 +
1.122 + virtual long notify(notify_flags_t flags, notify_values_t values);
1.123 };
1.124
1.125