Salome HOME
Porting SimanIO library on WIN32 platform.
authorrnv <rnv@opencascade.com>
Mon, 17 Feb 2014 09:44:10 +0000 (13:44 +0400)
committerrnv <rnv@opencascade.com>
Mon, 17 Feb 2014 09:44:10 +0000 (13:44 +0400)
CMakeLists.txt
CMakeModules/FindWSO2.cmake
INSTALL
src/CMakeLists.txt
src/SimanIO.hxx [new file with mode: 0644]
src/SimanIO_Activity.hxx
src/SimanIO_Configuration.cxx
src/SimanIO_Configuration.hxx
src/SimanIO_Document.hxx
src/SimanIO_Link.cxx
src/SimanIO_Link.hxx

index 4fbd6d07e5b80424bcff1c146ccc70bde47bd99a..630e04ff7694cecd9d18c36cfe041bf84826ed37 100644 (file)
@@ -35,6 +35,34 @@ SET(${PROJECT_NAME_UC}_VERSION
 LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)
 INCLUDE(SimanIOMacros)
 
+# Win32 specific definitions to avoid problems with std collection and iterators
+IF(WIN32)
+  ## Windows specific:  
+  ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)  # To disable windows warnings for strcpy, fopen, ...
+  ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS)  # To disable windows warnings generated by checked iterators(e.g. std::copy, std::transform, ...)
+  # Disable iterator debugging on WINDOWS to avoid runtime error during checking iterators
+    # _SECURE_SCL 
+    #             If defined as 1, unsafe iterator use causes a runtime error. 
+    #             If defined as 0, checked iterators are disabled.
+    #             The default value for _SECURE_SCL is 1
+    # _SECURE_SCL_THROWS
+    #             If defined as 1, an out of range iterator use causes an exception at runtime.
+    #             If defined as 0, the program is terminated by calling invalid_parameter. 
+    #             The default value for _SECURE_SCL_THROWS is 0
+  
+  ADD_DEFINITIONS(-D_SECURE_SCL=0 -D_SECURE_SCL_THROWS=0)
+
+    # The symbol _HAS_ITERATOR_DEBUGGING can be used to turn off the iterator debugging feature in a debug build
+    #             If defined as 1, iterator debugging is enabled. 
+    #             If defined as 0, iterator debugging is disabled.
+    #             The default value for _HAS_ITERATOR_DEBUGGING is 1
+
+  IF(NOT CMAKE_BUILD_TYPE STREQUAL "RELEASE" AND NOT CMAKE_BUILD_TYPE STREQUAL "Release")
+    ADD_DEFINITIONS(-D_HAS_ITERATOR_DEBUGGING=0)
+  ENDIF(NOT CMAKE_BUILD_TYPE STREQUAL "RELEASE" AND NOT CMAKE_BUILD_TYPE STREQUAL "Release")
+ENDIF(WIN32)
+
+
 # User options
 # ============
 IF(WIN32 AND NOT CYGWIN)
index 9ad51509ff56e30b6ac31ef09417780d29816db7..b3e855964118f119f5f43f0f65a20d369d09a3d9 100644 (file)
@@ -51,8 +51,14 @@ FIND_LIBRARY(WSO2_LIBRARY_axutil            NAMES axutil)
 FIND_LIBRARY(WSO2_LIBRARY_guththila         NAMES guththila)
 FIND_LIBRARY(WSO2_LIBRARY_neethi            NAMES neethi)
 FIND_LIBRARY(WSO2_LIBRARY_axis2_parser      NAMES axis2_parser)
+
+IF(WIN32)
+  FIND_LIBRARY(WSO2_LIBRARY_axis2_axiom       NAMES axiom)
+ELSE()
 FIND_LIBRARY(WSO2_LIBRARY_axis2_axiom       NAMES axis2_axiom)
 FIND_LIBRARY(WSO2_LIBRARY_axis2_http_common NAMES axis2_http_common)
