1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ModuleBase_WidgetCreatorFactory.cpp
4 // Created: 03 Dec 2015
5 // Author: Natalia ERMOLAEVA
7 #ifndef MODULEBASE_WIDGETCREATORFACTORY_H_
8 #define MODULEBASE_WIDGETCREATORFACTORY_H_
10 #include <ModuleBase.h>
17 #include <ModuleBase_IWidgetCreator.h>
19 class ModuleBase_ModelWidget;
20 class ModuleBase_PageBase;
26 * A class for creation of widgets instances in for property panel using XML deskription of
29 class MODULEBASE_EXPORT ModuleBase_WidgetCreatorFactory
32 // Returns an singular instance of the class if it exists or create it
33 static std::shared_ptr<ModuleBase_WidgetCreatorFactory> get();
36 virtual ~ModuleBase_WidgetCreatorFactory();
38 /// The creator is added to the internal container to be used when the createWidgetByType is called
39 /// \param theCreator a new widget creator
40 void registerCreator(const WidgetCreatorPtr& theCreator);
42 /// Returns true if there is a creator, which can make a page by the type
43 /// \param theType a type
44 bool hasPageWidget(const std::string& theType);
46 /// Create page by its type
47 /// \param theType a type
48 /// \param theParent a parent widget
49 ModuleBase_PageBase* createPageByType(const std::string& theType,
50 QWidget* theParent = NULL);
52 /// Create widget by its type
53 /// \param theType a type
54 /// \param theParent a parent widget
55 ModuleBase_ModelWidget* createWidgetByType(const std::string& theType,
56 QWidget* theParent = NULL);
59 /// Constructor is hidden
60 ModuleBase_WidgetCreatorFactory();
62 /// Map of widget type in XML to creator
63 QMap<std::string, WidgetCreatorPtr> myCreators;
65 /// Map of widget page in XML to creator
66 QMap<std::string, WidgetCreatorPtr> myPageToCreator;
69 typedef std::shared_ptr<ModuleBase_WidgetCreatorFactory> WidgetCreatorFactoryPtr;
71 #endif /* MODULEBASE_WIDGETCREATORFACTORY_H_ */