]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Migration to Boost shared_ptr and first python launch-tests
authormpv <mikhail.ponikarov@opencascade.com>
Wed, 26 Mar 2014 12:21:06 +0000 (16:21 +0400)
committermpv <mikhail.ponikarov@opencascade.com>
Wed, 26 Mar 2014 12:21:06 +0000 (16:21 +0400)
23 files changed:
CMakeCommon/Common.cmake
CMakeCommon/FindBoost.cmake [new file with mode: 0644]
CMakeLists.txt
CMakeLists.txt.orig [new file with mode: 0644]
buildNewGEOM.bat
env.bat
src/Config/CMakeLists.txt
src/Config/Config_XMLReader.cpp
src/Config/Config_XMLReader.cpp.orig [new file with mode: 0644]
src/Model/CMakeLists.txt
src/Model/Model_Document.cxx
src/Model/Model_Feature.cxx [new file with mode: 0644]
src/Model/Model_Feature.hxx [new file with mode: 0644]
src/Model/Model_PluginManager.cxx [new file with mode: 0644]
src/Model/Model_PluginManager.hxx [new file with mode: 0644]
src/ModelAPI/CMakeLists.txt
src/ModelAPI/ModelAPI.i
src/ModelAPI/ModelAPI_Application.hxx [deleted file]
src/ModelAPI/ModelAPI_Document.hxx
src/ModelAPI/ModelAPI_Feature.hxx [new file with mode: 0644]
src/ModelAPI/ModelAPI_Interface.hxx [new file with mode: 0644]
src/ModelAPI/ModelAPI_PluginManager.cxx [new file with mode: 0644]
src/ModelAPI/ModelAPI_PluginManager.hxx [new file with mode: 0644]

index b1e5384def66614edf0f35d4a4d4cf42762e697a..b9cf4596f7fd174c6965f05d709b5ca387f04e22 100644 (file)
@@ -8,5 +8,6 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
 set(CMAKE_INCLUDE_CURRENT_DIR ON)
 
 IF(WIN32)
-  ADD_DEFINITIONS(-DWIN32 -D_WINDOWS)
+  ## Specific definitions: EHsc to avoid exceptions-linkage unresolved symbols
+  ADD_DEFINITIONS(-DWIN32 -D_WINDOWS /EHsc)
 ENDIF(WIN32)
diff --git a/CMakeCommon/FindBoost.cmake b/CMakeCommon/FindBoost.cmake
new file mode 100644 (file)
index 0000000..e8d34a1
--- /dev/null
@@ -0,0 +1,30 @@
+# Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+#find_package(Boost)
+
+SET(BOOSTDIR $ENV{BOOST_ROOT_DIR})
+INCLUDE_DIRECTORIES(${BOOSTDIR}/include/boost-1_52)
+LINK_DIRECTORIES (${BOOSTDIR}/lib)
+
+#SET(BOOST_LIBRARIES ${BOOSTDIR}/lib/lib.lib)
+
+IF(WIN32)
+  SET(BOOST_DEFINITIONS -DBOOST_DISABLE_ASSERTS -DBOOST_ALL_DYN_LINK)
+ENDIF()
index bc48f8c8c011115478d9a376c15280b59bde26db..1a43d598de86e70dc5e37150eb3594cc47c86ac3 100644 (file)
@@ -8,8 +8,8 @@ INCLUDE(Common)
 INCLUDE(FindQt5)
 
 ADD_SUBDIRECTORY (src/Event)
+ADD_SUBDIRECTORY (src/Model)
+ADD_SUBDIRECTORY (src/ModelAPI)
 ADD_SUBDIRECTORY (src/Config)
-#ADD_SUBDIRECTORY (src/ModelAPI)
-#ADD_SUBDIRECTORY (src/Model)
 ADD_SUBDIRECTORY (src/PartSet)
 ADD_SUBDIRECTORY (src/XGUI)
