From 1cb6ad358c76f50ec83be5f367f98856438f67aa Mon Sep 17 00:00:00 2001 From: Arnaud Tanguy Date: Wed, 6 Apr 2022 11:19:07 +0200 Subject: [PATCH] [openrtm1.1] Fix build for OpenRTM 1.1 with C++>=14 When using OpenRTM 1.1, the various execution contexts interface declare a looser throw() specification, which is now disallowed in C++14 and above. In order to allow building with the latest choreonoid but using older openrtm versions this patch is necessary. In addition this fixes the include path for `rtm/idl/CameraCommonInterface.hh` that used to be `rtm/ext/CameraCommonInterface.hh` in openrtm1.1 --- .../BodyStateSubscriberRTCItem.cpp | 6 +++++- src/OpenRTMPlugin/RTMImageView.cpp | 6 +++++- .../SimulationExecutionContext.cpp | 20 +++++++++++++++++++ .../SimulationExecutionContext.h | 8 ++++++++ .../deprecated/ChoreonoidExecutionContext.cpp | 12 +++++++++++ .../deprecated/ChoreonoidExecutionContext.h | 7 +++++++ .../ChoreonoidPeriodicExecutionContext.cpp | 4 ++++ .../ChoreonoidPeriodicExecutionContext.h | 4 ++++ .../deprecated/VirtualRobotPortHandler.cpp | 6 +++++- 9 files changed, 70 insertions(+), 3 deletions(-) diff --git a/src/OpenRTMPlugin/BodyStateSubscriberRTCItem.cpp b/src/OpenRTMPlugin/BodyStateSubscriberRTCItem.cpp index e1ee462..a3ff622 100644 --- a/src/OpenRTMPlugin/BodyStateSubscriberRTCItem.cpp +++ b/src/OpenRTMPlugin/BodyStateSubscriberRTCItem.cpp @@ -23,7 +23,11 @@ #ifdef USE_BUILTIN_CAMERA_IMAGE_IDL # include "deprecated/corba/CameraImage.hh" #else -# include + #if defined(OPENRTM_VERSION11) + # include + #else + # include + #endif #endif #include diff --git a/src/OpenRTMPlugin/RTMImageView.cpp b/src/OpenRTMPlugin/RTMImageView.cpp index 1f567b5..014280a 100644 --- a/src/OpenRTMPlugin/RTMImageView.cpp +++ b/src/OpenRTMPlugin/RTMImageView.cpp @@ -14,7 +14,11 @@ #ifdef USE_BUILTIN_CAMERA_IMAGE_IDL # include "deprecated/corba/CameraImage.hh" #else -# include + #if defined(OPENRTM_VERSION11) + # include + #else + # include + #endif #endif #include diff --git a/src/OpenRTMPlugin/SimulationExecutionContext.cpp b/src/OpenRTMPlugin/SimulationExecutionContext.cpp index 903fd54..40b3588 100644 --- a/src/OpenRTMPlugin/SimulationExecutionContext.cpp +++ b/src/OpenRTMPlugin/SimulationExecutionContext.cpp @@ -29,7 +29,11 @@ SimulationExecutionContext::~SimulationExecutionContext() } +#if defined(OPENRTM_VERSION11) +void SimulationExecutionContext::tick() throw (CORBA::SystemException) +#else void SimulationExecutionContext::tick() +#endif { #if defined(OPENRTM_VERSION11) std::for_each(m_comps.begin(), m_comps.end(), invoke_worker()); @@ -39,13 +43,21 @@ void SimulationExecutionContext::tick() } +#if defined(OPENRTM_VERSION11) +int SimulationExecutionContext::svc(void) throw (CORBA::SystemException) +#else int SimulationExecutionContext::svc(void) +#endif { return 0; } +#if defined(OPENRTM_VERSION11) +RTC::ReturnCode_t SimulationExecutionContext::activate_component(RTC::LightweightRTObject_ptr comp) throw(CORBA::SystemException) +#else RTC::ReturnCode_t SimulationExecutionContext::activate_component(RTC::LightweightRTObject_ptr comp) +#endif { #if defined(OPENRTM_VERSION11) @@ -91,7 +103,11 @@ RTC::ReturnCode_t SimulationExecutionContext::activate_component(RTC::Lightweigh } +#if defined(OPENRTM_VERSION11) +RTC::ReturnCode_t SimulationExecutionContext::deactivate_component(RTC::LightweightRTObject_ptr comp) throw(CORBA::SystemException) +#else RTC::ReturnCode_t SimulationExecutionContext::deactivate_component(RTC::LightweightRTObject_ptr comp) +#endif { #if defined(OPENRTM_VERSION11) @@ -143,7 +159,11 @@ RTC::ReturnCode_t SimulationExecutionContext::deactivate_component(RTC::Lightwei } +#if defined(OPENRTM_VERSION11) +RTC::ReturnCode_t SimulationExecutionContext::reset_component(RTC::LightweightRTObject_ptr comp) throw(CORBA::SystemException) +#else RTC::ReturnCode_t SimulationExecutionContext::reset_component(RTC::LightweightRTObject_ptr comp) +#endif { #if defined(OPENRTM_VERSION11) diff --git a/src/OpenRTMPlugin/SimulationExecutionContext.h b/src/OpenRTMPlugin/SimulationExecutionContext.h index bf70fe3..fcfb2d5 100644 --- a/src/OpenRTMPlugin/SimulationExecutionContext.h +++ b/src/OpenRTMPlugin/SimulationExecutionContext.h @@ -34,11 +34,19 @@ class SimulationExecutionContext : public RTC::OpenHRPExecutionContext public: SimulationExecutionContext(); virtual ~SimulationExecutionContext(void); +#ifdef OPENRTM_VERSION11 + virtual void tick(void) throw(CORBA::SystemException) override; + virtual int svc(void) throw(CORBA::SystemException); + virtual RTC::ReturnCode_t activate_component(RTC::LightweightRTObject_ptr comp) throw(CORBA::SystemException) override; + virtual RTC::ReturnCode_t deactivate_component(RTC::LightweightRTObject_ptr comp) throw(CORBA::SystemException) override; + virtual RTC::ReturnCode_t reset_component(RTC::LightweightRTObject_ptr comp) throw(CORBA::SystemException) override; +#else virtual void tick(void) override; virtual int svc(void); virtual RTC::ReturnCode_t activate_component(RTC::LightweightRTObject_ptr comp) override; virtual RTC::ReturnCode_t deactivate_component(RTC::LightweightRTObject_ptr comp) override; virtual RTC::ReturnCode_t reset_component(RTC::LightweightRTObject_ptr comp) override; +#endif }; } diff --git a/src/OpenRTMPlugin/deprecated/ChoreonoidExecutionContext.cpp b/src/OpenRTMPlugin/deprecated/ChoreonoidExecutionContext.cpp index ab55628..a0ca512 100644 --- a/src/OpenRTMPlugin/deprecated/ChoreonoidExecutionContext.cpp +++ b/src/OpenRTMPlugin/deprecated/ChoreonoidExecutionContext.cpp @@ -30,7 +30,11 @@ ChoreonoidExecutionContext::~ChoreonoidExecutionContext() } +#if defined(OPENRTM_VERSION11) +void ChoreonoidExecutionContext::tick() throw(CORBA::SystemException) +#else void ChoreonoidExecutionContext::tick() +#endif { #if defined(OPENRTM_VERSION11) std::for_each(m_comps.begin(), m_comps.end(), invoke_worker()); @@ -40,13 +44,21 @@ void ChoreonoidExecutionContext::tick() } +#if defined(OPENRTM_VERSION11) +int ChoreonoidExecutionContext::svc(void) throw(CORBA::SystemException) +#else int ChoreonoidExecutionContext::svc(void) +#endif { return 0; } +#if defined(OPENRTM_VERSION11) +RTC::ReturnCode_t ChoreonoidExecutionContext::deactivate_component(RTC::LightweightRTObject_ptr comp) throw(CORBA::SystemException) +#else RTC::ReturnCode_t ChoreonoidExecutionContext::deactivate_component(RTC::LightweightRTObject_ptr comp) +#endif { #if defined(OPENRTM_VERSION11) RTC_TRACE(("deactivate_component()")); diff --git a/src/OpenRTMPlugin/deprecated/ChoreonoidExecutionContext.h b/src/OpenRTMPlugin/deprecated/ChoreonoidExecutionContext.h index 429b4ee..97c1e4b 100644 --- a/src/OpenRTMPlugin/deprecated/ChoreonoidExecutionContext.h +++ b/src/OpenRTMPlugin/deprecated/ChoreonoidExecutionContext.h @@ -36,9 +36,16 @@ class ChoreonoidExecutionContext : public RTC::OpenHRPExecutionContext public: ChoreonoidExecutionContext(); virtual ~ChoreonoidExecutionContext(void); +#if defined(OPENRTM_VERSION11) + virtual void tick(void) throw(CORBA::SystemException) override; + virtual int svc(void) throw(CORBA::SystemException); + virtual RTC::ReturnCode_t deactivate_component(RTC::LightweightRTObject_ptr comp) throw(CORBA::SystemException) override; +#else virtual void tick(void) override; virtual int svc(void); virtual RTC::ReturnCode_t deactivate_component(RTC::LightweightRTObject_ptr comp) override; +#endif + }; } diff --git a/src/OpenRTMPlugin/deprecated/ChoreonoidPeriodicExecutionContext.cpp b/src/OpenRTMPlugin/deprecated/ChoreonoidPeriodicExecutionContext.cpp index 4937e74..4b9340f 100644 --- a/src/OpenRTMPlugin/deprecated/ChoreonoidPeriodicExecutionContext.cpp +++ b/src/OpenRTMPlugin/deprecated/ChoreonoidPeriodicExecutionContext.cpp @@ -24,7 +24,11 @@ ChoreonoidPeriodicExecutionContext::~ChoreonoidPeriodicExecutionContext() } +#if defined(OPENRTM_VERSION11) +RTC::ReturnCode_t ChoreonoidPeriodicExecutionContext::deactivate_component(RTC::LightweightRTObject_ptr comp) throw(CORBA::SystemException) +#else RTC::ReturnCode_t ChoreonoidPeriodicExecutionContext::deactivate_component(RTC::LightweightRTObject_ptr comp) +#endif { #if defined(OPENRTM_VERSION11) RTC_TRACE(("deactivate_component()")); diff --git a/src/OpenRTMPlugin/deprecated/ChoreonoidPeriodicExecutionContext.h b/src/OpenRTMPlugin/deprecated/ChoreonoidPeriodicExecutionContext.h index 054145c..f96f5ed 100644 --- a/src/OpenRTMPlugin/deprecated/ChoreonoidPeriodicExecutionContext.h +++ b/src/OpenRTMPlugin/deprecated/ChoreonoidPeriodicExecutionContext.h @@ -30,7 +30,11 @@ class ChoreonoidPeriodicExecutionContext : public virtual RTC_exp::PeriodicExecu public: ChoreonoidPeriodicExecutionContext(); virtual ~ChoreonoidPeriodicExecutionContext(void); +#if defined(OPENRTM_VERSION11) + virtual RTC::ReturnCode_t deactivate_component(RTC::LightweightRTObject_ptr comp) throw(CORBA::SystemException) override; +#else virtual RTC::ReturnCode_t deactivate_component(RTC::LightweightRTObject_ptr comp) override; +#endif }; } diff --git a/src/OpenRTMPlugin/deprecated/VirtualRobotPortHandler.cpp b/src/OpenRTMPlugin/deprecated/VirtualRobotPortHandler.cpp index b77da16..6fe92de 100644 --- a/src/OpenRTMPlugin/deprecated/VirtualRobotPortHandler.cpp +++ b/src/OpenRTMPlugin/deprecated/VirtualRobotPortHandler.cpp @@ -8,7 +8,11 @@ #ifdef USE_BUILTIN_CAMERA_IMAGE_IDL # include #else -# include + #if defined(OPENRTM_VERSION11) + # include + #else + # include + #endif #endif #include "VirtualRobotPortHandler.h"