CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
Public Types | Public Member Functions | Protected Types | Protected Member Functions | List of all members
ctkAbstractFactory< BaseClassType > Class Template Reference

ctkAbstractFactory is the base class of all the factory where items need to be registered before being instantiated. More...

#include <Libs/Core/ctkAbstractFactory.h>

Inheritance diagram for ctkAbstractFactory< BaseClassType >:
Inheritance graph
[legend]

Public Types

typedef QHash< QString, QSharedPointer< ctkAbstractFactoryItem< BaseClassType > > > HashType
 

Public Member Functions

 ctkAbstractFactory ()
 Constructor/Desctructor. More...
 
virtual BaseClassType * instance (const QString &itemKey)
 Return the instance associated with itemKey if any, otherwise return 0. More...
 
virtual BaseClassType * instantiate (const QString &itemKey)
 Create an instance of the object. The item corresponding to the key should have been registered before. More...
 
QStringList itemKeys () const
 Get list of all registered item keys. More...
 
virtual QString path (const QString &itemKey)
 Get path associated with the item identified by itemKey Should be overloaded in subclasse. More...
 
virtual void printAdditionalInfo ()
 
virtual void registerItems ()
 Register items with the factory Method provided for convenience - Should be overloaded in subclasse. More...
 
void setSharedItems (const QSharedPointer< HashType > &items)
 
void setVerbose (bool value)
 Enabled verbose output Warning and error message will be printed to standard outputs. More...
 
QSharedPointer< HashTypesharedItems ()
 
void uninstantiate (const QString &itemKey)
 Uninstanciate the object. Do nothing if the item given by the key has not be instantiated nor registered. More...
 
bool verbose () const
 
virtual ~ctkAbstractFactory ()
 

Protected Types

typedef HashType::const_iterator ConstIterator
 
typedef HashType::iterator Iterator
 

Protected Member Functions

void displayStatusMessage (const QtMsgType &type, const QString &description, const QString &status, bool display)
 
ctkAbstractFactoryItem< BaseClassType > * item (const QString &itemKey) const
 Get a Factory item given its itemKey. Return 0 if any. More...
 
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. More...
 
ctkAbstractFactoryItem< BaseClassType > * sharedItem (const QString &itemKey) const
 

Detailed Description

template<typename BaseClassType>
class ctkAbstractFactory< BaseClassType >

ctkAbstractFactory is the base class of all the factory where items need to be registered before being instantiated.

ctkAbstractFactory contains a collection of ctkAbstractFactoryItems that are uniquely identifyed by a key. Subclasses of ctkAbstractFactory are responsible for populating the list of ctkAbstractFactoryItems. BaseClassType could be any type (most probably a QObject)

Definition at line 100 of file ctkAbstractFactory.h.

Member Typedef Documentation

◆ ConstIterator

template<typename BaseClassType >
typedef HashType::const_iterator ctkAbstractFactory< BaseClassType >::ConstIterator
protected

Definition at line 156 of file ctkAbstractFactory.h.

◆ HashType

template<typename BaseClassType >
typedef QHash<QString, QSharedPointer<ctkAbstractFactoryItem<BaseClassType> > > ctkAbstractFactory< BaseClassType >::HashType

Definition at line 104 of file ctkAbstractFactory.h.

◆ Iterator

template<typename BaseClassType >
typedef HashType::iterator ctkAbstractFactory< BaseClassType >::Iterator
protected

Definition at line 157 of file ctkAbstractFactory.h.

Constructor & Destructor Documentation

◆ ctkAbstractFactory()

template<typename BaseClassType >
ctkAbstractFactory< BaseClassType >::ctkAbstractFactory ( )

Constructor/Desctructor.

◆ ~ctkAbstractFactory()

template<typename BaseClassType >
virtual ctkAbstractFactory< BaseClassType >::~ctkAbstractFactory ( )
virtual

Member Function Documentation

◆ displayStatusMessage()

template<typename BaseClassType >
void ctkAbstractFactory< BaseClassType >::displayStatusMessage ( const QtMsgType &  type,
const QString &  description,
const QString &  status,
bool  display 
)
protected

◆ instance()

template<typename BaseClassType >
virtual BaseClassType* ctkAbstractFactory< BaseClassType >::instance ( const QString &  itemKey)
virtual

Return the instance associated with itemKey if any, otherwise return 0.

◆ instantiate()

template<typename BaseClassType >
virtual BaseClassType* ctkAbstractFactory< BaseClassType >::instantiate ( const QString &  itemKey)
virtual

Create an instance of the object. The item corresponding to the key should have been registered before.

◆ item()

template<typename BaseClassType >
ctkAbstractFactoryItem<BaseClassType>* ctkAbstractFactory< BaseClassType >::item ( const QString &  itemKey) const
protected

Get a Factory item given its itemKey. Return 0 if any.

◆ itemKeys()

template<typename BaseClassType >
QStringList ctkAbstractFactory< BaseClassType >::itemKeys ( ) const

Get list of all registered item keys.

◆ path()

template<typename BaseClassType >
virtual QString ctkAbstractFactory< BaseClassType >::path ( const QString &  itemKey)
inlinevirtual

Get path associated with the item identified by itemKey Should be overloaded in subclasse.

Reimplemented in ctkAbstractFileBasedFactory< BaseClassType >.

Definition at line 125 of file ctkAbstractFactory.h.

◆ printAdditionalInfo()

template<typename BaseClassType >
virtual void ctkAbstractFactory< BaseClassType >::printAdditionalInfo ( )
virtual

◆ registerItem()

template<typename BaseClassType >
bool ctkAbstractFactory< BaseClassType >::registerItem ( const QString &  key,
const QSharedPointer< ctkAbstractFactoryItem< BaseClassType > > &  item 
)
protected

Call the load method associated with the item. If succesfully loaded, add it to the internal map.

◆ registerItems()

template<typename BaseClassType >
virtual void ctkAbstractFactory< BaseClassType >::registerItems ( )
inlinevirtual

Register items with the factory Method provided for convenience - Should be overloaded in subclasse.

Definition at line 135 of file ctkAbstractFactory.h.

◆ setSharedItems()

template<typename BaseClassType >
void ctkAbstractFactory< BaseClassType >::setSharedItems ( const QSharedPointer< HashType > &  items)

◆ setVerbose()

template<typename BaseClassType >
void ctkAbstractFactory< BaseClassType >::setVerbose ( bool  value)

Enabled verbose output Warning and error message will be printed to standard outputs.

◆ sharedItem()

template<typename BaseClassType >
ctkAbstractFactoryItem<BaseClassType>* ctkAbstractFactory< BaseClassType >::sharedItem ( const QString &  itemKey) const
protected

◆ sharedItems()

template<typename BaseClassType >
QSharedPointer<HashType> ctkAbstractFactory< BaseClassType >::sharedItems ( )

◆ uninstantiate()

template<typename BaseClassType >
void ctkAbstractFactory< BaseClassType >::uninstantiate ( const QString &  itemKey)

Uninstanciate the object. Do nothing if the item given by the key has not be instantiated nor registered.

◆ verbose()

template<typename BaseClassType >
bool ctkAbstractFactory< BaseClassType >::verbose ( ) const

The documentation for this class was generated from the following file: