[Liblas-commits] hg-main-tree: tighten up / dbeugging

liblas-commits at liblas.org liblas-commits at liblas.org
Mon Aug 15 10:54:14 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/489edceade8e
changeset: 1091:489edceade8e
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Mon Aug 15 07:53:58 2011 -0700
description:
tighten up / dbeugging

diffstat:

 include/pdal/Signaller.hpp  |   7 ++++++-
 test/unit/SignallerTest.cpp |  39 ++++++++++++++++++++++++++-------------
 2 files changed, 32 insertions(+), 14 deletions(-)

diffs (108 lines):

diff -r 5f618629cc5f -r 489edceade8e include/pdal/Signaller.hpp
--- a/include/pdal/Signaller.hpp	Mon Aug 15 07:35:40 2011 -0700
+++ b/include/pdal/Signaller.hpp	Mon Aug 15 07:53:58 2011 -0700
@@ -53,10 +53,13 @@
     virtual ~Signaller() {}
 
     // This is called by the pipeline at various times,
-    // passing in a value in range [0..1].  It could
+    // passing in a value in range [0..100].  It could
     // be called often, so the implementation should be fast.
     virtual void setPercentComplete(double value) = 0;
 
+    // returns a vlaue in range [0..100]
+    virtual double getPercentComplete() const = 0;
+
     // This is called by the pipeline at various times;
     // a return value of true means the pipeline should
     // abandon its work and do an orderly shutdown as
@@ -64,6 +67,8 @@
     // the implementation should be fast.
     virtual bool isInterruptRequested() const = 0;
 
+    virtual void requestInterrupt() = 0;
+
 private:
     Signaller& operator=(const Signaller&); // not implemented
     Signaller(const Signaller&); // not implemented
diff -r 5f618629cc5f -r 489edceade8e test/unit/SignallerTest.cpp
--- a/test/unit/SignallerTest.cpp	Mon Aug 15 07:35:40 2011 -0700
+++ b/test/unit/SignallerTest.cpp	Mon Aug 15 07:53:58 2011 -0700
@@ -53,7 +53,13 @@
     // override
     void setPercentComplete(double value)
     {
-        m_perc = (int)(value * 100);
+        m_perc = value;
+    }
+
+    // override
+    double getPercentComplete() const
+    {
+        return m_perc;
     }
 
     // override
@@ -62,7 +68,14 @@
         return m_stop;
     }
 
-    int m_perc;
+    // override
+    void requestInterrupt()
+    {
+        m_stop = true;
+    }
+
+private:
+    double m_perc;
     bool m_stop;
 };
 
@@ -76,13 +89,13 @@
     {
     }
 
-    bool tick()
+    bool doWork()
     {
         if (m_sig.isInterruptRequested())
             return false;
 
         ++m_ticks;
-        m_sig.setPercentComplete((double)m_ticks / 100.0);
+        m_sig.setPercentComplete((double)m_ticks);
         return true;
     }
 
@@ -101,21 +114,21 @@
     Worker worker(sig);
     bool ok;
 
-    ok = worker.tick();
+    ok = worker.doWork();
     BOOST_CHECK(ok);
-    BOOST_CHECK_EQUAL(sig.m_perc, 1);
-    ok = worker.tick();
+    BOOST_CHECK_CLOSE(sig.getPercentComplete(), 1.0, 0.001);
+    ok = worker.doWork();
     BOOST_CHECK(ok);
-    BOOST_CHECK_EQUAL(sig.m_perc, 2);
-    ok = worker.tick();
+    BOOST_CHECK_CLOSE(sig.getPercentComplete(), 2.0, 0.001);
+    ok = worker.doWork();
     BOOST_CHECK(ok);
-    BOOST_CHECK_EQUAL(sig.m_perc, 3);
+    BOOST_CHECK_CLOSE(sig.getPercentComplete(), 3.0, 0.001);
 
-    sig.m_stop = true;
+    sig.requestInterrupt();
 
-    ok = worker.tick();
+    ok = worker.doWork();
     BOOST_CHECK(!ok);
-    BOOST_CHECK_EQUAL(sig.m_perc, 3);
+    BOOST_CHECK_CLOSE(sig.getPercentComplete(), 3.0, 0.001);
 
     return;
 }


More information about the Liblas-commits mailing list