diff --git a/MAC/APL/RTCCommon/include/APL/RTCCommon/RegisterState.h b/MAC/APL/RTCCommon/include/APL/RTCCommon/RegisterState.h index 493249b1b138e51ee430b297cf2c264d0fc291bc..e5ff9fe81472f6511c79d05544dae562954f357b 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 e2cd154eca46c5b1066fea49227b32a6dc74da59..e5d88997c07c4357bc4e0785c24bf5cca0b2a75d 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++) {