From fec7d23d3be2ae1809c616c55dd38cd6718a8fbc Mon Sep 17 00:00:00 2001 From: knodlseder <> Date: Sat, 12 Jun 2010 11:45:28 +0000 Subject: [PATCH] add isin() method --- include/GGti.hpp | 1 + src/obs/GGti.cpp | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 0 deletions(-) diff --git a/include/GGti.hpp b/include/GGti.hpp index 1037620..605c016 100644 --- a/include/GGti.hpp +++ b/include/GGti.hpp @@ -68,6 +68,7 @@ public: GTime tstop(int inx) const; double telapse(void) const { return m_telapse; } double ontime(void) const { return m_ontime; } + bool isin(const GTime& t) const; protected: // Protected methods diff --git a/src/obs/GGti.cpp b/src/obs/GGti.cpp index 151a43f..b67f478 100644 --- a/src/obs/GGti.cpp +++ b/src/obs/GGti.cpp @@ -422,6 +422,29 @@ GTime GGti::tstop(int inx) const } +/***********************************************************************//** + * @brief Tests whether time is within GTI intervals + * + * @param[in] t Time to be tested. + ***************************************************************************/ +bool GGti::isin(const GTime& t) const +{ + // Initialise test + bool found = false; + + // Test all GTIs + for (int i = 0; i < m_num; ++i) { + if (t >= m_start[i] && t <= m_stop[i]) { + found = true; + break; + } + } + + // Return result + return found; +} + + /*========================================================================== = = = Private methods = -- libgit2 0.21.4