 |
CTK
0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
|
Go to the documentation of this file.
21 #ifndef __ctkAbstractFactory_h
22 #define __ctkAbstractFactory_h
27 #include <QSharedPointer>
28 #include <QStringList>
31 # pragma warning(disable: 4505)
41 template<
typename BaseClassType>
84 QStringList InstantiateErrorStrings;
85 QStringList InstantiateWarningStrings;
86 QStringList LoadErrorStrings;
87 QStringList LoadWarningStrings;
99 template<
typename BaseClassType>
117 virtual BaseClassType *
instance(
const QString& itemKey);
125 virtual QString
path(
const QString& itemKey){ Q_UNUSED(itemKey);
return QString(); }
145 const QString& status,
bool display);
165 QSharedPointer<HashType> SharedRegisteredItemMap;
170 #include "ctkAbstractFactory.tpp"
virtual QString path(const QString &itemKey)
Get path associated with the item identified by itemKey Should be overloaded in subclasse.
void displayStatusMessage(const QtMsgType &type, const QString &description, const QString &status, bool display)
QStringList instantiateWarningStrings() const
ctkAbstractFactory()
Constructor/Desctructor.
void clearInstantiateErrorStrings()
void appendInstantiateWarningString(const QString &msg)
ctkAbstractFactory is the base class of all the factory where items need to be registered before bein...
void clearLoadWarningStrings()
virtual BaseClassType * instanciator()=0
Must be reimplemented in subclasses to instanciate a BaseClassType*.
QStringList itemKeys() const
Get list of all registered item keys.
virtual BaseClassType * instantiate(const QString &itemKey)
Create an instance of the object. The item corresponding to the key should have been registered befor...
void appendLoadErrorString(const QString &msg)
virtual BaseClassType * instance(const QString &itemKey)
Return the instance associated with itemKey if any, otherwise return 0.
virtual void uninstantiate()
BaseClassType * instantiate()
QStringList instantiateErrorStrings() const
void setSharedItems(const QSharedPointer< HashType > &items)
virtual void printAdditionalInfo()
BaseClassType * instance() const
virtual void registerItems()
Register items with the factory Method provided for convenience - Should be overloaded in subclasse.
QSharedPointer< HashType > sharedItems()
ctkAbstractFactoryItem< BaseClassType > * sharedItem(const QString &itemKey) const
QStringList loadWarningStrings() const
QHash< QString, QSharedPointer< ctkAbstractFactoryItem< BaseClassType > > > HashType
void setVerbose(bool value)
void setVerbose(bool value)
Enabled verbose output Warning and error message will be printed to standard outputs.
virtual ~ctkAbstractFactoryItem()
void appendInstantiateErrorString(const QString &msg)
ctkAbstractFactoryItem< BaseClassType > * item(const QString &itemKey) const
Get a Factory item given its itemKey. Return 0 if any.
bool isInstantiated() const
void appendLoadWarningString(const QString &msg)
HashType::const_iterator ConstIterator
QStringList loadErrorStrings() const
void clearInstantiateWarningStrings()
bool registerItem(const QString &key, const QSharedPointer< ctkAbstractFactoryItem< BaseClassType > > &item)
Call the load method associated with the item. If succesfully loaded, add it to the internal map.
void clearLoadErrorStrings()
HashType::iterator Iterator
virtual ~ctkAbstractFactory()
void uninstantiate(const QString &itemKey)
Uninstanciate the object. Do nothing if the item given by the key has not be instantiated nor registe...