w11 - cpp 0.794
Backend server for Rlink and w11
Loading...
Searching...
No Matches
Rstats.hpp
Go to the documentation of this file.
1// $Id: Rstats.hpp 1186 2019-07-12 17:49:59Z mueller $
2// SPDX-License-Identifier: GPL-3.0-or-later
3// Copyright 2011-2019 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4//
5// Revision History:
6// Date Rev Version Comment
7// 2019-06-07 1160 1.0.3 add Reset(); drop operator-=() and operator*=()
8// 2017-02-04 865 1.0.2 add NameMaxLength(); Dump(): add detail arg
9// 2017-02-18 851 1.0.1 add IncLogHist; fix + and * operator definition
10// 2011-02-06 359 1.0 Initial version
11// ---------------------------------------------------------------------------
12
17#ifndef included_Retro_Rstats
18#define included_Retro_Rstats 1
19
20#include <cstddef>
21#include <cstdint>
22#include <string>
23#include <vector>
24#include <ostream>
25
26namespace Retro {
27
28 class Rstats {
29 public:
30 Rstats();
31 Rstats(const Rstats& rhs);
32 ~Rstats();
33
34 void Define(size_t ind, const std::string& name,
35 const std::string& text);
36
37 void Set(size_t ind, double val);
38 void Inc(size_t ind, double val=1.);
39
40 void Reset();
41
42 void IncLogHist(size_t ind, size_t maskfirst,
43 size_t masklast, size_t val);
44
45 void SetFormat(const char* format, int width=0, int prec=0);
46
47 size_t Size() const;
48 double Value(size_t ind) const;
49 const std::string& Name(size_t ind) const;
50 const std::string& Text(size_t ind) const;
51 size_t NameMaxLength() const;
52
53 void Print(std::ostream& os, const char* format=0,
54 int width=0, int prec=0) const;
55 void Dump(std::ostream& os, int ind=0, const char* text=0,
56 int detail=0) const;
57
58 double operator[](size_t ind) const;
59
60 Rstats& operator=(const Rstats& rhs);
61
62 private:
63 std::vector<double> fValue;
64 std::vector<std::string> fName;
65 std::vector<std::string> fText;
66 std::uint32_t fHash;
67 std::string fFormat;
68 int fWidth;
69 int fPrec;
70 };
71
72 std::ostream& operator<<(std::ostream& os, const Rstats& obj);
73
74} // end namespace Retro
75
76#include "Rstats.ipp"
77
78#endif
FIXME_docs.
Definition: Rstats.hpp:28
std::vector< std::string > fText
counter text
Definition: Rstats.hpp:65
std::vector< std::string > fName
counter name
Definition: Rstats.hpp:64
void SetFormat(const char *format, int width=0, int prec=0)
FIXME_docs.
Definition: Rstats.cpp:134
size_t Size() const
FIXME_docs.
Definition: Rstats.ipp:38
void IncLogHist(size_t ind, size_t maskfirst, size_t masklast, size_t val)
FIXME_docs.
Definition: Rstats.cpp:114
void Dump(std::ostream &os, int ind=0, const char *text=0, int detail=0) const
FIXME_docs.
Definition: Rstats.cpp:178
int fPrec
default precision for Print
Definition: Rstats.hpp:69
~Rstats()
Destructor.
Definition: Rstats.cpp:66
void Inc(size_t ind, double val=1.)
FIXME_docs.
Definition: Rstats.ipp:29
void Print(std::ostream &os, const char *format=0, int width=0, int prec=0) const
FIXME_docs.
Definition: Rstats.cpp:157
size_t NameMaxLength() const
FIXME_docs.
Definition: Rstats.cpp:144
void Set(size_t ind, double val)
FIXME_docs.
Definition: Rstats.ipp:20
std::string fFormat
default format for Print
Definition: Rstats.hpp:67
std::vector< double > fValue
counter value
Definition: Rstats.hpp:63
void Define(size_t ind, const std::string &name, const std::string &text)
FIXME_docs.
Definition: Rstats.cpp:72
std::uint32_t fHash
hash value for name+text
Definition: Rstats.hpp:66
double operator[](size_t ind) const
FIXME_docs.
Definition: Rstats.ipp:70
const std::string & Name(size_t ind) const
FIXME_docs.
Definition: Rstats.ipp:54
double Value(size_t ind) const
FIXME_docs.
Definition: Rstats.ipp:46
const std::string & Text(size_t ind) const
FIXME_docs.
Definition: Rstats.ipp:62
Rstats()
Default constructor.
Definition: Rstats.cpp:41
Rstats & operator=(const Rstats &rhs)
FIXME_docs.
Definition: Rstats.cpp:208
int fWidth
default width for Print
Definition: Rstats.hpp:68
void Reset()
FIXME_docs.
Definition: Rstats.cpp:105
Declaration of class ReventLoop.
Definition: ReventLoop.cpp:47
std::ostream & operator<<(std::ostream &os, const RerrMsg &obj)