ctkAbstractPluginFactory.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. All rights reserved.
  5. Distributed under a BSD License. See LICENSE.txt file.
  6. This software is distributed "AS IS" WITHOUT ANY WARRANTY; without even
  7. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the above copyright notice for more information.
  9. =========================================================================*/
  10. #ifndef __ctkAbstractPluginFactory_h
  11. #define __ctkAbstractPluginFactory_h
  12. // Qt includes
  13. #include <QPluginLoader>
  14. #include <QFileInfo>
  15. // CTK includes
  16. #include "ctkAbstractFactory.h"
  17. //----------------------------------------------------------------------------
  18. template<typename BaseClassType>
  19. class ctkFactoryPluginItem : public ctkAbstractFactoryItem<BaseClassType>
  20. {
  21. public:
  22. explicit ctkFactoryPluginItem(const QString& key, const QString& path);
  23. virtual bool load();
  24. QString path()const;
  25. virtual QString loadErrorString()const;
  26. protected:
  27. virtual BaseClassType* instanciator();
  28. private:
  29. QPluginLoader Loader;
  30. QString Path;
  31. };
  32. //----------------------------------------------------------------------------
  33. template<typename BaseClassType, typename FactoryItemType = ctkFactoryPluginItem<BaseClassType> >
  34. class ctkAbstractPluginFactory : public ctkAbstractFactory<BaseClassType>
  35. {
  36. public:
  37. ///
  38. /// Constructor
  39. explicit ctkAbstractPluginFactory();
  40. virtual ~ctkAbstractPluginFactory();
  41. ///
  42. /// Register a plugin in the factory
  43. virtual bool registerLibrary(const QFileInfo& file, QString& key);
  44. private:
  45. ctkAbstractPluginFactory(const ctkAbstractPluginFactory &); /// Not implemented
  46. void operator=(const ctkAbstractPluginFactory&); /// Not implemented
  47. };
  48. #include "ctkAbstractPluginFactory.tpp"
  49. #endif