changeset 212:827176d3b6ec

Naming
author Chris Cannam
date Fri, 27 Feb 2015 14:14:42 +0000
parents 6373d14deace
children 2fcd1c14f0f6
files Makefile.inc src/DistanceMetric.cpp src/Finder.cpp src/MatchTypes.h src/Matcher.cpp test/TestDistanceMetric.cpp
diffstat 6 files changed, 37 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.inc	Fri Feb 27 14:10:50 2015 +0000
+++ b/Makefile.inc	Fri Feb 27 14:14:42 2015 +0000
@@ -36,14 +36,14 @@
 	
 # DO NOT DELETE
 
-src/DistanceMetric.o: src/DistanceMetric.h
+src/DistanceMetric.o: src/DistanceMetric.h src/MatchTypes.h
 src/Path.o: src/Path.h
-src/FeatureConditioner.o: src/FeatureConditioner.h
+src/FeatureConditioner.o: src/FeatureConditioner.h src/MatchTypes.h
 src/MatchFeatureFeeder.o: src/MatchFeatureFeeder.h src/Matcher.h
 src/MatchFeatureFeeder.o: src/DistanceMetric.h src/MatchTypes.h src/Finder.h
-src/FeatureExtractor.o: src/FeatureExtractor.h
-src/Finder.o: src/Finder.h src/Matcher.h src/DistanceMetric.h src/MatchTypes.h
-src/Finder.o: src/Path.h
+src/FeatureExtractor.o: src/FeatureExtractor.h src/MatchTypes.h
+src/Finder.o: src/Finder.h src/Matcher.h src/DistanceMetric.h
+src/Finder.o: src/MatchTypes.h src/Path.h
 src/Matcher.o: src/Matcher.h src/DistanceMetric.h src/MatchTypes.h
 src/MatchPipeline.o: src/MatchPipeline.h src/Matcher.h src/DistanceMetric.h
 src/MatchPipeline.o: src/MatchTypes.h src/Finder.h src/FeatureExtractor.h
@@ -55,6 +55,7 @@
 src/MatchVampPlugin.o: src/Path.h
 src/MatchFeatureFeeder.o: src/Matcher.h src/DistanceMetric.h src/MatchTypes.h
 src/MatchFeatureFeeder.o: src/Finder.h
+src/FeatureExtractor.o: src/MatchTypes.h
 src/Finder.o: src/Matcher.h src/DistanceMetric.h src/MatchTypes.h
 src/Matcher.o: src/DistanceMetric.h src/MatchTypes.h
 src/MatchPipeline.o: src/Matcher.h src/DistanceMetric.h src/MatchTypes.h
@@ -63,6 +64,8 @@
 src/MatchVampPlugin.o: src/MatchPipeline.h src/Matcher.h src/DistanceMetric.h
 src/MatchVampPlugin.o: src/MatchTypes.h src/Finder.h src/FeatureExtractor.h
 src/MatchVampPlugin.o: src/FeatureConditioner.h src/MatchFeatureFeeder.h
-test/TestFeatureConditioner.o: src/FeatureConditioner.h
-test/TestDistanceMetric.o: src/DistanceMetric.h
-test/TestFeatureExtractor.o: src/FeatureExtractor.h
+src/DistanceMetric.o: src/MatchTypes.h
+src/FeatureConditioner.o: src/MatchTypes.h
+test/TestFeatureConditioner.o: src/FeatureConditioner.h src/MatchTypes.h
+test/TestDistanceMetric.o: src/DistanceMetric.h src/MatchTypes.h
+test/TestFeatureExtractor.o: src/FeatureExtractor.h src/MatchTypes.h
--- a/src/DistanceMetric.cpp	Fri Feb 27 14:10:50 2015 +0000
+++ b/src/DistanceMetric.cpp	Fri Feb 27 14:14:42 2015 +0000
@@ -31,8 +31,8 @@
     if (scaled < 0) {
         scaled = 0;
     }
