From f96794c70e1dcb7d88a7362cceb382783b1d7464 Mon Sep 17 00:00:00 2001
From: wierenga <sdos@astron.nl>
Date: Wed, 12 Jul 2006 07:50:09 +0000
Subject: [PATCH] BugID: 778 Add function to check if all states match some
 given state.

---
 MAC/APL/RTCCommon/include/APL/RTCCommon/RegisterState.h | 4 +++-
 MAC/APL/RTCCommon/src/RegisterState.cc                  | 8 +++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/MAC/APL/RTCCommon/include/APL/RTCCommon/RegisterState.h b/MAC/APL/RTCCommon/include/APL/RTCCommon/RegisterState.h
index 493249b1b13..e5ff9fe8147 100644
--- a/MAC/APL/RTCCommon/include/APL/RTCCommon/RegisterState.h
+++ b/MAC/APL/RTCCommon/include/APL/RTCCommon/RegisterState.h
@@ -112,7 +112,9 @@ namespace LOFAR {
 	void clear(int i = -1);
 	void reset(int i = -1);
 
-	State get(int i);
+	State get(int i) const;
+	int   getMatchCount(blitz::Range r, State matchstate) const;
+
 	void print(std::ostream& out) const;
 
       public:
diff --git a/MAC/APL/RTCCommon/src/RegisterState.cc b/MAC/APL/RTCCommon/src/RegisterState.cc
index e2cd154eca4..e5d88997c07 100644
--- a/MAC/APL/RTCCommon/src/RegisterState.cc
+++ b/MAC/APL/RTCCommon/src/RegisterState.cc
@@ -27,13 +27,19 @@
 using namespace std;
 using namespace LOFAR;
 using namespace RTC;
+using namespace blitz;
 
-RegisterState::State RegisterState::get(int i)
+RegisterState::State RegisterState::get(int i) const
 {
   ASSERT(i >= 0 && i < m_state.extent(blitz::firstDim));
   return m_state(i);
 }
 
+int RegisterState::getMatchCount(Range r, State matchstate) const
+{
+  return sum(where(m_state(r) == matchstate, 1, 0));
+}
+
 void RegisterState::print(std::ostream& out) const
 {
   for (int i = 0; i < m_state.extent(blitz::firstDim); i++) {
-- 
GitLab