about summary refs log tree commit diff homepage
path: root/include/klee/Statistics/Statistic.h
blob: bbb67116db0f3301c7100888b2708ead213c18fc (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//===-- Statistic.h ---------------------------------------------*- C++ -*-===//
//
//                     The KLEE Symbolic Virtual Machine
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef KLEE_STATISTIC_H
#define KLEE_STATISTIC_H

#include <string>

namespace klee {
  class Statistic;
  class StatisticManager;
  class StatisticRecord;

  /// Statistic - A named statistic instance.
  ///
  /// The Statistic class holds information about the statistic, but
  /// not the actual values. Values are managed by the global
  /// StatisticManager to enable transparent support for instruction
  /// level and call path level statistics.
  class Statistic final {
    friend class StatisticManager;
    friend class StatisticRecord;

  private:
    std::uint32_t id;
    const std::string name;
    const std::string shortName;

  public:
    Statistic(const std::string &name, const std::string &shortName);
    ~Statistic() = default;

    /// getID - Get the unique statistic ID.
    std::uint32_t getID() const { return id; }

    /// getName - Get the statistic name.
    const std::string &getName() const { return name; }

    /// getShortName - Get the "short" statistic name, used in
    /// callgrind output for example.
    const std::string &getShortName() const { return shortName; }

    /// getValue - Get the current primary statistic value.
    std::uint64_t getValue() const;

    /// operator std::uint64_t - Get the current primary statistic value.
    operator std::uint64_t() const { return getValue(); }

    /// operator++ - Increment the statistic by 1.
    Statistic &operator++() { return (*this += 1); }

    /// operator+= - Increment the statistic by \arg addend.
    Statistic &operator+=(std::uint64_t addend);
  };
}

#endif /* KLEE_STATISTIC_H */