From dde651a141f588d0812a037de907cb4533542076 Mon Sep 17 00:00:00 2001 From: rnv Date: Mon, 17 Feb 2014 13:44:10 +0400 Subject: [PATCH] Porting SimanIO library on WIN32 platform. --- CMakeLists.txt | 28 ++++++++++++++ CMakeModules/FindWSO2.cmake | 10 +++++ INSTALL | 26 +++++++------ src/CMakeLists.txt | 11 ++++-- src/SimanIO.hxx | 33 ++++++++++++++++ src/SimanIO_Activity.hxx | 6 ++- src/SimanIO_Configuration.cxx | 1 + src/SimanIO_Configuration.hxx | 6 ++- src/SimanIO_Document.hxx | 6 ++- src/SimanIO_Link.cxx | 71 ++++++++++++++++++++++++++++++----- src/SimanIO_Link.hxx | 4 +- 11 files changed, 171 insertions(+), 31 deletions(-) create mode 100644 src/SimanIO.hxx diff --git a/CMakeLists.txt b/CMakeLists.txt index 4fbd6d0..630e04f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/CMakeModules/FindWSO2.cmake b/CMakeModules/FindWSO2.cmake index 9ad5150..b3e8559 100644 --- a/CMakeModules/FindWSO2.cmake +++ b/CMakeModules/FindWSO2.cmake @@ -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 f3eb040..30dc89f 100644 --- 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 -d adb -u + $ siman_stabs_code_generator.sh -uri -d adb -u -The SIMAN stabs code generator script -(/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 (/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 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://:8080/siman". +the SIMAN server can be accesible on SALOME client side from your browser using URL: +"http://:8080/siman". Normally, this should display the SIMAN start page. SALOME session connected to SIMAN is automatically started from the browser; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 173f5df..d28e7ad 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 index 0000000..af5eca4 --- /dev/null +++ b/src/SimanIO.hxx @@ -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_ diff --git a/src/SimanIO_Activity.hxx b/src/SimanIO_Activity.hxx index 828da48..6f07976 100644 --- a/src/SimanIO_Activity.hxx +++ b/src/SimanIO_Activity.hxx @@ -20,6 +20,8 @@ #ifndef SIMANIO_ACTIVITY_H #define SIMANIO_ACTIVITY_H +#include "SimanIO.hxx" + #include "SimanIO_Document.hxx" #include @@ -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 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: diff --git a/src/SimanIO_Configuration.cxx b/src/SimanIO_Configuration.cxx index 2843627..c4e1260 100644 --- a/src/SimanIO_Configuration.cxx +++ b/src/SimanIO_Configuration.cxx @@ -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) diff --git a/src/SimanIO_Configuration.hxx b/src/SimanIO_Configuration.hxx index 3821d61..7331d9d 100644 --- a/src/SimanIO_Configuration.hxx +++ b/src/SimanIO_Configuration.hxx @@ -20,6 +20,8 @@ #ifndef SIMANIO_CONFIGURATION_H #define SIMANIO_CONFIGURATION_H +#include "SimanIO.hxx" + #include "SimanIO_Activity.hxx" #include @@ -29,7 +31,7 @@ * \brief Class for storage and store CFG file information. */ -class SimanIO_Configuration { +class SIMANIO_EXPORT SimanIO_Configuration { std::map 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::iterator myIter; // activities iterator std::map::iterator myEnd; // end if activities identifier public: diff --git a/src/SimanIO_Document.hxx b/src/SimanIO_Document.hxx index 1d0d8df..40be9d3 100644 --- a/src/SimanIO_Document.hxx +++ b/src/SimanIO_Document.hxx @@ -20,6 +20,8 @@ #ifndef SIMANIO_DOCUMENT_H #define SIMANIO_DOCUMENT_H +#include "SimanIO.hxx" + #include #include @@ -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 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: diff --git a/src/SimanIO_Link.cxx b/src/SimanIO_Link.cxx index 8987a93..cb74e2b 100644 --- a/src/SimanIO_Link.cxx +++ b/src/SimanIO_Link.cxx @@ -35,6 +35,10 @@ #include #include +#ifdef WIN32 + #include +#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 diff --git a/src/SimanIO_Link.hxx b/src/SimanIO_Link.hxx index 0e99439..d01d830 100644 --- a/src/SimanIO_Link.hxx +++ b/src/SimanIO_Link.hxx @@ -20,13 +20,15 @@ #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 -- 2.39.2