From: Michal MalĂ˝ Date: Sat, 1 Aug 2015 12:25:38 +0000 (+0200) Subject: Add specific equality checks for SDL2 periodic and conditional effects X-Git-Url: https://gitweb.devoid-pointer.net/?a=commitdiff_plain;h=ddd3d22da1416a492e276ebf0f59f203d3988b1f;p=FFBChecker.git Add specific equality checks for SDL2 periodic and conditional effects --- 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);