ctkAbstractQObjectFactory.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) 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.apache.org/licenses/LICENSE-2.0.txt
  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. /// \ingroup Core
  22. template<typename BaseClassType>
  23. class ctkAbstractQObjectFactory : public ctkAbstractObjectFactory<BaseClassType>
  24. {
  25. public:
  26. /// Constructor/Desctructor
  27. explicit ctkAbstractQObjectFactory();
  28. virtual ~ctkAbstractQObjectFactory();
  29. /// Create an instance of the object identified by \a itemKey
  30. virtual BaseClassType * instantiate(const QString& itemKey);
  31. /// Uninstanciate the object identified by \a itemKey
  32. virtual void uninstantiate(const QString& itemKey);
  33. /// \brief Return a name allowing to uniquely identify the QObject
  34. /// By default, it return \a objectName obtained using staticMetaObject.className()
  35. virtual QString objectNameToKey(const QString& objectName);
  36. /// \brief Register an object in the factory
  37. /// The parameter \a key passed by reference will be updated with the
  38. /// associated object name obtained using ::objectNameToKey()
  39. template<typename ClassType>
  40. bool registerQObject(QString& key);
  41. private:
  42. ctkAbstractQObjectFactory(const ctkAbstractQObjectFactory &); /// Not implemented
  43. void operator=(const ctkAbstractQObjectFactory&); /// Not implemented
  44. };
  45. #include "ctkAbstractQObjectFactory.tpp"
  46. #endif