svc_scriptobji.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #pragma once
  2. #include "svc_scriptobji.h"
  3. // derive from this one
  4. class svc_scriptObjectI : public svc_scriptObject {
  5. public:
  6. virtual ScriptObjectController *getController(int n)=0;
  7. virtual void onRegisterClasses(ScriptObjectController *rootController) {};
  8. protected:
  9. RECVS_DISPATCH;
  10. };
  11. template <class T>
  12. class ScriptObjectControllerCreator : public svc_scriptObjectI {
  13. public:
  14. static const char *getServiceName() { return "ScriptObjectControllerCreator"; }
  15. ScriptObjectControllerCreator()
  16. {
  17. }
  18. virtual ~ScriptObjectControllerCreator()
  19. {
  20. }
  21. virtual ScriptObjectController *getController(int n)
  22. {
  23. if (n == 0) return &single_controller;
  24. return NULL;
  25. }
  26. private:
  27. T single_controller;
  28. };
  29. #include <api/service/servicei.h>
  30. template <class T>
  31. class ScriptObjectCreator : public waServiceFactoryTSingle<svc_scriptObject, T> {};
  32. #include <api/service/svc_enum.h>
  33. class ExternalScriptObjectEnum : public SvcEnumT<svc_scriptObject> {
  34. public:
  35. ExternalScriptObjectEnum() { }
  36. protected:
  37. virtual int testService(svc_scriptObject*svc) {
  38. return (svc->getController(0) != NULL);
  39. }
  40. };