From ddd3d22da1416a492e276ebf0f59f203d3988b1f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Mal=C3=BD?= Date: Sat, 1 Aug 2015 14:25:38 +0200 Subject: [PATCH] Add specific equality checks for SDL2 periodic and conditional effects --- sdl2ffbconditioneffect.cpp | 14 +++++++++++++- sdl2ffbconditioneffect.h | 2 ++ sdl2ffbperiodiceffect.cpp | 13 +++++++++++++ sdl2ffbperiodiceffect.h | 2 ++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/sdl2ffbconditioneffect.cpp b/sdl2ffbconditioneffect.cpp index 1702fbd..2c13472 100644 --- a/sdl2ffbconditioneffect.cpp +++ b/sdl2ffbconditioneffect.cpp @@ -135,4 +135,16 @@ bool SDL2FFBConditionEffect::setParameters(std::shared_ptrtype() != other.type()) + return false; + else { + try { + const SDL2FFBConditionEffect& cother = dynamic_cast(other); + return this->m_params->subtype == cother.m_params->subtype; + } catch (std::bad_cast&) { + return false; + } + } +} diff --git a/sdl2ffbconditioneffect.h b/sdl2ffbconditioneffect.h index 178abc8..7492434 100644 --- a/sdl2ffbconditioneffect.h +++ b/sdl2ffbconditioneffect.h @@ -12,6 +12,8 @@ public: inline const std::shared_ptr parameters() const { return m_params; } bool setParameters(std::shared_ptr params); + bool operator==(const FFBEffect& other) const; + private: bool setParameters(std::shared_ptr params); diff --git a/sdl2ffbperiodiceffect.cpp b/sdl2ffbperiodiceffect.cpp index 73409cf..96ad998 100644 --- a/sdl2ffbperiodiceffect.cpp +++ b/sdl2ffbperiodiceffect.cpp @@ -103,3 +103,16 @@ bool SDL2FFBPeriodicEffect::setParameters(const std::shared_ptrtype() != other.type()) + return false; + else { + try { + const SDL2FFBPeriodicEffect& eff = dynamic_cast(other); + return this->m_params->waveform == eff.m_params->waveform; + } catch(std::bad_cast&) { + return false; + } + } +} \ No newline at end of file diff --git a/sdl2ffbperiodiceffect.h b/sdl2ffbperiodiceffect.h index cbf67ba..7b3f909 100644 --- a/sdl2ffbperiodiceffect.h +++ b/sdl2ffbperiodiceffect.h @@ -12,6 +12,8 @@ public: inline const std::shared_ptr parameters() const { return m_params; } bool setParameters(const std::shared_ptr params); + bool operator==(const FFBEffect& other) const; + private: bool setParameters(const std::shared_ptr params); -- 2.43.5