aboutsummaryrefslogtreecommitdiffstats
path: root/vbench/src/vbench/core/taint.h
blob: 11d9d1d24121e9f5334067c1021108ec46694496 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "string.h"

namespace vbench {

/**
 * A Taint indicates whether something has gone wrong. It may also
 * contain a textual reason.
 **/
class Taint
{
private:
    bool   _taint;
    string _reason;

public:
    Taint() : _taint(false), _reason() {}
    Taint(const string &r) : _taint(true), _reason(r) {}
    void reset() { _taint = false; _reason.clear(); }
    void reset(const string &r) { _taint = true; _reason = r; }
    bool taint() const { return _taint; }
    const string &reason() const { return _reason; }
    operator bool() const { return taint(); }
};

} // namespace vbench