Salome HOME
Make circle with radius 0 not crashed: check validity before execution
[modules/shaper.git] / src / ExchangePlugin / ExchangePlugin_ImportFeature.h
1 /*
2  * ExchangePlugin_ImportFeature.h
3  *
4  *  Created on: Aug 28, 2014
5  *      Author: sbh
6  */
7
8 #ifndef EXCHANGEPLUGIN_IMPORTFEATURE_H_
9 #define EXCHANGEPLUGIN_IMPORTFEATURE_H_
10
11 #include <ExchangePlugin.h>
12 #include <ModelAPI_Feature.h>
13
14 #include <map>
15
16 #ifdef WIN32
17 #include <windows.h>
18 #define LibHandle HMODULE
19 #define LoadLib( name ) LoadLibrary( name )
20 #define GetProc GetProcAddress
21 #define UnLoadLib( handle ) FreeLibrary( handle );
22 #else
23 #include <dlfcn.h>
24 #define LibHandle void*
25 #define LoadLib( name ) dlopen( name, RTLD_LAZY | RTLD_GLOBAL)
26 #define GetProc dlsym
27 #define UnLoadLib( handle ) dlclose( handle );
28 #endif
29
30 class ExchangePlugin_ImportFeature : public ModelAPI_Feature
31 {
32  public:
33   /// Extrusion kind
34   inline static const std::string& ID()
35   {
36     static const std::string MY_IMPORT_ID("Import");
37     return MY_IMPORT_ID;
38   }
39   /// attribute name of referenced face
40   inline static const std::string& FILE_PATH_ID()
41   {
42     static const std::string MY_FILE_PATH_ID("import_file_selector");
43     return MY_FILE_PATH_ID;
44   }
45
46   EXCHANGEPLUGIN_EXPORT ExchangePlugin_ImportFeature();
47   EXCHANGEPLUGIN_EXPORT virtual ~ExchangePlugin_ImportFeature();
48
49   /// Returns the unique kind of a feature
50   EXCHANGEPLUGIN_EXPORT virtual const std::string& getKind();
51
52   /// Request for initialization of data model of the feature: adding all attributes
53   EXCHANGEPLUGIN_EXPORT virtual void initAttributes();
54
55   /// Computes or recomputes the results
56   EXCHANGEPLUGIN_EXPORT virtual void execute();
57
58   EXCHANGEPLUGIN_EXPORT virtual bool isInHistory()
59   {
60     return false;
61   }
62
63  protected:
64   EXCHANGEPLUGIN_EXPORT bool importFile(const std::string& theFileName);
65   EXCHANGEPLUGIN_EXPORT LibHandle loadImportPlugin(const std::string& theFormatName);
66   
67 };
68
69 #endif /* IMPORT_IMPORTFEATURE_H_ */