diff --git a/CMakeLists.txt.orig b/CMakeLists.txt.orig
new file mode 100644 (file)
index 0000000..bec6bea
--- /dev/null
@@ -0,0 +1,20 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11)
+
+PROJECT (NewGEOM)
+
+SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeCommon" ${CMAKE_MODULE_PATH})
+
+INCLUDE(Common)
+INCLUDE(FindQt5)
+
+ADD_SUBDIRECTORY (src/Event)
+<<<<<<< Updated upstream
+ADD_SUBDIRECTORY (src/Config)
+#ADD_SUBDIRECTORY (src/ModelAPI)
+#ADD_SUBDIRECTORY (src/Model)
+ADD_SUBDIRECTORY (src/PartSet)
+=======
+ADD_SUBDIRECTORY (src/ModelAPI)
+ADD_SUBDIRECTORY (src/Model)
+>>>>>>> Stashed changes
+ADD_SUBDIRECTORY (src/XGUI)
index 51e29adda2e4d59f1ad9a6dacc02e7431b7846c6..a82fa4afe8c0704947e486cea36d10b450c49de3 100644 (file)
@@ -13,6 +13,6 @@ call %SRC_DIR%\env.bat
 mkdir %ROOT_DIR%\build
 cd %ROOT_DIR%\build
 
-cmake %SRC_DIR% -G "Visual Studio 10" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX:PATH=%ROOT_DIR%\install
+cmake %SRC_DIR% -G "Visual Studio 10" -DWIN32 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX:PATH=%ROOT_DIR%\install
 
 start "" %MSVC_EXE% NewGEOM.sln