+ENDIF()
+
 FIND_LIBRARY(WSO2_LIBRARY_axis2_engine      NAMES axis2_engine)
 FIND_LIBRARY(WSO2_LIBRARY_wso2_wsf          NAMES wso2_wsf)
 
@@ -62,7 +68,11 @@ SET(WSO2_LIBRARIES ${WSO2_LIBRARIES} ${WSO2_LIBRARY_guththila})
 SET(WSO2_LIBRARIES ${WSO2_LIBRARIES} ${WSO2_LIBRARY_neethi})
 SET(WSO2_LIBRARIES ${WSO2_LIBRARIES} ${WSO2_LIBRARY_axis2_parser})
 SET(WSO2_LIBRARIES ${WSO2_LIBRARIES} ${WSO2_LIBRARY_axis2_axiom})
+
+IF(NOT WIN32)
 SET(WSO2_LIBRARIES ${WSO2_LIBRARIES} ${WSO2_LIBRARY_axis2_http_common})
+ENDIF()
+
 SET(WSO2_LIBRARIES ${WSO2_LIBRARIES} ${WSO2_LIBRARY_axis2_engine})     
 SET(WSO2_LIBRARIES ${WSO2_LIBRARIES} ${WSO2_LIBRARY_wso2_wsf})
 
diff --git a/INSTALL b/INSTALL
index f3eb0403e9179db8a49a02f8947af047b18f9a83..30dc89f348e8961a6262b45d78a91625bf1d6222 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -88,7 +88,8 @@ CMAKE_INSTALL_PREFIX variable (passed to cmake or ccmake):
 3. Generating Web Service Client Stubs
 --------------------------------------
 
-It is the optional action for current version.
+This paragraph describes a procedure of the web services client stubs generating
+Note: it is an optional action for the current version of SimanIO.
 
 SimanIO library sources include a set of web services client stubs generated
 by means of WSO2 Web Services Framework for C++.
@@ -100,13 +101,16 @@ SIMAN wsdl file.
 Use the following parameters to generate the Axis2/C client stub code with
 ADB (Axis Data Binding) support:
 
-    $ ./siman_stabs_code_generator.sh -uri <wsdl_location> -d adb -u
+    $ siman_stabs_code_generator.sh -uri <wsdl_location> -d adb -u
 
-The SIMAN stabs code generator script
-(<SIMANIO_SRC>/scripts/siman_stabs_code_generator.sh) generates the client stub
-files .h and .cpp from the given SIMAN wsdl file, path to which is specified
-via <wsdl_location> (<SIMANIO_SRC>/scripts/SimanSalomeService.wsdl) 
-and puts generated files to the src sub-directory of a source tree.
+The SIMAN stabs code generator script creates the client stub files .h and
+.cpp from the given SIMAN wsdl file, path to which is specified
+via the <wsdl_location> parameter; resulting files should be put to the 
+src sub-directory of a source tree.
+
+The siman_stabs_code_generator.sh script and wsdl template file
+SimanSalomeService.wsdl are located in the scripts sub-directory of a source
+tree.
 
 -------------------------------------------------
 4. Build SALOME KERNEL module with SIMAN support
@@ -210,14 +214,14 @@ procedure, you will need to use alternative way to set proper environment.
 5.6. Configuration of SIMAN web server and SIMAN database server
 
 Please find all necessary details concerning the configuration and running of
-SALOME SIMAN client and SIMAN Web server with SIMAN database server in 
-the SIMAN Administration Guide (SIMAN_AdminGuide_vx.y).
+SALOME SIMAN client and SIMAN Web server with SIMAN database in the SIMAN
+Administration Guide (SIMAN_AdminGuide_vX.Y).
 
 5.7. Basic working mode of SALOME with SIMAN server
 
 If installation and configuration of SIMAN have been performed successfully
