* Returns whether sending a notification of type type right now would represent *this' current state correctly. * * @param type The type of notification to send (or not to send). * * @return Whether to send the notification. */
| 261 | * @return Whether to send the notification. |
| 262 | */ |
| 263 | bool Checkable::NotificationReasonApplies(NotificationType type) |
| 264 | { |
| 265 | switch (type) { |
| 266 | case NotificationProblem: |
| 267 | { |
| 268 | auto cr (GetLastCheckResult()); |
| 269 | return cr && !IsStateOK(cr->GetState()); |
| 270 | } |
| 271 | case NotificationRecovery: |
| 272 | { |
| 273 | auto cr (GetLastCheckResult()); |
| 274 | return cr && IsStateOK(cr->GetState()); |
| 275 | } |
| 276 | case NotificationFlappingStart: |
| 277 | return IsFlapping(); |
| 278 | case NotificationFlappingEnd: |
| 279 | return !IsFlapping(); |
| 280 | default: |
| 281 | VERIFY(!"Checkable#NotificationReasonStillApplies(): given type not implemented"); |
| 282 | return false; |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | /** |
| 287 | * Checks if notifications of a given type should be suppressed for this Checkable at the moment. |
no test coverage detected