SupportOrVeto.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 #ifndef SQUID_SRC_BASE_SUPPORTORVETO_H
10 #define SQUID_SRC_BASE_SUPPORTORVETO_H
11 
12 #include <optional>
13 
16 {
17 public:
19  bool decision() const { return decision_.value_or(false); }
20 
22  operator bool() const { return decision(); }
23 
26  void support() { if (!decision_) decision_ = true; }
27 
29  void veto() { decision_ = false; }
30 
31 private:
33  std::optional<bool> decision_;
34 };
35 
36 #endif /* SQUID_SRC_BASE_SUPPORTORVETO_H */
37 
bool decision() const
either the current explicit decision or, by default, false
Definition: SupportOrVeto.h:19
std::optional< bool > decision_
current decision (if any)
Definition: SupportOrVeto.h:33
void veto()
makes decision() false regardless of past or future support() calls
Definition: SupportOrVeto.h:29
a boolean flag that is false by default and becomes permanently false if vetoed
Definition: SupportOrVeto.h:15

 

Introduction

Documentation

Support

Miscellaneous