1
0

SysCallbacks.h 967 B

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef NULLSOFT_SYSCALLBACKSH
  2. #define NULLSOFT_SYSCALLBACKSH
  3. #include <api/syscb/api_syscb.h>
  4. #include "../nu/AutoLock.h"
  5. #include <map>
  6. #include <vector>
  7. class SysCallbacks : public api_syscb
  8. {
  9. public:
  10. static const char *getServiceName() { return "System Callback API"; }
  11. static const GUID getServiceGuid() { return syscbApiServiceGuid; }
  12. public:
  13. SysCallbacks();
  14. int syscb_registerCallback(SysCallback *cb, void *param = NULL);
  15. int syscb_deregisterCallback(SysCallback *cb);
  16. int syscb_issueCallback(int eventtype, int msg, intptr_t param1 = 0, intptr_t param2 = 0);
  17. SysCallback *syscb_enum(int eventtype, size_t n);
  18. protected:
  19. RECVS_DISPATCH;
  20. private:
  21. Nullsoft::Utility::LockGuard callbackGuard;
  22. typedef std::vector<SysCallback*> CallbackList;
  23. typedef std::map<int, CallbackList*> EventMap;
  24. EventMap callback_map;
  25. CallbackList deleteMeAfterCallbacks;
  26. bool inCallback;
  27. volatile int reentry;
  28. };
  29. extern SysCallbacks *sysCallbacks;
  30. #endif