Slicer  4.11
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
qSlicerCLILoadableModuleFactory.h
Go to the documentation of this file.
1 /*==============================================================================
2 
3  Program: 3D Slicer
4 
5  Copyright (c) Kitware Inc.
6 
7  See COPYRIGHT.txt
8  or http://www.slicer.org/copyright/copyright.txt for details.
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 
16  This file was originally developed by Jean-Christophe Fillion-Robin, Kitware Inc.
17  and was partially funded by NIH grant 3P41RR013218-12S1
18 
19 ==============================================================================*/
20 
21 
22 #ifndef __qSlicerCLILoadableModuleFactory_h
23 #define __qSlicerCLILoadableModuleFactory_h
24 
25 // CTK includes
26 #include <ctkPimpl.h>
27 #include <ctkAbstractLibraryFactory.h>
28 
29 // Slicer includes
30 #include "qSlicerAbstractModule.h"
31 #include "qSlicerBaseQTCLIExport.h"
32 
33 class ModuleDescription;
34 class ModuleLogo;
35 class qSlicerCLIModule;
36 
37 //-----------------------------------------------------------------------------
39  : public ctkFactoryLibraryItem<qSlicerAbstractCoreModule>
40 {
41 public:
42  typedef ctkFactoryLibraryItem<qSlicerAbstractCoreModule> Superclass;
43  qSlicerCLILoadableModuleFactoryItem(const QString& newTempDirectory);
44  bool load() override;
45 
46  static void loadLibraryAndResolveSymbols(
47  void* libraryLoader, ModuleDescription& desc);
48 
49 protected:
51  QString xmlModuleDescriptionFilePath()const;
52 
55  bool resolveSymbols(ModuleDescription& desc);
56  static bool updateLogo(qSlicerCLILoadableModuleFactoryItem* item, ModuleLogo& logo);
57 private:
58  QString TempDirectory;
59 };
60 
61 class qSlicerCLILoadableModuleFactoryPrivate;
62 
63 //-----------------------------------------------------------------------------
64 class Q_SLICER_BASE_QTCLI_EXPORT qSlicerCLILoadableModuleFactory :
65  public ctkAbstractLibraryFactory<qSlicerAbstractCoreModule>
66 {
67 public:
68  typedef ctkAbstractLibraryFactory<qSlicerAbstractCoreModule> Superclass;
71 
73  void registerItems() override;
74 
81  QString fileNameToKey(const QString& fileName)const override;
82 
83  void setTempDirectory(const QString& newTempDirectory);
84 
85 protected:
86  ctkAbstractFactoryItem<qSlicerAbstractCoreModule>*
87  createFactoryFileBasedItem() override;
88 
89  bool isValidFile(const QFileInfo& file)const override;
90 
91 protected:
92 
93  QScopedPointer<qSlicerCLILoadableModuleFactoryPrivate> d_ptr;
94 
95 private:
96  Q_DECLARE_PRIVATE(qSlicerCLILoadableModuleFactory);
97  Q_DISABLE_COPY(qSlicerCLILoadableModuleFactory);
98 };
99 
100 #endif
bool resolveSymbols(ModuleDescription &desc)
ctkAbstractLibraryFactory< qSlicerAbstractCoreModule > Superclass
static bool updateLogo(qSlicerCLILoadableModuleFactoryItem *item, ModuleLogo &logo)
static void loadLibraryAndResolveSymbols(void *libraryLoader, ModuleDescription &desc)
QScopedPointer< qSlicerCLILoadableModuleFactoryPrivate > d_ptr
qSlicerAbstractCoreModule is the base class of any module in Slicer.
QString xmlModuleDescriptionFilePath() const
Return path of the expected XML file.
qSlicerCLILoadableModuleFactoryItem(const QString &newTempDirectory)
qSlicerAbstractCoreModule * instanciator() override
ctkFactoryLibraryItem< qSlicerAbstractCoreModule > Superclass