1 //===-- Statistic.h ---------------------------------------------*- C++ -*-===// 2 // 3 // The KLEE Symbolic Virtual Machine 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef KLEE_STATISTIC_H 11 #define KLEE_STATISTIC_H 12 13 #include <string> 14 15 namespace klee { 16 class Statistic; 17 class StatisticManager; 18 class StatisticRecord; 19 20 /// Statistic - A named statistic instance. 21 /// 22 /// The Statistic class holds information about the statistic, but 23 /// not the actual values. Values are managed by the global 24 /// StatisticManager to enable transparent support for instruction 25 /// level and call path level statistics. 26 class Statistic final { 27 friend class StatisticManager; 28 friend class StatisticRecord; 29 30 private: 31 std::uint32_t id; 32 const std::string name; 33 const std::string shortName; 34 35 public: 36 Statistic(const std::string &name, const std::string &shortName); 37 ~Statistic() = default; 38 39 /// getID - Get the unique statistic ID. getID()40 std::uint32_t getID() const { return id; } 41 42 /// getName - Get the statistic name. getName()43 const std::string &getName() const { return name; } 44 45 /// getShortName - Get the "short" statistic name, used in 46 /// callgrind output for example. getShortName()47 const std::string &getShortName() const { return shortName; } 48 49 /// getValue - Get the current primary statistic value. 50 std::uint64_t getValue() const; 51 52 /// operator std::uint64_t - Get the current primary statistic value. uint64_t()53 operator std::uint64_t() const { return getValue(); } 54 55 /// operator++ - Increment the statistic by 1. 56 Statistic &operator++() { return (*this += 1); } 57 58 /// operator+= - Increment the statistic by \arg addend. 59 Statistic &operator+=(std::uint64_t addend); 60 }; 61 } 62 63 #endif /* KLEE_STATISTIC_H */ 64