]> Devoid-pointer.net GitWeb - FFBChecker.git/commitdiff
Add specific equality checks for SDL2 periodic and conditional effects
authorMichal Malý <madcatxster@devoid-pointer.net>
Sat, 1 Aug 2015 12:25:38 +0000 (14:25 +0200)
committerMichal Malý <madcatxster@devoid-pointer.net>
Sat, 1 Aug 2015 12:25:38 +0000 (14:25 +0200)
sdl2ffbconditioneffect.cpp
sdl2ffbconditioneffect.h
sdl2ffbperiodiceffect.cpp
sdl2ffbperiodiceffect.h

index 1702fbddcd481440d6b63d5d221fb73d56849835..2c1347219e7e2a17897ace01a10c5c5b053380ab 100644 (file)
@@ -135,4 +135,16 @@ bool SDL2FFBConditionEffect::setParameters(std::shared_ptr<FFBConditionEffectPar
   return true;
 }
 
-
+bool SDL2FFBConditionEffect::operator==(const FFBEffect& other) const
+{
+  if (this->type() != other.type())
+    return false;
+  else {
+    try {
+      const SDL2FFBConditionEffect& cother = dynamic_cast<const SDL2FFBConditionEffect&>(other);
+      return this->m_params->subtype == cother.m_params->subtype;
+    } catch (std::bad_cast&) {
+      return false;
+    }
+  }
+}
index 178abc8da364f72a21420ac5bc7eacfc43a6ca5f..7492434cc3a1fb53923eea173d170c60faf0cd6c 100644 (file)
@@ -12,6 +12,8 @@ public:
   inline const std::shared_ptr<FFBEffectParameters> parameters() const { return m_params; }
   bool setParameters(std::shared_ptr<FFBEffectParameters> params);
 
+  bool operator==(const FFBEffect& other) const;
+
 private:
   bool setParameters(std::shared_ptr<FFBConditionEffectParameters> params);
 
index 73409cfa722e1a003ef5c2b59c837a3d33133c44..96ad998622876520e9274e5a8dc745a861947499 100644 (file)
@@ -103,3 +103,16 @@ bool SDL2FFBPeriodicEffect::setParameters(const std::shared_ptr<FFBPeriodicEffec
   return true;
 }
 
+bool SDL2FFBPeriodicEffect::operator==(const FFBEffect& other) const
+{
+  if (this->type() != other.type())
+    return false;
+  else {
+    try {
+      const SDL2FFBPeriodicEffect& eff = dynamic_cast<const SDL2FFBPeriodicEffect&>(other);
+      return this->m_params->waveform == eff.m_params->waveform;
+    } catch(std::bad_cast&) {
+      return false;
+    }
+  }
+}
\ No newline at end of file
index cbf67ba7f56dafdd6ebfb48c01599d7703156bd4..7b3f90986d0d8988a59df36aae36d10d1bbc38a4 100644 (file)
@@ -12,6 +12,8 @@ public:
   inline const std::shared_ptr<FFBEffectParameters> parameters() const { return m_params; }
   bool setParameters(const std::shared_ptr<FFBEffectParameters> params);
 
+  bool operator==(const FFBEffect& other) const;
+
 private:
   bool setParameters(const std::shared_ptr<FFBPeriodicEffectParameters> params);