ctkAbstractQObjectFactory.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) 2010 Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.commontk.org/LICENSE
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. #ifndef __ctkAbstractQObjectFactory_h
  15. #define __ctkAbstractQObjectFactory_h
  16. // Qt includes
  17. #include <QDebug>
  18. // CTK includes
  19. #include "ctkAbstractObjectFactory.h"
  20. //----------------------------------------------------------------------------
  21. template<typename BaseClassType>
  22. class ctkAbstractQObjectFactory : public ctkAbstractObjectFactory<BaseClassType>
  23. {
  24. public:
  25. /// Constructor/Desctructor
  26. explicit ctkAbstractQObjectFactory();
  27. virtual ~ctkAbstractQObjectFactory();
  28. /// Create an instance of the object identified by \a itemKey
  29. virtual BaseClassType * instantiate(const QString& itemKey);
  30. /// Uninstanciate the object identified by \a itemKey
  31. virtual void uninstantiate(const QString& itemKey);
  32. /// \brief Return a name allowing to uniquely identify the QObject
  33. /// By default, it return \a objectName obtained using staticMetaObject.className()
  34. virtual QString objectNameToKey(const QString& objectName);
  35. /// \brief Register an object in the factory
  36. /// The parameter \a key passed by reference will be updated with the
  37. /// associated object name obtained using ::objectNameToKey()
  38. template<typename ClassType>
  39. bool registerQObject(QString& key);
  40. private:
  41. ctkAbstractQObjectFactory(const ctkAbstractQObjectFactory &); /// Not implemented
  42. void operator=(const ctkAbstractQObjectFactory&); /// Not implemented
  43. };
  44. #include "ctkAbstractQObjectFactory.tpp"
  45. #endif