Commit fec7d23d3be2ae1809c616c55dd38cd6718a8fbc
1 parent
70d3ef0e
add isin() method
Showing
2 changed files
with
24 additions
and
0 deletions
include/GGti.hpp
| @@ -68,6 +68,7 @@ public: | @@ -68,6 +68,7 @@ public: | ||
| 68 | GTime tstop(int inx) const; | 68 | GTime tstop(int inx) const; |
| 69 | double telapse(void) const { return m_telapse; } | 69 | double telapse(void) const { return m_telapse; } |
| 70 | double ontime(void) const { return m_ontime; } | 70 | double ontime(void) const { return m_ontime; } |
| 71 | + bool isin(const GTime& t) const; | ||
| 71 | 72 | ||
| 72 | protected: | 73 | protected: |
| 73 | // Protected methods | 74 | // Protected methods |
src/obs/GGti.cpp
| @@ -422,6 +422,29 @@ GTime GGti::tstop(int inx) const | @@ -422,6 +422,29 @@ GTime GGti::tstop(int inx) const | ||
| 422 | } | 422 | } |
| 423 | 423 | ||
| 424 | 424 | ||
| 425 | +/***********************************************************************//** | ||
| 426 | + * @brief Tests whether time is within GTI intervals | ||
| 427 | + * | ||
| 428 | + * @param[in] t Time to be tested. | ||
| 429 | + ***************************************************************************/ | ||
| 430 | +bool GGti::isin(const GTime& t) const | ||
| 431 | +{ | ||
| 432 | + // Initialise test | ||
| 433 | + bool found = false; | ||
| 434 | + | ||
| 435 | + // Test all GTIs | ||
| 436 | + for (int i = 0; i < m_num; ++i) { | ||
| 437 | + if (t >= m_start[i] && t <= m_stop[i]) { | ||
| 438 | + found = true; | ||
| 439 | + break; | ||
| 440 | + } | ||
| 441 | + } | ||
| 442 | + | ||
| 443 | + // Return result | ||
| 444 | + return found; | ||
| 445 | +} | ||
| 446 | + | ||
| 447 | + | ||
| 425 | /*========================================================================== | 448 | /*========================================================================== |
| 426 | = = | 449 | = = |
| 427 | = Private methods = | 450 | = Private methods = |