Salome HOME
Use validators to set import file formats
[modules/shaper.git] / src / ExchangePlugin / ExchangePlugin_Plugin.cpp
1 /*
2  *
3  */
4
5 #include <ExchangePlugin_Plugin.h>
6 #include <ExchangePlugin_ImportFeature.h>
7 #include <ExchangePlugin_Validators.h>
8
9 #include <ModelAPI_Session.h>
10 #include <ModelAPI_Validator.h>
11
12 #include <boost/smart_ptr/shared_ptr.hpp>
13
14 using namespace std;
15
16 // the only created instance of this plugin
17 static ExchangePlugin_Plugin* MY_EXCHANGE_INSTANCE = new ExchangePlugin_Plugin();
18
19 ExchangePlugin_Plugin::ExchangePlugin_Plugin()
20 {
21   // register this plugin
22   SessionPtr aSession = ModelAPI_Session::get();
23   aSession->registerPlugin(this);
24   ModelAPI_ValidatorsFactory* aFactory = aSession->validators();
25   aFactory->registerValidator("ExchangePlugin_ImportFormat",
26                               new ExchangePlugin_ImportFormatValidator);
27 }
28
29 FeaturePtr ExchangePlugin_Plugin::createFeature(string theFeatureID)
30 {
31   if (theFeatureID == ExchangePlugin_ImportFeature::ID()) {
32     return FeaturePtr(new ExchangePlugin_ImportFeature);
33   }
34   // feature of such kind is not found
35   return FeaturePtr();
36 }