ccPluginInterface.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. //##########################################################################
  2. //# #
  3. //# CLOUDCOMPARE #
  4. //# #
  5. //# This program is free software; you can redistribute it and/or modify #
  6. //# it under the terms of the GNU General Public License as published by #
  7. //# the Free Software Foundation; version 2 of the License. #
  8. //# #
  9. //# This program is distributed in the hope that it will be useful, #
  10. //# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  11. //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  12. //# GNU General Public License for more details. #
  13. //# #
  14. //# COPYRIGHT: EDF R&D / TELECOM ParisTech (ENST-TSI) #
  15. //# #
  16. //##########################################################################
  17. #pragma once
  18. //Qt
  19. #include <QIcon>
  20. #include <QList>
  21. #include <QObject>
  22. #include <QPair>
  23. #include <QString>
  24. //Qt version
  25. #include <qglobal.h>
  26. class ccExternalFactory;
  27. class ccCommandLineInterface;
  28. //! Plugin type
  29. enum CC_PLUGIN_TYPE
  30. {
  31. CC_STD_PLUGIN = 1,
  32. CC_GL_FILTER_PLUGIN = 2,
  33. CC_IO_FILTER_PLUGIN = 4,
  34. };
  35. //! Standard CC plugin interface
  36. /** Version 3.2
  37. **/
  38. class ccPluginInterface
  39. {
  40. public:
  41. // Contact represents a person and is used for authors and maintainer lists
  42. struct Contact
  43. {
  44. QString name;
  45. QString email;
  46. };
  47. using ContactList = QList<Contact>;
  48. // Reference represents a journal article or online post about the plugin where
  49. // the user can find more information.
  50. struct Reference
  51. {
  52. QString article;
  53. QString url;
  54. };
  55. using ReferenceList = QList<Reference>;
  56. public:
  57. //! Virtual destructor
  58. virtual ~ccPluginInterface() = default;
  59. //! Returns plugin type (standard or OpenGL filter)
  60. virtual CC_PLUGIN_TYPE getType() const = 0;
  61. //! Is this plugin a core plugin?
  62. virtual bool isCore() const = 0;
  63. //! Returns (short) name (for menu entry, etc.)
  64. virtual QString getName() const = 0;
  65. //! Returns long name/description (for tooltip, etc.)
  66. virtual QString getDescription() const = 0;
  67. //! Returns icon
  68. /** Should be reimplemented if necessary
  69. **/
  70. virtual QIcon getIcon() const = 0;
  71. //! Returns a list of references (articles and websites) for the plugin
  72. //! This is optional.
  73. //! See qDummyPlugin for a real example.
  74. //! Added in v3.1 of the plugin interface.
  75. virtual ReferenceList getReferences() const = 0;
  76. //! Returns a list of the authors' names and email addresses
  77. //! This is optional.
  78. //! See qDummyPlugin for a real example.
  79. //! Added in v3.1 of the plugin interface.
  80. virtual ContactList getAuthors() const = 0;
  81. //! Returns a list of the maintainers' names and email addresses
  82. //! This is optional.
  83. //! See qDummyPlugin for a real example.
  84. //! Added in v3.1 of the plugin interface.
  85. virtual ContactList getMaintainers() const = 0;
  86. //! Starts the plugin
  87. /** Should be reimplemented if necessary.
  88. Used when 'starting' a plugin from the command line
  89. (to start a background service, a thread, etc.)
  90. **/
  91. virtual bool start() = 0;
  92. //! Stops the plugin
  93. /** Should be reimplemented if necessary.
  94. Used to stop a plugin previously started (see ccPluginInterface::start).
  95. **/
  96. virtual void stop() = 0;
  97. //! Returns the plugin's custom object factory (if any)
  98. /** Plugins may provide a factory to build custom objects.
  99. This allows qCC_db to properly code and decode the custom
  100. objects stream in BIN files. Custom objects must inherit the
  101. ccCustomHObject or ccCustomLeafObject interfaces.
  102. **/
  103. virtual ccExternalFactory* getCustomObjectsFactory() const = 0;
  104. //! Optional: registers commands (for the command line mode)
  105. /** Does nothing by default.
  106. \warning: don't use keywords that are already used by the main application or other plugins!
  107. (use a unique prefix for all commands if possible)
  108. **/
  109. virtual void registerCommands(ccCommandLineInterface* cmd) = 0;
  110. protected:
  111. friend class ccPluginManager;
  112. //! Set the IID of the plugin (which comes from Q_PLUGIN_METADATA).
  113. //! It is used to uniquely identify the plugin.
  114. virtual void setIID( const QString& iid ) = 0;
  115. //! Get the IID of the plugin.
  116. virtual const QString& IID() const = 0;
  117. };
  118. Q_DECLARE_METATYPE(const ccPluginInterface *);
  119. Q_DECLARE_INTERFACE(ccPluginInterface, "cccorp.cloudcompare.ccPluginInterface/3.2")