CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkAbstractLibraryFactory.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Library: CTK
4 
5  Copyright (c) Kitware Inc.
6 
7  Licensed under the Apache License, Version 2.0 (the "License");
8  you may not use this file except in compliance with the License.
9  You may obtain a copy of the License at
10 
11  http://www.apache.org/licenses/LICENSE-2.0.txt
12 
13  Unless required by applicable law or agreed to in writing, software
14  distributed under the License is distributed on an "AS IS" BASIS,
15  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  See the License for the specific language governing permissions and
17  limitations under the License.
18 
19 =========================================================================*/
20 
21 #ifndef __ctkAbstractLibraryFactory_h
22 #define __ctkAbstractLibraryFactory_h
23 
24 // Qt includes
25 #include <QFileInfo>
26 #include <QLibrary>
27 #include <QStringList>
28 
29 // CTK includes
31 
32 //----------------------------------------------------------------------------
34 template<typename BaseClassType>
36 {
37 
38 public:
39 
40 #if QT_VERSION < 0x50000
41  typedef void* SymbolAddressType;
42 #else
43  typedef QFunctionPointer SymbolAddressType;
44 #endif
45 
46 protected:
49 
50 public:
51  //explicit ctkFactoryLibraryItem(const QString& path);
52 
53  virtual bool load();
54 
57  void setSymbols(const QStringList& symbols);
58 
60  void setLoadHints(QLibrary::LoadHints hints);
61 
66  bool resolve();
67 
70  SymbolAddressType symbolAddress(const QString& symbol)const;
71 
72 protected:
73  mutable QLibrary Library;
75  QStringList Symbols;
76 };
77 
78 //----------------------------------------------------------------------------
80 template<typename BaseClassType>
82  : public ctkAbstractFileBasedFactory<BaseClassType>
83 {
84 public:
86  void setSymbols(const QStringList& symbols);
87 
88 protected:
89  virtual bool isValidFile(const QFileInfo& file)const;
91 
92 private:
93  QStringList Symbols;
94 };
95 
96 #include "ctkAbstractLibraryFactory.tpp"
97 
98 #endif
ctkAbstractLibraryFactory::initItem
virtual void initItem(ctkAbstractFactoryItem< BaseClassType > *item)
ctkAbstractFactoryFileBasedItem
Definition: ctkAbstractFileBasedFactory.h:36
ctkFactoryLibraryItem::Library
QLibrary Library
Definition: ctkAbstractLibraryFactory.h:73
ctkFactoryLibraryItem::symbolAddress
SymbolAddressType symbolAddress(const QString &symbol) const
Get symbol address.
ctkFactoryLibraryItem::resolve
bool resolve()
Resolve symbols.
ctkFactoryLibraryItem::Symbols
QStringList Symbols
Definition: ctkAbstractLibraryFactory.h:75
ctkFactoryLibraryItem
Definition: ctkAbstractLibraryFactory.h:36
ctkFactoryLibraryItem::load
virtual bool load()
ctkAbstractFileBasedFactory
Definition: ctkAbstractFileBasedFactory.h:50
ctkFactoryLibraryItem::SymbolAddressType
void * SymbolAddressType
Definition: ctkAbstractLibraryFactory.h:41
ctkFactoryLibraryItem::setLoadHints
void setLoadHints(QLibrary::LoadHints hints)
Set lookup hints for symbol resolution. See QLibrary documentation.
ctkFactoryLibraryItem::ResolvedSymbols
QHash< QString, SymbolAddressType > ResolvedSymbols
Definition: ctkAbstractLibraryFactory.h:74
QHash
Definition: ctkCmdLineModuleFrontend.h:29
ctkAbstractLibraryFactory::setSymbols
void setSymbols(const QStringList &symbols)
Set the list of symbols.
ctkAbstractLibraryFactory
Definition: ctkAbstractLibraryFactory.h:83
ctkFactoryLibraryItem::ConstIterator
QHash< QString, SymbolAddressType >::const_iterator ConstIterator
Definition: ctkAbstractLibraryFactory.h:47
ctkAbstractLibraryFactory::isValidFile
virtual bool isValidFile(const QFileInfo &file) const
ctkAbstractFileBasedFactory.h
ctkFactoryLibraryItem::Iterator
QHash< QString, SymbolAddressType >::iterator Iterator
Definition: ctkAbstractLibraryFactory.h:48
ctkAbstractFactory::item
ctkAbstractFactoryItem< BaseClassType > * item(const QString &itemKey) const
Get a Factory item given its itemKey. Return 0 if any.
ctkAbstractFactoryItem
Definition: ctkAbstractFactory.h:43
ctkFactoryLibraryItem::setSymbols
void setSymbols(const QStringList &symbols)
Set list of required symbols.