ctkCmdLineModuleManager.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) German Cancer Research Center,
  4. Division of Medical and Biological Informatics
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. =============================================================================*/
  15. #ifndef CTKCMDLINEMODULEMANAGER_H
  16. #define CTKCMDLINEMODULEMANAGER_H
  17. #include <ctkCommandLineModulesCoreExport.h>
  18. #include <QStringList>
  19. #include <QString>
  20. #include "ctkCmdLineModuleReference.h"
  21. struct ctkCmdLineModuleBackend;
  22. struct ctkCmdLineModuleFrontendFactory;
  23. class ctkCmdLineModuleFrontend;
  24. class ctkCmdLineModuleFuture;
  25. struct ctkCmdLineModuleManagerPrivate;
  26. /**
  27. * \class ctkCmdLineModuleManager
  28. * \brief Main manager class to handle loading and unloading of modules.
  29. * \ingroup CommandLineModulesCore
  30. */
  31. class CTK_CMDLINEMODULECORE_EXPORT ctkCmdLineModuleManager : public QObject
  32. {
  33. Q_OBJECT
  34. public:
  35. enum ValidationMode {
  36. /** registerModule() will throw an exception if the XML is invalid */
  37. STRICT_VALIDATION,
  38. /** no XML schema validation at all */
  39. SKIP_VALIDATION,
  40. /**
  41. * registerModule() will validate the XML description but proceed with
  42. * registration on validation error.
  43. */
  44. WEAK_VALIDATION
  45. };
  46. ctkCmdLineModuleManager(ValidationMode = STRICT_VALIDATION, const QString& cacheDir = QString());
  47. ~ctkCmdLineModuleManager();
  48. void registerBackend(ctkCmdLineModuleBackend* backend);
  49. ctkCmdLineModuleReference registerModule(const QUrl& location);
  50. void unregisterModule(const ctkCmdLineModuleReference& moduleRef);
  51. ctkCmdLineModuleReference moduleReference(const QUrl& location) const;
  52. QList<ctkCmdLineModuleReference> moduleReferences() const;
  53. ctkCmdLineModuleFuture run(ctkCmdLineModuleFrontend* frontend);
  54. Q_SIGNALS:
  55. void moduleRegistered(const ctkCmdLineModuleReference&);
  56. void moduleUnregistered(const ctkCmdLineModuleReference&);
  57. private:
  58. QScopedPointer<ctkCmdLineModuleManagerPrivate> d;
  59. Q_DISABLE_COPY(ctkCmdLineModuleManager)
  60. };
  61. #endif // CTKCMDLINEMODULEMANAGER_H