diff --git a/env.bat b/env.bat
index ac6d75d7cf6966ff15147adb12b015327bdc3da7..b0d1e3dec52deb53e5ffb995c2cc46c648e61249 100644 (file)
--- a/env.bat
+++ b/env.bat
@@ -120,6 +120,12 @@ if "%QTDIR%" == "" (
 @SET PATH=%PDIR%\swig-2.0.9\bin;%PATH%
 @REM -------------------------
 
+@REM -------------------------
+@REM BOOST
+@SET BOOST_ROOT_DIR=%PDIR%\boost-1.52.0
+@SET PATH=%BOOST_ROOT_DIR%\lib;%PATH%
+@REM -------------------------
+
 @SET PATH=D:\NewGEOM\build-eclipse\bin;%PATH%
 
 rem -------- Visual Studio --------------------
index 63f5a96314ec78703cdae32ae400c98d483103a9..01be1d384d999eaf864dc321660be67057c8181c 100644 (file)
@@ -27,7 +27,7 @@ SET(XML_RESOURCES
 
 SET(PROJECT_LIBRARIES
     Event
-       ${LIBXML2_LIBRARIES}
+    ${LIBXML2_LIBRARIES}
 )
 
 SOURCE_GROUP ("Resource Files" FILES ${XML_RESOURCES})
index c235c3355922ad97b13d54e04a08a906bcc1a9d2..fd625fc3f0f070d23d6072449107440923127b77 100644 (file)
@@ -111,6 +111,8 @@ xmlNodePtr Config_XMLReader::findRoot()
  */
 void Config_XMLReader::readRecursively(xmlNodePtr theParent)
 {
+  static Event_ID aFeatureEvent = Event_Loop::EventByName("Feature");
+
   if(!theParent)
     return;
   xmlNodePtr aNode = theParent->xmlChildrenNode;
@@ -118,6 +120,7 @@ void Config_XMLReader::readRecursively(xmlNodePtr theParent)
     processNode(aNode);
     if(processChildren(aNode)) {
       readRecursively(aNode);
+      Config_FeatureMessage aMessage(aFeatureEvent, this);
     }
   }
 }
diff --git a/src/Config/Config_XMLReader.cpp.orig b/src/Config/Config_XMLReader.cpp.orig
new file mode 100644 (file)
index 0000000..a0ee3aa
--- /dev/null
@@ -0,0 +1,201 @@
+/*
+ * Config_XMLReader.cpp
+ *
+ *  Created on: Mar 14, 2014
+ *      Author: sbh
+ */
+
+#include <Config_XMLReader.h>
+
+#include <Event_Loop.hxx>
+#include <libxml\parser.h>
+#include <libxml\tree.h>
+
+#ifdef WIN32
+//For GetModuleFileNameW
+#include <windows.h>
+#endif
+
+#ifdef _DEBUG
+#include <iostream>
+#endif
+
+
+Config_XMLReader::Config_XMLReader(const std::string& theXmlFileName)
+{
+  std::string prefix;
+  //Get path to *.xml files (typically ./bin/../plugins/)
+#ifdef WIN32
+  HMODULE hModule = GetModuleHandleW(NULL);
+  WCHAR wchar_path[MAX_PATH];
+  GetModuleFileNameW(hModule, wchar_path, MAX_PATH);
+  char char_path[MAX_PATH];
+  char DefChar = ' ';
+  WideCharToMultiByte(CP_ACP, 0, wchar_path, -1, char_path, MAX_PATH, &DefChar, NULL);
+  prefix = std::string(char_path);
+  //chop "bin\XGUI.exe"
+  unsigned found = prefix.rfind("bin");
+  if(found != std::string::npos)
+    prefix.replace(found, prefix.length(), "plugins\\");
+#else
+  //TODO(sbh): Find full path to binary on linux
+  prefix = "../plugins/";
+#endif
+
+  m_DocumentPath = prefix + theXmlFileName;
+}
+
+
+Config_XMLReader::~Config_XMLReader()
+{
+}
+
+/*
+ * Read all nodes (recursively if processChildren() is true
+ * for a node). For each read node the processNode will be
+ * called.
+ */
+void Config_XMLReader::readAll()
+{
+  xmlNodePtr aRoot = findRoot();
+  readRecursively(aRoot);
+}
+
+/*
+ * Allows to customize reader's behavior for a node. Virtual.
+ * The default implementation does nothing. (In debug mode prints
+ * some info)
+ */
+void Config_XMLReader::processNode(xmlNodePtr aNode)
+{
+  #ifdef _DEBUG
+    std::cout << "Config_XMLReader::processNode: "
+              << aNode->name << " content: "
+              << aNode->content << std::endl;
+  #endif
+}
+
+/*
+ * Defines which nodes should be processed recursively. Virtual.
+ * The default implementation to read all nodes.
+ */
+bool Config_XMLReader::processChildren(xmlNodePtr aNode)
+{
+  return true;
+}
+
+xmlNodePtr Config_XMLReader::findRoot()
+{
+  xmlDocPtr aDoc;
+  aDoc = xmlParseFile(m_DocumentPath.c_str());
+  if(aDoc == NULL) {
+    #ifdef _DEBUG
+    std::cout << "Config_XMLReader::import: " << "Document " << m_DocumentPath
+              << " is not parsed successfully." << std::endl;
+    #endif
+    return NULL;
+  }
+  xmlNodePtr aRoot = xmlDocGetRootElement(aDoc);
+  #ifdef _DEBUG
+  if(aRoot == NULL) {
+    std::cout << "Config_XMLReader::import: " << "Error: empty document";
+  }
+  #endif
+  return aRoot;
+}
+
+/*
+ * Calls processNode() for each child (for some - recursively)
+ * of the given node.
+ * \sa ReadAll()
+ */
+void Config_XMLReader::readRecursively(xmlNodePtr theParent)
+{
+<<<<<<< Updated upstream
+  if(!theParent)
+    return;
+  xmlNodePtr aNode = theParent->xmlChildrenNode;
+  for(; aNode; aNode = aNode->next) {
+    processNode(aNode);
+    if(processChildren(aNode)) {
+      readRecursively(aNode);
+=======
+  static Event_ID aFeatureEvent = Event_Loop::EventByName("Feature");
+
+  xmlNodePtr aGroupNode = (static_cast<xmlNodePtr>(theRoot))->xmlChildrenNode;
+  Event_Loop* aEvLoop = Event_Loop::Loop();
+  if(!aEvLoop) {
+    #ifdef _DEBUG
+    std::cout << "Config_XMLReader::importWorkbench: "
+              << "No event loop registered" << std::endl;
+    #endif
+    return false;
+  }
+  for(; aGroupNode; aGroupNode = aGroupNode->next) { // searching for record
+    if(!IsNode(aGroupNode, "group"))
+      continue;
+    std::string aGroupName = getProperty(aGroupNode, FEATURE_GROUP_NAME);
+    if(aGroupName.empty())
+      continue;
+    xmlNodePtr aFtNode = aGroupNode->xmlChildrenNode;
+    for(; aFtNode; aFtNode = aFtNode->next) {
+      if(!IsNode(aFtNode, "feature"))
+        continue;
+      //Create feature...
+      Config_FeatureMessage aMessage(aFeatureEvent, this);
+      fillFeature(aFtNode, aMessage);
+      aMessage.m_group = aGroupName;
+      aEvLoop->Send(aMessage);
+>>>>>>> Stashed changes
+    }
+  }
+}
+
+/*
+ * void* -> xmlNodePtr
+ */
+xmlNodePtr Config_XMLReader::node(void* theNode)
+{
+  return static_cast<xmlNodePtr>(theNode);
+}
+
+/*
+ * Returns named property for a given node as std::string.
+ */
+std::string Config_XMLReader::getProperty(xmlNodePtr theNode, const char* name)
+{
+  std::string result = "";
+  char* aPropChars = (char*) xmlGetProp(theNode, BAD_CAST name);
+  if(!aPropChars || aPropChars[0] == 0)
+    return result;
+  result = std::string(aPropChars);
+  return result;
+}
+
+/*
+ * Returns true if theNode is XML node with a given name.
+ */
+bool Config_XMLReader::isNode(xmlNodePtr theNode, const char* theNodeName, ...)
+{
+  bool result = false;
+  const xmlChar* aName = theNode->name;
+  if(!aName || theNode->type != XML_ELEMENT_NODE)
+    return false;
+
+  if(!xmlStrcmp(aName, (const xmlChar *) theNodeName))
+    return true;
+
+  va_list args; // define argument list variable
+  va_start (args, theNodeName); // init list; point to last defined argument
+  while(true) {
+    char *anArg = va_arg (args, char *); // get next argument
+    if(anArg == NULL)
+      break;
+    if(!xmlStrcmp(aName, (const xmlChar *) anArg)) {
+      va_end (args); // cleanup the system stack
+      return true;
+    }
+  }
+  va_end (args); // cleanup the system stack
+  return false;
+}
index 44badeb68b19fb86661d83e0a1cf49b5da7b308b..c7d2585c21b7110a4bcfdc384b06a08debeb6212 100644 (file)
@@ -2,23 +2,28 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11)
 
 INCLUDE(Common)
 INCLUDE(FindCAS)
+INCLUDE(FindBoost)
 
 SET(PROJECT_HEADERS
     Model.hxx
-    Model_Application.hxx
     Model_Document.hxx
+    Model_PluginManager.hxx
+    Model_Feature.hxx
 )
 
 SET(PROJECT_SOURCES
-    Model_Application.cxx
     Model_Document.cxx
+    Model_PluginManager.cxx
+    Model_Feature.cxx
 )
 
-ADD_DEFINITIONS(-DMODEL_EXPORTS ${CAS_DEFINITIONS})
+ADD_DEFINITIONS(-DMODEL_EXPORTS ${CAS_DEFINITIONS} ${BOOST_DEFINITIONS})
 ADD_LIBRARY(Model SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
-TARGET_LINK_LIBRARIES(Model ${PROJECT_LIBRARIES} ${CAS_OCAF})
+TARGET_LINK_LIBRARIES(Model ${PROJECT_LIBRARIES} ${CAS_OCAF} ModelAPI Event Config)
 
 INCLUDE_DIRECTORIES(
   ../ModelAPI
+  ../Event
+  ../Config
   ${CAS_INCLUDE_DIRS}
 )
index 42ce6f766c582b930977df32dc40f34e3db56882..eec9755ab7d96475ceb4860c3a6aacd54ccca56f 100644 (file)
@@ -4,7 +4,6 @@
 // Copyright:   CEA 2011
 
 #include <Model_Document.hxx>
-#include <Model_Application.hxx>
 
 #include <TDataStd_Integer.hxx>
 
@@ -23,6 +22,7 @@ using namespace std;
 bool Model_Document::Load(const char* theFileName)
 {
   bool myIsError = Standard_False;
+  /*
   TCollection_ExtendedString aPath ((const Standard_CString)theFileName);
   PCDM_ReaderStatus aStatus = (PCDM_ReaderStatus) -1;
   try
@@ -56,11 +56,14 @@ bool Model_Document::Load(const char* theFileName)
     }
   }
   SetUndoLimit(UNDO_LIMIT);
+  */
   return !myIsError;
 }
 
 bool Model_Document::Save(const char* theFileName)
 {
+  bool myIsError = true;
+  /*
   TCollection_ExtendedString aPath ((const Standard_CString)theFileName);
   PCDM_StoreStatus aStatus;
   try {
@@ -72,7 +75,7 @@ bool Model_Document::Save(const char* theFileName)
     cout<<"OCAFApp_Engine:save Error: "<<aFail->GetMessageString()<<endl;
     return false;
   }
-  bool myIsError = aStatus != PCDM_SS_OK;
+  myIsError = aStatus != PCDM_SS_OK;
   if (myIsError)
   {
     switch (aStatus)
@@ -91,6 +94,7 @@ bool Model_Document::Save(const char* theFileName)
   }
   myTransactionsAfterSave = 0;
   Standard::Purge(); // Release free memory
+  */
   return !myIsError;
 }
 
diff --git a/src/Model/Model_Feature.cxx b/src/Model/Model_Feature.cxx
new file mode 100644 (file)
index 0000000..379beb4
--- /dev/null
@@ -0,0 +1,16 @@
+// File:        Model_Feature.hxx
+// Created:     21 Mar 2014
+// Author:      Mikhail PONIKAROV
+
+#include <Model_Feature.hxx>
+
+using namespace std;
+
+Model_Feature::Model_Feature()
+{
+}
+
+string Model_Feature::GetKind()
+{
+  return "Point";
+}
diff --git a/src/Model/Model_Feature.hxx b/src/Model/Model_Feature.hxx
new file mode 100644 (file)
index 0000000..fa632f1
--- /dev/null
@@ -0,0 +1,27 @@
+// File:        Model_Feature.hxx
+// Created:     21 Mar 2014
+// Author:      Mikhail PONIKAROV
+
+#ifndef Model_Feature_HeaderFile
+#define Model_Feature_HeaderFile
+
+#include "Model.hxx"
+#include <ModelAPI_Feature.hxx>
+
+/**\class Model_Feature
+ * \ingroup DataModel
+ * \brief General object of the application that allows
+ * to get/set attributes from the document and compute result of an operation.
+ */
+
+class Model_Feature: public ModelAPI_Feature
+{
+  Model_Feature();
+
+  friend class Model_PluginManager;
+public:
+  /// Returns the kind of a feature (like "Point")
+  virtual std::string GetKind();
+};
+
+#endif
diff --git a/src/Model/Model_PluginManager.cxx b/src/Model/Model_PluginManager.cxx
new file mode 100644 (file)
index 0000000..bf7a06f
--- /dev/null
@@ -0,0 +1,36 @@
+// File:        Model_PluginManager.cxx
+// Created:     20 Mar 2014
+// Author:      Mikhail PONIKAROV
+
+#include <Model_PluginManager.hxx>
+#include <ModelAPI_Feature.hxx>
+#include <Model_Feature.hxx>
+#include <Event_Loop.hxx>
+#include <Config_Message.h>
+
+using namespace std;
+
+boost::shared_ptr<ModelAPI_Feature> Model_PluginManager::CreateFeature(string theFeatureID)
+{
+  return boost::shared_ptr<ModelAPI_Feature>(new Model_Feature());
+}
+
+Model_PluginManager::Model_PluginManager()
+{
+  static Event_ID aFeatureEvent = Event_Loop::EventByName("Feature");
+
+  static Model_PluginManager* myImpl = new Model_PluginManager();
+  ModelAPI_PluginManager::SetPluginManager(boost::shared_ptr<ModelAPI_PluginManager>(myImpl));
+  // register the configuration reading listener
+  Event_Loop* aLoop = Event_Loop::Loop();
+  aLoop->RegisterListener(myImpl, aFeatureEvent);
+}
+
+void Model_PluginManager::ProcessEvent(const Event_Message* theMessage)
+{
+  const Config_FeatureMessage* aMsg =
+    dynamic_cast<const Config_FeatureMessage*>( theMessage );
+  if(aMsg) {
+    // proccess the plugin info, load plugin
+  }
+}
diff --git a/src/Model/Model_PluginManager.hxx b/src/Model/Model_PluginManager.hxx
new file mode 100644 (file)
index 0000000..584eb63
--- /dev/null
@@ -0,0 +1,33 @@
+// File:        Model_PluginManager.hxx
+// Created:     20 Mar 2014
+// Author:      Mikhail PONIKAROV
+
+#ifndef Model_PluginManager_HeaderFile
+#define Model_PluginManager_HeaderFile
+
+#include "Model.hxx"
+#include <ModelAPI_PluginManager.hxx>
+#include <Event_Listener.hxx>
+
+/**\class Model_PluginManager
+ * \ingroup DataModel
+ * \brief Object that knows (from the initial XML file) which
+ * plugin contains which feature, loads and stores reference to loaded plugins by
+ * the feature functionality request.
+ */
+
+class MODEL_EXPORT Model_PluginManager : public ModelAPI_PluginManager, public Event_Listener
+{
+public:
+  /// Creates the feature object using plugins functionality
+  virtual boost::shared_ptr<ModelAPI_Feature> CreateFeature(std::string theFeatureID);
+
+  /// Processes the configuration file reading
+  virtual void ProcessEvent(const Event_Message* theMessage);
+
+private:
+  /// Is called only once, on startup of the application
+  Model_PluginManager();
+};
+
+#endif
index dc9e4096553e79c5b0ee3edd2ede4494d7decac9..e45b8eece057382bfc528fafde42a643ba2e3b73 100644 (file)
@@ -4,14 +4,21 @@ INCLUDE(Common)
 FIND_PACKAGE(SWIG REQUIRED)
 INCLUDE(${SWIG_USE_FILE})
 INCLUDE(FindPython)
+INCLUDE(FindBoost)
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
 
 SET(PROJECT_HEADERS
     ModelAPI.hxx
-    ModelAPI_Application.hxx
+    ModelAPI_Interface.hxx
+    ModelAPI_PluginManager.hxx
+    ModelAPI_Feature.hxx
     ModelAPI_Document.hxx
 )
 
+SET(PROJECT_SOURCES
+    ModelAPI_PluginManager.cxx
+)
+
 ADD_DEFINITIONS(-DMODELAPI_EXPORTS)
 ADD_LIBRARY(ModelAPI SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
 SET_TARGET_PROPERTIES(ModelAPI PROPERTIES LINKER_LANGUAGE CXX)
@@ -20,9 +27,10 @@ SET_TARGET_PROPERTIES(ModelAPI PROPERTIES LINKER_LANGUAGE CXX)
 SET(CMAKE_SWIG_FLAGS "")
 
 SET_SOURCE_FILES_PROPERTIES(ModelAPI.i PROPERTIES CPLUSPLUS ON)
-SET_SOURCE_FILES_PROPERTIES(ModelAPI.i PROPERTIES SWIG_FLAGS "-includeall")
+# "-includeall" is not needed: it starts to follow the standard inludes (like "string") without success
+# SET_SOURCE_FILES_PROPERTIES(ModelAPI.i PROPERTIES SWIG_FLAGS)
 SET_SOURCE_FILES_PROPERTIES(ModelAPI.i PROPERTIES SWIG_DEFINITIONS "-shadow")
-#SET_SOURCE_FILES_PROPERTIES(ModelAPIPYTHON_wrap.cxx PROPERTIES COMPILE_FLAGS "-DHAVE_CONFIG_H")
+#SET_SOURCE_FILES_PROPERTIES(ModelAPIPYTHON_wrap.cxx PROPERTIES COMPILE_FLAGS "-D_WIN32")
 
 SET(SWIG_SCRIPTS
   ${CMAKE_CURRENT_BINARY_DIR}/ModelAPI.py
index ffc072a2f7de7259f89ef5a762fbcc9b9e538190..1f63f6c29cdb511eafe30fcdc660fded085a8db2 100644 (file)
@@ -2,8 +2,24 @@
 %module ModelAPI
 %{
   #include "ModelAPI.hxx"
-  #include "ModelAPI_Application.hxx"
   #include "ModelAPI_Document.hxx"
+  #include "ModelAPI_PluginManager.hxx"
+  #include "ModelAPI_Feature.hxx"
 %}
-%include "ModelAPI_Application.hxx"
+
+// to avoid error on this
+#define MODELAPI_EXPORT
+
+// standard definitions
+%include "typemaps.i"
+%include "std_string.i"
+
+// boost pointers
+%include <boost_shared_ptr.i>
+%shared_ptr(ModelAPI_PluginManager)
+%shared_ptr(ModelAPI_Feature)
+
+// all supported interfaces
 %include "ModelAPI_Document.hxx"
+%include "ModelAPI_PluginManager.hxx"
+%include "ModelAPI_Feature.hxx"
diff --git a/src/ModelAPI/ModelAPI_Application.hxx b/src/ModelAPI/ModelAPI_Application.hxx
deleted file mode 100644 (file)
index 284e5a1..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-// File:        Model_Application.hxx
-// Created:     28 Dec 2011
-// Author:      Mikhail PONIKAROV
-// Copyright:   CEA 2011
-
-#ifndef ModelAPI_Application_HeaderFile
-#define ModelAPI_Application_HeaderFile
-
-#include "ModelAPI.hxx"
-class ModelAPI_Document;
-
-/**\class Model_Application
- * \ingroup DataModel
- * \brief Realization of Open CASCADE application abstraction. Class for internal use only.
- * Application supports the formats and document management. It is uses OCAF-lke
- * architecture and just implements specific features of the module.
- */
-class ModelAPI_Application
-{
-public: // useful methods inside of the module
-  //! Retuns the application: one per process    
-  MODELAPI_EXPORT virtual ModelAPI_Application GetApplication() = 0;
-
-  MODELAPI_EXPORT virtual ModelAPI_Document* GetMainDocument() = 0;
-};
-
-#endif
index 02c537df1a28596047f6b85e96affb72f6fa0865..cc8aa70dfe65c852617b29f41eda0dc91e78dd05 100644 (file)
@@ -49,11 +49,14 @@ public:
   //! Returns True if there are available Undos
   MODELAPI_EXPORT virtual bool CanUndo() = 0;
   //! Undoes last operation
-  MODELAPI_EXPORT virtual void Undo();
+  MODELAPI_EXPORT virtual void Undo() = 0;
   //! Returns True if there are available Redos
   MODELAPI_EXPORT virtual bool CanRedo() = 0;
   //! Redoes last operation
   MODELAPI_EXPORT virtual  void Redo() = 0;
+
+  /// Only for SWIG wrapping it is here
+  MODELAPI_EXPORT ModelAPI_Document() {};
 };
 
 #endif
diff --git a/src/ModelAPI/ModelAPI_Feature.hxx b/src/ModelAPI/ModelAPI_Feature.hxx
new file mode 100644 (file)
index 0000000..ea84802
--- /dev/null
@@ -0,0 +1,30 @@
+// File:        ModelAPI_Feature.hxx
+// Created:     21 Mar 2014
+// Author:      Mikhail PONIKAROV
+
+#ifndef ModelAPI_Feature_HeaderFile
+#define ModelAPI_Feature_HeaderFile
+
+#include "ModelAPI.hxx"
+#include <string>
+
+class ModelAPI_Feature;
+
+/**\class ModelAPI_Feature
+ * \ingroup DataModel
+ * \brief General object of the application that allows
+ * to get/set attributes from the document and compute result of an operation.
+ */
+
+class MODELAPI_EXPORT ModelAPI_Feature
+{
+public:
+  /// Returns the kind of a feature (like "Point")
+  virtual std::string GetKind() = 0;
+
+  /// Use plugin manager for features creation: this method is 
+  /// defined here only for SWIG-wrapping
+  ModelAPI_Feature() {}
+};
+
+#endif
diff --git a/src/ModelAPI/ModelAPI_Interface.hxx b/src/ModelAPI/ModelAPI_Interface.hxx
new file mode 100644 (file)
index 0000000..377b7ea
--- /dev/null
@@ -0,0 +1,38 @@
+// File:        ModelAPI_Interface.hxx
+// Created:     20 Mar 2014
+// Author:      Mikhail PONIKAROV
+
+#ifndef ModelAPI_Interface_HeaderFile
+#define ModelAPI_Interface_HeaderFile
+
+#include <ModelAPI.hxx>
+
+/**\class ModelAPI_Interface
+ * \ingroup DataModel
+ * \brief General base class for all interfaces in this package
+ */
+
+class MODELAPI_EXPORT ModelAPI_Interface
+{
+  void* myImpl; ///< pointer to the internal implementation object
+
+public:
+  /// None - constructor
+  virtual ModelAPI_Interface() {myImpl = 0;}
+
+  /// Constructor by the implementation pointer (used for internal needs)
+  virtual ModelAPI_Interface(void* theImpl) {myImpl = theImpl;}
+
+  /// Copy-constructor
+  virtual ModelAPI_Interface(ModelAPI_Interface& theOrig) 
+  {myImpl = theOrig.theImpl; Duplicate();}
+
+  virtual ModelAPI_Interface& operator=(ModelAPI_Interface& const theOrig)
+  {myImpl = theOrig.theImpl; Duplicate(); return *this;}
+
+  /// Duplicates the objet pointed by myImpl (loosing the old one)
+  virtual void Duplicate() = 0;
+
+};
+
+#endif
diff --git a/src/ModelAPI/ModelAPI_PluginManager.cxx b/src/ModelAPI/ModelAPI_PluginManager.cxx
new file mode 100644 (file)
index 0000000..889b6e7
--- /dev/null
@@ -0,0 +1,26 @@
+// File:        ModelAPI_PluginManager.hxx
+// Created:     20 Mar 2014
+// Author:      Mikhail PONIKAROV
+
+#include <ModelAPI_PluginManager.hxx>
+// to avoid unresolved ModelAPI_Document()
+#include <ModelAPI_Document.hxx>
+// to avoid unresolved ModelAPI_Feature()
+#include <ModelAPI_Feature.hxx>
+
+/// Manager that will be initialized from Model package, one per application
+boost::shared_ptr<ModelAPI_PluginManager> MY_MANAGER;
+
+ModelAPI_PluginManager::ModelAPI_PluginManager() 
+{}
+
+boost::shared_ptr<ModelAPI_PluginManager> ModelAPI_PluginManager::Get()
+{
+  return MY_MANAGER;
+}
+
+void ModelAPI_PluginManager::SetPluginManager(
+  boost::shared_ptr<ModelAPI_PluginManager> theManager)
+{
+  MY_MANAGER = theManager;
+}
diff --git a/src/ModelAPI/ModelAPI_PluginManager.hxx b/src/ModelAPI/ModelAPI_PluginManager.hxx
new file mode 100644 (file)
index 0000000..1d6a2e2
--- /dev/null
@@ -0,0 +1,37 @@
+// File:        ModelAPI_PluginManager.hxx
+// Created:     20 Mar 2014
+// Author:      Mikhail PONIKAROV
+
+#ifndef ModelAPI_PluginManager_HeaderFile
+#define ModelAPI_PluginManager_HeaderFile
+
+#include "ModelAPI.hxx"
+#include <string>
+#include <boost/shared_ptr.hpp>
+
+class ModelAPI_Feature;
+
+/**\class ModelAPI_PluginManager
+ * \ingroup DataModel
+ * \brief Object that knows (from the initial XML file) which
+ * plugin contains which feature, loads and stores reference to loaded plugins by
+ * the feature functionality request.
+ */
+
+class MODELAPI_EXPORT ModelAPI_PluginManager
+{
+public:
+  /// Creates the feature object using plugins functionality
+  virtual boost::shared_ptr<ModelAPI_Feature> CreateFeature(std::string theFeatureID) = 0;
+
+  /// Returns the real implementation (the alone instance per application) of the plugin manager
+  static boost::shared_ptr<ModelAPI_PluginManager> Get();
+
+  /// Is needed for python wrapping by swig, call Get to get an instance
+  ModelAPI_PluginManager();
+
+protected:
+  static void SetPluginManager(boost::shared_ptr<ModelAPI_PluginManager> theManager);
+};
+
+#endif