ctkAbstractPluginFactory.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Library:   CTK
00004  
00005   Copyright (c) 2010  Kitware Inc.
00006 
00007   Licensed under the Apache License, Version 2.0 (the "License");
00008   you may not use this file except in compliance with the License.
00009   You may obtain a copy of the License at
00010 
00011       http://www.commontk.org/LICENSE
00012 
00013   Unless required by applicable law or agreed to in writing, software
00014   distributed under the License is distributed on an "AS IS" BASIS,
00015   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00016   See the License for the specific language governing permissions and
00017   limitations under the License.
00018  
00019 =========================================================================*/
00020 
00021 #ifndef __ctkAbstractPluginFactory_h
00022 #define __ctkAbstractPluginFactory_h
00023 
00024 // Qt includes
00025 #include <QPluginLoader>
00026 #include <QFileInfo>
00027 
00028 // CTK includes
00029 #include "ctkAbstractFactory.h"
00030 
00031 //----------------------------------------------------------------------------
00032 template<typename BaseClassType>
00033 class ctkFactoryPluginItem : public ctkAbstractFactoryItem<BaseClassType>
00034 {
00035 public:
00036   explicit ctkFactoryPluginItem(const QString& key, const QString& path);
00037   virtual bool load();
00038   QString path()const;
00039   virtual QString loadErrorString()const;
00040 
00041 protected:
00042   virtual BaseClassType* instanciator();
00043 
00044 private:
00045   QPluginLoader    Loader;
00046   QString          Path;
00047 };
00048 
00049 //----------------------------------------------------------------------------
00050 template<typename BaseClassType, typename FactoryItemType = ctkFactoryPluginItem<BaseClassType> >
00051 class ctkAbstractPluginFactory : public ctkAbstractFactory<BaseClassType>
00052 {
00053 public:
00056   explicit ctkAbstractPluginFactory();
00057   virtual ~ctkAbstractPluginFactory();
00058 
00062   virtual QString fileNameToKey(const QString& fileName);
00063 
00068   virtual bool registerLibrary(const QFileInfo& file, QString& key);
00069 
00070 private:
00071   ctkAbstractPluginFactory(const ctkAbstractPluginFactory &);  
00072   void operator=(const ctkAbstractPluginFactory&); 
00073 };
00074 
00075 #include "ctkAbstractPluginFactory.tpp"
00076 
00077 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines