CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkPlugin.h
Go to the documentation of this file.
1 /*=============================================================================
2 
3  Library: CTK
4 
5  Copyright (c) German Cancer Research Center,
6  Division of Medical and Biological Informatics
7 
8  Licensed under the Apache License, Version 2.0 (the "License");
9  you may not use this file except in compliance with the License.
10  You may obtain a copy of the License at
11 
12  http://www.apache.org/licenses/LICENSE-2.0
13 
14  Unless required by applicable law or agreed to in writing, software
15  distributed under the License is distributed on an "AS IS" BASIS,
16  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  See the License for the specific language governing permissions and
18  limitations under the License.
19 
20 =============================================================================*/
21 
22 #ifndef CTKPLUGIN_H
23 #define CTKPLUGIN_H
24 
25 #include <QHash>
26 #include <QWeakPointer>
27 #include <QMetaType>
28 #include <QUrl>
29 
30 #include "ctkVersion.h"
31 #include "ctkPluginLocalization.h"
32 #include "ctkPluginConstants.h"
34 
35 class ctkPluginContext;
36 class ctkPluginArchive;
37 class ctkPluginFrameworkContext;
38 class ctkPluginPrivate;
39 
83 class CTK_PLUGINFW_EXPORT ctkPlugin {
84 
85 public:
86 
87  enum State {
97  UNINSTALLED = 0x00000001,
98 
111  INSTALLED = 0x00000002,
112 
129  RESOLVED = 0x00000004,
130 
147  STARTING = 0x00000008,
148 
159  STOPPING = 0x00000010,
160 
168  ACTIVE = 0x00000020
169  };
170 
176  Q_DECLARE_FLAGS(States, State)
177 
178  enum StartOption {
179 
192  START_TRANSIENT = 0x00000001,
193 
207  START_ACTIVATION_POLICY = 0x00000002
208 
209  };
210 
216  Q_DECLARE_FLAGS(StartOptions, StartOption)
217 
218  enum StopOption {
231  STOP_TRANSIENT = 0x00000001
232  };
233 
239  Q_DECLARE_FLAGS(StopOptions, StopOption)
240 
241  virtual ~ctkPlugin();
242 
253  State getState() const;
254 
358  virtual void start(const StartOptions& options = START_ACTIVATION_POLICY);
359 
432  virtual void stop(const StopOptions& options = 0);
433 
512  void update(const QUrl &updateLocation = QUrl());
513 
573  virtual void uninstall();
574 
591  ctkPluginContext* getPluginContext() const;
592 
615  long getPluginId() const;
616 
632  QString getLocation() const;
633 
661  virtual QHash<QString, QString> getHeaders();
662 
677  QString getSymbolicName() const;
678 
700  virtual QStringList getResourceList(const QString& path) const;
701 
741  virtual QStringList findResources(const QString& path, const QString& filePattern, bool recurse) const;
742 
759  virtual QByteArray getResource(const QString& path) const;
760 
780  ctkPluginLocalization getPluginLocalization(const QLocale& locale,
781  const QString& base = ctkPluginConstants::PLUGIN_LOCALIZATION_DEFAULT_BASENAME) const;
782 
794  ctkVersion getVersion() const;
795 
796 protected:
797 
798  friend class ctkPluginFramework;
799  friend class ctkPluginFrameworkLauncherPrivate;
800  friend class ctkPluginFrameworkPrivate;
801  friend class ctkPluginFrameworkContext;
802  friend class ctkPlugins;
803  friend class ctkServiceReferencePrivate;
804 
805  // Do NOT change this to QScopedPointer<ctkPluginPrivate>!
806  // We would need to include ctkPlugin.h (and ctkPluginPrivate_p.h)
807  // at a lot of places...
808  ctkPluginPrivate* d_ptr;
809 
811  void init(ctkPluginPrivate* dd);
812  void init(const QWeakPointer<ctkPlugin>& self, ctkPluginFrameworkContext* fw, QSharedPointer<ctkPluginArchive> ba);
813 
814 private:
815  Q_DECLARE_PRIVATE(ctkPlugin)
816  Q_DISABLE_COPY(ctkPlugin)
817 };
818 
825 Q_DECLARE_METATYPE(QSharedPointer<ctkPlugin>)
826 
830 
831 CTK_PLUGINFW_EXPORT QDebug operator<<(QDebug debug, ctkPlugin::State state);
832 CTK_PLUGINFW_EXPORT QDebug operator<<(QDebug debug, const ctkPlugin& plugin);
833 CTK_PLUGINFW_EXPORT QDebug operator<<(QDebug debug, ctkPlugin const * plugin);
834 
835 CTK_PLUGINFW_EXPORT ctkLogStream& operator<<(ctkLogStream& stream, ctkPlugin const * plugin);
836 CTK_PLUGINFW_EXPORT ctkLogStream& operator<<(ctkLogStream& stream, const QSharedPointer<ctkPlugin>& plugin);
837 
840 #endif // CTKPLUGIN_H
Q_DECLARE_METATYPE(ctkDICOMPersonName)
Q_DECLARE_OPERATORS_FOR_FLAGS(ctkVTKDataSetModel::AttributeTypes)