Salome HOME
975ca1e3a32eff654ca3bd9cf30239727832cb9e
[modules/shaper.git] / src / ParametersPlugin / ParametersPlugin_Plugin.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 #include <pyconfig.h>
4
5 #include <ParametersPlugin_Plugin.h>
6 #include <ParametersPlugin_Parameter.h>
7 #include <ParametersPlugin_ParametersMgr.h>
8 #include <ParametersPlugin_Validators.h>
9 #include <ParametersPlugin_WidgetCreator.h>
10
11 #include <ModuleBase_WidgetCreatorFactory.h>
12
13 #include <ModelAPI_Session.h>
14 #include <ModelAPI_Validator.h>
15
16 #include <memory>
17
18 // the only created instance of this plugin
19 static ParametersPlugin_Plugin* MY_PARAMETERSPLUGIN_INSTANCE = new ParametersPlugin_Plugin();
20
21 ParametersPlugin_Plugin::ParametersPlugin_Plugin()
22 {
23   // register this plugin
24   WidgetCreatorFactoryPtr aWidgetCreatorFactory = ModuleBase_WidgetCreatorFactory::get();
25   aWidgetCreatorFactory->registerCreator(
26    std::shared_ptr<ParametersPlugin_WidgetCreator>(new ParametersPlugin_WidgetCreator()));
27
28   SessionPtr aSession = ModelAPI_Session::get();
29   aSession->registerPlugin(this);
30
31   ModelAPI_ValidatorsFactory* aFactory = aSession->validators();
32   aFactory->registerValidator("Parameters_VariableValidator",
33                               new ParametersPlugin_VariableValidator);
34   aFactory->registerValidator("Parameters_ExpressionValidator",
35                               new ParametersPlugin_ExpressionValidator);
36
37   myEvalListener = std::shared_ptr<ParametersPlugin_EvalListener>(new ParametersPlugin_EvalListener());
38 }
39
40 FeaturePtr ParametersPlugin_Plugin::createFeature(std::string theFeatureID)
41 {
42   // TODO: register some features
43   if (theFeatureID == ParametersPlugin_Parameter::ID()) {
44     return FeaturePtr(new ParametersPlugin_Parameter);
45   }
46   if (theFeatureID == ParametersPlugin_ParametersMgr::ID()) {
47     return FeaturePtr(new ParametersPlugin_ParametersMgr);
48   }
49   return FeaturePtr();
50 }
51