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;
21 class ModuleBase_IWorkshop;
27 * A class for creation of widgets instances in for property panel using XML deskription of
30 class MODULEBASE_EXPORT ModuleBase_WidgetCreatorFactory
33 // Returns an singular instance of the class if it exists or create it
34 static std::shared_ptr<ModuleBase_WidgetCreatorFactory> get();
37 virtual ~ModuleBase_WidgetCreatorFactory();
39 /// The creator is added to the internal container to be used when the createWidgetByType is called
40 /// \param theCreator a new widget creator
41 void registerCreator(const WidgetCreatorPtr& theCreator);
43 /// Returns true if there is a creator, which can make a page by the type
44 /// \param theType a type
45 bool hasPageWidget(const std::string& theType);
47 /// Create page by its type
48 /// \param theType a type
49 /// \param theParent a parent widget
50 ModuleBase_PageBase* createPageByType(const std::string& theType,
52 Config_WidgetAPI* theWidgetApi);
54 /// Create widget by its type
55 /// \param theType a type
56 /// \param theParent a parent widget
57 ModuleBase_ModelWidget* createWidgetByType(const std::string& theType,
59 Config_WidgetAPI* theWidgetApi,
60 ModuleBase_IWorkshop* theWorkshop);
63 /// Constructor is hidden
64 ModuleBase_WidgetCreatorFactory();
66 /// Map of widget type in XML to creator
67 QMap<std::string, WidgetCreatorPtr> myCreators;
69 /// Map of widget page in XML to creator
70 QMap<std::string, WidgetCreatorPtr> myPageToCreator;
73 typedef std::shared_ptr<ModuleBase_WidgetCreatorFactory> WidgetCreatorFactoryPtr;
75 #endif /* MODULEBASE_WIDGETCREATORFACTORY_H_ */