-    if (scaled > MaxDistance) {
-        scaled = MaxDistance;
+    if (scaled > DISTANCE_MAX) {
+        scaled = DISTANCE_MAX;
         ++m_overcount;
     }
     return uint8_t(scaled);
--- a/src/Finder.cpp	Fri Feb 27 14:10:50 2015 +0000
+++ b/src/Finder.cpp	Fri Feb 27 14:14:42 2015 +0000
@@ -254,7 +254,7 @@
         for (int c = rowStart; c < rowStop; c++) {
 
             advance_t dir = AdvanceNone;
-            pathcost_t updateTo = InvalidPathCost;
+            pathcost_t updateTo = INVALID_PATHCOST;
             distance_t distance = m_m->getDistance(r, c);
             pathcost_t straightIncrement = distance;
             pathcost_t diagIncrement = pathcost_t(distance * m_m->getDiagonalWeight());
--- a/src/MatchTypes.h	Fri Feb 27 14:10:50 2015 +0000
+++ b/src/MatchTypes.h	Fri Feb 27 14:14:42 2015 +0000
@@ -31,14 +31,14 @@
 /// What to cast a distance_t to when printing it (to avoid printing as char)
 typedef int distance_print_t;
 
-const distance_t MaxDistance = 0xfe;
-const distance_t InvalidDistance = 0xff;
+const distance_t DISTANCE_MAX = 0xfe;
+const distance_t INVALID_DISTANCE = 0xff;
 
 /// The integrated distance (path cost) from the origin to a given point
 typedef uint32_t pathcost_t;
 
-const pathcost_t MaxPathCost = 0xfffffffe;
-const pathcost_t InvalidPathCost = 0xffffffff;
+const pathcost_t PATHCOST_MAX = 0xfffffffe;
+const pathcost_t INVALID_PATHCOST = 0xffffffff;
 
 /// A direction advance instruction or state
 enum advance_t : uint8_t {
@@ -63,14 +63,14 @@
 /// What to cast a distance_t to when printing it
 typedef distance_t distance_print_t;
 
-const float MaxDistance = FLT_MAX;
-const float InvalidDistance = -1.f;
+const float DISTANCE_MAX = FLT_MAX;
+const float INVALID_DISTANCE = -1.f;
 
 /// The integrated distance (path cost) from the origin to a given point
 typedef double pathcost_t;
 
-const double MaxPathCost = DBL_MAX;
-const double InvalidPathCost = -1.;
+const double PATHCOST_MAX = DBL_MAX;
+const double INVALID_PATHCOST = -1.;
 
 /// A direction advance instruction or state
 enum advance_t {
--- a/src/Matcher.cpp	Fri Feb 27 14:10:50 2015 +0000
+++ b/src/Matcher.cpp	Fri Feb 27 14:14:42 2015 +0000
@@ -81,7 +81,7 @@
 {
     if (m_firstPM) {
         if (isInRange(i, j)) {
-            return (m_bestPathCost[i][j - m_first[i]] != InvalidPathCost);
+            return (m_bestPathCost[i][j - m_first[i]] != INVALID_PATHCOST);
         } else {
             return false;
         }
@@ -97,7 +97,7 @@
 
         if (i < 0 || i >= int(m_first.size())) return false;
         for (auto c: m_bestPathCost[i]) {
-            if (c != InvalidPathCost) return true;
+            if (c != INVALID_PATHCOST) return true;
         }
         return false;
 
@@ -112,7 +112,7 @@
     if (m_firstPM) {
         for (int i = 0; i < int(m_first.size()); ++i) {
             if (j >= m_first[i] && j < m_last[i]) {
-                if (m_bestPathCost[i][j - m_first[i]] != InvalidPathCost) {
+                if (m_bestPathCost[i][j - m_first[i]] != INVALID_PATHCOST) {
                     return true;
                 }
             }
@@ -184,7 +184,7 @@
 #endif
         distance_t dist = m_distance[i][j - m_first[i]];
 #ifdef PERFORM_ERROR_CHECKS
-        if (dist == InvalidDistance) {
+        if (dist == INVALID_DISTANCE) {
             cerr << "ERROR: Matcher::getDistance(" << i << ", " << j << "): "
                  << "Location is in range, but distance ("
                  << distance_print_t(dist)
@@ -279,8 +279,8 @@
 
     if (m_firstPM) {
         int distSize = (m_params.maxRunCount + 1) * m_blockSize;
-        m_bestPathCost.resize(m_distXSize, pathcostvec_t(distSize, InvalidPathCost));
-        m_distance.resize(m_distXSize, distancevec_t(distSize, InvalidDistance));
+        m_bestPathCost.resize(m_distXSize, pathcostvec_t(distSize, INVALID_PATHCOST));
+        m_distance.resize(m_distXSize, distancevec_t(distSize, INVALID_DISTANCE));
         m_advance.resize(m_distXSize, advancevec_t(distSize, AdvanceNone));
     }
 }
@@ -297,8 +297,8 @@
 pathcost_t
 Matcher::addToCost(pathcost_t cost, pathcost_t increment)
 {
-    if (MaxPathCost - increment < cost) {
-        return MaxPathCost;
+    if (PATHCOST_MAX - increment < cost) {
+        return PATHCOST_MAX;
     } else {
         return cost + pathcost_t(increment);
     }
@@ -448,10 +448,10 @@
     }
 
     pathcost_t newValue = addToCost(value, increment);
-    if (newValue == MaxPathCost) {
+    if (newValue == PATHCOST_MAX) {
         cerr << "ERROR: Path cost overflow at i=" << i << ", j=" << j << ": "
-             << value << " + " << increment << " >= " << MaxPathCost << endl;
-        newValue = MaxPathCost;
+             << value << " + " << increment << " >= " << PATHCOST_MAX << endl;
+        newValue = PATHCOST_MAX;
     }
     
     if (m_firstPM) {
@@ -471,8 +471,8 @@
             // pauses in either direction, and arbitrary lengths at
             // end, it is better than a segmentation fault.
             cerr << "Emergency resize: " << idx << " -> " << idx * 2 << endl;
-            m_otherMatcher->m_bestPathCost[j].resize(idx * 2, InvalidPathCost);
-            m_otherMatcher->m_distance[j].resize(idx * 2, InvalidDistance);
+            m_otherMatcher->m_bestPathCost[j].resize(idx * 2, INVALID_PATHCOST);
+            m_otherMatcher->m_distance[j].resize(idx * 2, INVALID_DISTANCE);
             m_otherMatcher->m_advance[j].resize(idx * 2, AdvanceNone);
         }
 
--- a/test/TestDistanceMetric.cpp	Fri Feb 27 14:10:50 2015 +0000
+++ b/test/TestDistanceMetric.cpp	Fri Feb 27 14:14:42 2015 +0000
@@ -36,7 +36,7 @@
     BOOST_CHECK_EQUAL(dm.scaleValueIntoDistanceRange(2.0), 2);
 
     if (sizeof(distance_t) == 1) {
-        BOOST_CHECK_EQUAL(dm.scaleValueIntoDistanceRange(256.0), MaxDistance);
+        BOOST_CHECK_EQUAL(dm.scaleValueIntoDistanceRange(256.0), DISTANCE_MAX);
     } else {
         BOOST_CHECK_EQUAL(dm.scaleValueIntoDistanceRange(256.0), 256);
     }
@@ -48,7 +48,7 @@
         BOOST_CHECK_EQUAL(dm.scaleValueIntoDistanceRange(0.0), 0);
         BOOST_CHECK_EQUAL(dm.scaleValueIntoDistanceRange(1.0), 2);
         BOOST_CHECK_EQUAL(dm.scaleValueIntoDistanceRange(2.0), 4);
-        BOOST_CHECK_EQUAL(dm.scaleValueIntoDistanceRange(128.0), MaxDistance);
+        BOOST_CHECK_EQUAL(dm.scaleValueIntoDistanceRange(128.0), DISTANCE_MAX);
     } else {
         BOOST_CHECK_EQUAL(dm.scaleValueIntoDistanceRange(0.0), 0);
         BOOST_CHECK_EQUAL(dm.scaleValueIntoDistanceRange(1.0), 1);