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