MyFactory.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #ifndef _MYFACTORY_H_
  2. #define _MYFACTORY_H_
  3. #include "api__bmp.h"
  4. #include <api/service/waservicefactory.h>
  5. #include <api/service/services.h>
  6. template <class T, class Base>
  7. class MyFactory : public waServiceFactory
  8. {
  9. public:
  10. MyFactory(GUID guid) : guid(guid) {}
  11. FOURCC GetServiceType() { return T::getServiceType(); }
  12. const char *GetServiceName() { return T::getServiceName(); }
  13. GUID GetGUID() { return guid; }
  14. void *GetInterface(int global_lock) { return (Base*)new T; }
  15. int SupportNonLockingInterface() {return 1;}
  16. int ReleaseInterface(void *ifc) { delete static_cast<T *>(static_cast<Base *>(ifc)); return 1; }
  17. const char *GetTestString() {return 0;}
  18. int ServiceNotify(int msg, int param1, int param2) {return 1;}
  19. private:
  20. GUID guid;
  21. protected:
  22. #define CBCLASS MyFactory
  23. START_DISPATCH_INLINE;
  24. CB(WASERVICEFACTORY_GETSERVICETYPE, GetServiceType)
  25. CB(WASERVICEFACTORY_GETSERVICENAME, GetServiceName)
  26. CB(WASERVICEFACTORY_GETGUID, GetGUID)
  27. CB(WASERVICEFACTORY_GETINTERFACE, GetInterface)
  28. CB(WASERVICEFACTORY_SUPPORTNONLOCKINGGETINTERFACE, SupportNonLockingInterface)
  29. CB(WASERVICEFACTORY_RELEASEINTERFACE, ReleaseInterface)
  30. CB(WASERVICEFACTORY_GETTESTSTRING, GetTestString)
  31. CB(WASERVICEFACTORY_SERVICENOTIFY, ServiceNotify)
  32. END_DISPATCH;
  33. #undef CBCLASS
  34. //RECVS_DISPATCH;
  35. };
  36. #endif