api_dependent.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifndef __WASABI_API_DEPENDENT_H
  2. #define __WASABI_API_DEPENDENT_H
  3. #include <bfc/dispatch.h>
  4. #include "api_dependentviewer.h"
  5. // we define some common event codes here. if your object needs more send
  6. // them as parameters to OBJECTSPECIFIC
  7. // some system-level codes for cb param. You can implement your own events
  8. // with DEPCB_EVENT and the parameters
  9. namespace DependentCB
  10. {
  11. enum {
  12. DEPCB_NOP = 0,
  13. DEPCB_DELETED = 100, // object being deleted
  14. DEPCB_EVENT = 1000, // object-specific event. use param1 etc to send your messages
  15. };
  16. };
  17. class NOVTABLE ifc_dependent : public Dispatchable
  18. {
  19. protected:
  20. ifc_dependent() {}
  21. ~ifc_dependent() {}
  22. public:
  23. void dependent_regViewer(ifc_dependentviewer *viewer, int add) ;
  24. void *dependent_getInterface(const GUID *classguid);
  25. DISPATCH_CODES
  26. {
  27. API_DEPENDENT_REGVIEWER = 10,
  28. API_DEPENDENT_GETINTERFACE = 20,
  29. };
  30. };
  31. inline void ifc_dependent::dependent_regViewer(api_dependentviewer *viewer, int add)
  32. {
  33. _voidcall(API_DEPENDENT_REGVIEWER, viewer, add);
  34. }
  35. inline void *ifc_dependent::dependent_getInterface(const GUID *classguid)
  36. {
  37. return _call(API_DEPENDENT_GETINTERFACE, (void *)0, classguid);
  38. }
  39. // this is a helper for dependent_getInterface
  40. #define HANDLEGETINTERFACE(x) { \
  41. if (*classguid == *x::depend_getClassGuid()) return static_cast<x *>(this); \
  42. }
  43. typedef ifc_dependent api_dependent;
  44. #endif