From 289da2cdfb505da7d77477921f443656d6111ff6 Mon Sep 17 00:00:00 2001 From: Nils Menager Date: Tue, 31 Mar 2015 08:20:36 +0000 Subject: [PATCH] Added necessary ifdefs for ModelicaSimulationError on RT targets (cpp runtime) git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@25329 f25d12d1-65f4-0310-ae8a-bbce733d8d8e --- .../cpp/Core/Utils/Modelica/CMakeLists.txt | 3 +- .../Core/Utils/Modelica/FactoryExport.h | 8 +++ .../Utils/Modelica/ModelicaSimulationError.h | 52 ++++++++++--------- 3 files changed, 37 insertions(+), 26 deletions(-) create mode 100644 SimulationRuntime/cpp/Include/Core/Utils/Modelica/FactoryExport.h diff --git a/SimulationRuntime/cpp/Core/Utils/Modelica/CMakeLists.txt b/SimulationRuntime/cpp/Core/Utils/Modelica/CMakeLists.txt index f464dc5b5b4..75852f678d8 100644 --- a/SimulationRuntime/cpp/Core/Utils/Modelica/CMakeLists.txt +++ b/SimulationRuntime/cpp/Core/Utils/Modelica/CMakeLists.txt @@ -15,5 +15,4 @@ endif(UNIX) target_link_libraries (${ModelicaUtilitiesName} ${Boost_LIBRARIES}) install (TARGETS ${ModelicaUtilitiesName} DESTINATION lib/omc/${LIBINSTALLEXT}) -install (FILES ${CMAKE_SOURCE_DIR}/Include/Core/Utils/Modelica/ModelicaUtilities.h ${CMAKE_SOURCE_DIR}/Include/Core/Utils/Modelica/ModelicaSimulationError.h DESTINATION include/omc/cpp/Core/Utils/Modelica) - +install (FILES ${CMAKE_SOURCE_DIR}/Include/Core/Utils/Modelica/ModelicaUtilities.h ${CMAKE_SOURCE_DIR}/Include/Core/Utils/Modelica/FactoryExport.h ${CMAKE_SOURCE_DIR}/Include/Core/Utils/Modelica/ModelicaSimulationError.h DESTINATION include/omc/cpp/Core/Utils/Modelica) \ No newline at end of file diff --git a/SimulationRuntime/cpp/Include/Core/Utils/Modelica/FactoryExport.h b/SimulationRuntime/cpp/Include/Core/Utils/Modelica/FactoryExport.h new file mode 100644 index 00000000000..3fc5b6cdefb --- /dev/null +++ b/SimulationRuntime/cpp/Include/Core/Utils/Modelica/FactoryExport.h @@ -0,0 +1,8 @@ +#pragma once + +#if defined(__vxworks) || defined(__TRICORE__) + #define BOOST_EXTENSION_EXPORT_DECL +#elif defined(OMC_BUILD) || defined(SIMSTER_BUILD) +#else + error "operating system not supported" +#endif \ No newline at end of file diff --git a/SimulationRuntime/cpp/Include/Core/Utils/Modelica/ModelicaSimulationError.h b/SimulationRuntime/cpp/Include/Core/Utils/Modelica/ModelicaSimulationError.h index 1406e037fd7..8c67964227f 100644 --- a/SimulationRuntime/cpp/Include/Core/Utils/Modelica/ModelicaSimulationError.h +++ b/SimulationRuntime/cpp/Include/Core/Utils/Modelica/ModelicaSimulationError.h @@ -1,5 +1,7 @@ #pragma once +#include + //Enum for error types that can occur enum SIMULATION_ERROR { SOLVER, //all errors occur in solver (Euler,CVode) @@ -19,32 +21,34 @@ enum SIMULATION_ERROR { /* Exception class for all simulation errors */ -class ModelicaSimulationError: public std::runtime_error - { - public: - ModelicaSimulationError(SIMULATION_ERROR error_id,const std::string& error_info) - :runtime_error(strdup(error_info.c_str())) - ,_error_id(error_id) - { - } - const char* what() - { +class ModelicaSimulationError : public std::runtime_error +{ + public: + ModelicaSimulationError(SIMULATION_ERROR error_id, const std::string& error_info) + : runtime_error(strdup(error_info.c_str())) + , _error_id(error_id) + { + } + + const char* what() + { std::stringstream ss; ss << "simulation error message : " << std::runtime_error::what(); return strdup(ss.str().c_str()); - } - SIMULATION_ERROR getErrorID() - { - return _error_id; - } + } + + SIMULATION_ERROR getErrorID() + { + return _error_id; + } + private: - SIMULATION_ERROR _error_id; - - }; + SIMULATION_ERROR _error_id; +}; - //Helper functions to convert the error id to a readable format - BOOST_EXTENSION_EXPORT_DECL string error_id_string(SIMULATION_ERROR id); - //Helper functions to extend an error information for new additional string and time stamp - BOOST_EXTENSION_EXPORT_DECL string add_error_info(string new_info,string info,SIMULATION_ERROR id,double& time); - //Helper functions to extend an error information for new additional string - BOOST_EXTENSION_EXPORT_DECL string add_error_info(string new_info,string info,SIMULATION_ERROR id); \ No newline at end of file +//Helper functions to convert the error id to a readable format +BOOST_EXTENSION_EXPORT_DECL string error_id_string(SIMULATION_ERROR id); +//Helper functions to extend an error information for new additional string and time stamp +BOOST_EXTENSION_EXPORT_DECL string add_error_info(string new_info,string info,SIMULATION_ERROR id,double& time); +//Helper functions to extend an error information for new additional string +BOOST_EXTENSION_EXPORT_DECL string add_error_info(string new_info,string info,SIMULATION_ERROR id); \ No newline at end of file