-the SIMAN server can be accesible on SALOME client side from your browser using
-URL: "http://<server_name or server_IP>:8080/siman".
+the SIMAN server can be accesible on SALOME client side from your browser using URL:
+"http://<server_name or server_IP>:8080/siman".
 Normally, this should display the SIMAN start page.
 
 SALOME session connected to SIMAN is automatically started from the browser;
index 173f5dfc89879413259b8e35938a3f0e0f2b3831..d28e7ad38f4d54000013c0eee89f09cf6da1ecb1 100644 (file)
@@ -29,6 +29,7 @@ SET(SimanIO_HEADERS
   SimanIO_Configuration.hxx
   SimanIO_Document.hxx
   SimanIO_Link.hxx
+  SimanIO.hxx 
 )
 
 # [ generated sources ]
@@ -64,10 +65,14 @@ SET(SimanIO_SOURCES
 # [ target: library ]
 ADD_LIBRARY(SimanIO SHARED ${SimanIO_SOURCES})
 TARGET_LINK_LIBRARIES(SimanIO ${PLATFORM_LIBS} ${WSO2_LIBRARIES})
+SET_TARGET_PROPERTIES(SimanIO PROPERTIES COMPILE_DEFINITIONS "AXIS2_DECLARE_EXPORT")
+#SET_TARGET_PROPERTIES(SimanIO PROPERTIES COMPILE_DEFINITIONS "AXIS2_SVR_MULTI_THREADED")
 INSTALL(TARGETS SimanIO EXPORT ${PROJECT_NAME}Targets DESTINATION lib)
 INSTALL(FILES ${SimanIO_HEADERS} DESTINATION include)
 
 # [ target: test ]
-ADD_EXECUTABLE(TestCreateConfigFile TestCreateConfigFile.cpp)
-TARGET_LINK_LIBRARIES(TestCreateConfigFile SimanIO)
-INSTALL(TARGETS TestCreateConfigFile DESTINATION bin)
+#ADD_EXECUTABLE(TestCreateConfigFile TestCreateConfigFile.cpp)
+#TARGET_LINK_LIBRARIES(TestCreateConfigFile SimanIO)
+#SET_TARGET_PROPERTIES(SimanIO PROPERTIES COMPILE_DEFINITIONS "AXIS2_DECLARE_EXPORT")
+##SET_TARGET_PROPERTIES(SimanIO PROPERTIES COMPILE_DEFINITIONS "AXIS2_SVR_MULTI_THREADED")
+#INSTALL(TARGETS TestCreateConfigFile DESTINATION bin)
diff --git a/src/SimanIO.hxx b/src/SimanIO.hxx
new file mode 100644 (file)
index 0000000..af5eca4
--- /dev/null
@@ -0,0 +1,33 @@
+// Copyright (C) 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
+//
+
+#ifndef _SIMANIO_HXX_
+#define _SIMANIO_HXX_
+
+#ifdef WIN32
+# if defined SIMANIO_EXPORTS || defined SimanIO_EXPORTS
+#  define SIMANIO_EXPORT __declspec( dllexport )
+# else
+#  define SIMANIO_EXPORT __declspec( dllimport )
+# endif
+#else
+# define SIMANIO_EXPORT
+#endif
+
+#endif //_SIMANIO_HXX_
index 828da48ef8984926390bef9f0ebe51af03c697cc..6f079768a0e2eb559f37a12d8675ec250cf8444a 100644 (file)
@@ -20,6 +20,8 @@
 #ifndef SIMANIO_ACTIVITY_H
 #define SIMANIO_ACTIVITY_H
 
+#include "SimanIO.hxx"
+
 #include "SimanIO_Document.hxx"
 
 #include <string>
@@ -28,7 +30,7 @@
 /**
  * \brief Class for storage and store CFG file activity information.
  */
-class SimanIO_Activity {
+class SIMANIO_EXPORT SimanIO_Activity {
   std::string myName;   ///< name of the activity
   std::string myModule; ///< module of the activity
   typedef std::map<int, SimanIO_Document> ActivityDocuments;
@@ -88,7 +90,7 @@ public:
   SimanIO_Document& GetOrCreateDocument(const int theId);
 
   //! Iterator for activity documents browsing
-  class DocumentsIterator {
+  class SIMANIO_EXPORT DocumentsIterator {
     ActivityDocuments::iterator myIter; ///< iterator by the documents of the activity
     ActivityDocuments::const_iterator myEnd;  ///< end iteration indicator
     public:
index 2843627ac6095046b2a17ebc1224f91b98925cde..c4e1260cfcd1f22e1a4c023ecd267b4fab9c0dc6 100644 (file)
@@ -219,6 +219,7 @@ int SimanIO_Configuration::AddActivity(const SimanIO_Activity& theActivity, cons
     }
   }
   myActivities[anId] = theActivity;
+  return anId;
 }
 
 SimanIO_Activity& SimanIO_Configuration::GetOrCreateActivity(const int theId)
index 3821d61f27531c61efea4f773491b460b9db6de6..7331d9d2ff5895d272c8adc75b5003abf07435f7 100644 (file)
@@ -20,6 +20,8 @@
 #ifndef SIMANIO_CONFIGURATION_H
 #define SIMANIO_CONFIGURATION_H
 
+#include "SimanIO.hxx"
+
 #include "SimanIO_Activity.hxx"
 
 #include <fstream>
@@ -29,7 +31,7 @@
  * \brief Class for storage and store CFG file information.
  */
 
-class SimanIO_Configuration {
+class SIMANIO_EXPORT SimanIO_Configuration {
   std::map<int, SimanIO_Activity> myActivities; ///< map of Id of activity t othe activity instance
   
   // fileds that are used for file parsing
@@ -67,7 +69,7 @@ public:
   /**
    * Iterator for actifities.
    */
-  class ActivitiesIterator {
+  class SIMANIO_EXPORT ActivitiesIterator {
     std::map<int, SimanIO_Activity>::iterator myIter; // activities iterator
     std::map<int, SimanIO_Activity>::iterator myEnd;  // end if activities identifier
   public:
index 1d0d8df1169b3459ba35aa3393c7e87c2b6236da..40be9d3cffe0faa56e4766188f138122848e8e7b 100644 (file)
@@ -20,6 +20,8 @@
 #ifndef SIMANIO_DOCUMENT_H
 #define SIMANIO_DOCUMENT_H
 
+#include "SimanIO.hxx"
+
 #include <string>
 #include <list>
 
@@ -46,7 +48,7 @@ struct SimanIO_File {
 /**
  * \brief Class for storage and store CFG file document information.
  */
-class SimanIO_Document {
+class SIMANIO_EXPORT SimanIO_Document {
   std::string myName;   ///< name of the document
   typedef std::list<SimanIO_File> DocumentFiles;
   DocumentFiles myFiles; ///< files of the document
@@ -91,7 +93,7 @@ public:
   const SimanIO_File& File(const int theId) const;
 
   //! Iterator for activity documents browsing
-  class FilesIterator {
+  class SIMANIO_EXPORT FilesIterator {
     DocumentFiles::iterator myIter; ///< iterator by the file of the document
     DocumentFiles::const_iterator myEnd;  ///< end iteration indicator
     public:
index 8987a93bdad7651a59eab30409f9fd2bcc4b9e64..cb74e2b34e31cb9db85782f87e38f1bebce99f3e 100644 (file)
 #include <sstream>
 #include <algorithm>
 
+#ifdef WIN32
+  #include <stdlib.h>
+#endif
+
 using namespace org_splat_ws_server_service_salome;
 using namespace wso2wsf;
 
@@ -95,13 +99,20 @@ SimanIO_Configuration SimanIO_Link::RetrieveConf()
   //CreateConfigFile operation
   CreateConfigFile* aCreateConfigFileRequest = new CreateConfigFile();
   
-  aCreateConfigFileRequest->setArgs0(atoll(myStudy.c_str()));
-  aCreateConfigFileRequest->setArgs1(atoll(myScenario.c_str()));
-  aCreateConfigFileRequest->setArgs2(atoll(myUser.c_str()));
+#ifdef WIN32
+  aCreateConfigFileRequest->setArgs0(_atoi64(myStudy.c_str()));
+  aCreateConfigFileRequest->setArgs1(_atoi64(myScenario.c_str()));
+  aCreateConfigFileRequest->setArgs2(_atoi64(myUser.c_str()));
+#else
+  aCreateConfigFileRequest->setArgs0(std::atoll(myStudy.c_str()));
+  aCreateConfigFileRequest->setArgs1(std::atoll(myScenario.c_str()));
+  aCreateConfigFileRequest->setArgs2(std::atoll(myUser.c_str()));
+
+  //std::cout<<"StudyId = " << std::atoll(myStudy.c_str()) << "\n";
+  //std::cout<<"ScenarioId = " << std::atoll(myScenario.c_str()) << "\n";
+  //std::cout<<"UserId = " << std::atoll(myUser.c_str()) << "\n";
+#endif
   
-  //std::cout<<"StudyId = " << atoll(myStudy.c_str()) << "\n";
-  //std::cout<<"ScenarioId = " << atoll(myScenario.c_str()) << "\n";
-  //std::cout<<"UserId = " << atoll(myUser.c_str()) << "\n";
   
   CreateConfigFileResponse* aCreateConfigFileResponse = new CreateConfigFileResponse();
   aCreateConfigFileResponse = aStub->createConfigFile(aCreateConfigFileRequest);
@@ -120,6 +131,16 @@ SimanIO_Configuration SimanIO_Link::RetrieveConf()
   aGetFileResponse = aStub->getFile(aGetFileRequest);
   
   //Parse the response and get the filename
+#ifdef WIN32
+  char* aHome = getenv("HOME");
+  std::string aTmpDir(aHome);
+  std::string aClientFileDir = aTmpDir + "\\SimanSalome\\" + myStudy + "\\" + myScenario + "\\" + myUser + "\\";
+  //std::string aClientFileDir = aTmpDir + "/SimanSalome/" +  myUser + "/download/";
+  std::string aClientFilePath = aClientFileDir + aResponseFileName;
+  
+  //Create the directories
+  system(("if not exist aClientFileDir).c_str() mkdir " + aClientFileDir).c_str());
+#else
   std::string aTmpDir = "/tmp";
   std::string aClientFileDir = aTmpDir + "/SimanSalome/" + myStudy + "/" + myScenario + "/" + myUser + "/";
   //std::string aClientFileDir = aTmpDir + "/SimanSalome/" +  myUser + "/download/";
@@ -128,6 +149,7 @@ SimanIO_Configuration SimanIO_Link::RetrieveConf()
   //Create the directories
   system(("mkdir -p " + aClientFileDir).c_str());
   system(("chmod -Rf g+w " + aTmpDir + "/SimanSalome/").c_str());
+#endif
   
   //Download the siman-salome.conf file
   std::ofstream outputStream;
@@ -157,7 +179,11 @@ SimanIO_Configuration SimanIO_Link::RetrieveConf()
         std::string aSourceFileName = aFileName.substr(startUnderlineIndex);
         
         //std::cout << "aURL = " << aURL << "\n";
+       #ifdef WIN32
+       std::string aPathToVault = aResponseFilePath.substr(0, aResponseFilePath.find("download")) + "vault\\";
+       #else
         std::string aPathToVault = aResponseFilePath.substr(0, aResponseFilePath.find("download")) + "vault/";
+       #endif
         
         //only for test only for WIN
         //replace(aURL.begin(),aURL.end(),'/','\\');
@@ -236,9 +262,17 @@ void SimanIO_Link::StoreConf(/*const*/ SimanIO_Configuration& theConf)
   PutFileResponse* aPutFileResponse = new PutFileResponse();
   
   //Prepare salome-siman.conf file
+#ifdef WIN32
+  char* aHome = getenv("HOME");
+  std::string aTmpDir(aHome);
+  std::string aClientFileDir = aTmpDir + "\\SimanSalome\\" + myStudy + "\\" + myScenario + "\\" + myUser + "\\";
+  //std::string aClientFileDir = aTmpDir + "/SimanSalome/" +  myUser + "/download/";
+  
+#else
   std::string aTmpDir = "/tmp";
   std::string aClientFileDir = aTmpDir + "/SimanSalome/" + myStudy + "/" + myScenario + "/" + myUser + "/";
   //std::string aClientFileDir = aTmpDir + "/SimanSalome/" +  myUser + "/download/";
+#endif
   std::string aClientFilePath = aClientFileDir + "salome-siman.conf";
   std::ofstream aSalomeSimanFile;
   aSalomeSimanFile.open(aClientFilePath.c_str());
@@ -274,7 +308,12 @@ void SimanIO_Link::StoreConf(/*const*/ SimanIO_Configuration& theConf)
         //Set arguments
         aPutFileRequest->setArgs0(aRequestDH);
         aPutFileRequest->setArgs1(aFileName);
-        aPutFileRequest->setArgs2(atoll(myUser.c_str()));
+
+#ifdef WIN32
+        aPutFileRequest->setArgs2(_atoi64(myUser.c_str()));
+#else
+        aPutFileRequest->setArgs2(std::atoll(myUser.c_str()));
+#endif
         
         aPutFileResponse = aStub->putFile(aPutFileRequest);
         
@@ -311,7 +350,12 @@ void SimanIO_Link::StoreConf(/*const*/ SimanIO_Configuration& theConf)
   //Set arguments
   aPutFileRequest->setArgs0(aRequestDH);
   aPutFileRequest->setArgs1("salome-siman.conf");
-  aPutFileRequest->setArgs2(atoll(myUser.c_str()));
+
+#ifdef WIN32
+  aPutFileRequest->setArgs2(_atoi64(myUser.c_str()));
+#else
+  aPutFileRequest->setArgs2(std::atoll(myUser.c_str()));
+#endif
 
   aPutFileResponse = aStub->putFile(aPutFileRequest);
 
@@ -321,8 +365,15 @@ void SimanIO_Link::StoreConf(/*const*/ SimanIO_Configuration& theConf)
   CheckIn* aCheckInRequest = new CheckIn();
   CheckInResponse* aCheckInResponse = new CheckInResponse();
   aCheckInRequest->setArgs0(aPutFileResponse->get_return());
-  aCheckInRequest->setArgs1(atoll(myScenario.c_str()));
-  aCheckInRequest->setArgs2(atoll(myUser.c_str()));
+
+#ifdef WIN32
+  aCheckInRequest->setArgs1(_atoi64(myScenario.c_str()));
+  aCheckInRequest->setArgs2(_atoi64(myUser.c_str()));
+#else
+  aCheckInRequest->setArgs1(std::atoll(myScenario.c_str()));
+  aCheckInRequest->setArgs2(std::atoll(myUser.c_str()));
+#endif
+
   aCheckInResponse = aStub->checkIn(aCheckInRequest);
   
   //Delete the directories
index 0e99439657a5ecca736272a3a0418907e453dc14..d01d8302246a5d217bec3dd2edef16e9822912c3 100644 (file)
 #ifndef SIMANIO_LINK_H
 #define SIMANIO_LINK_H
 
+#include "SimanIO.hxx"
+
 #include "SimanIO_Configuration.hxx"
 
 /**
  * \brief Class for creation of connection with SIMAN database.
  */
 
-class SimanIO_Link {
+class SIMANIO_EXPORT SimanIO_Link {
   std::string myStudy;    ///< identifier of the study in the SIMAN
   std::string myScenario; ///< identifier of the scenario in the SIMAN
   std::string myUser;     ///< identifier of the user in the SIMAN