All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NonRandomCounter.cxx
Go to the documentation of this file.
1 /**
2  * @file icarusalg/Utilities/NonRandomCounter.cxx
3  * @brief Non-random number engine for profiling purposes (implementation).
4  * @author Gianluca Petrillo (petrillo@slac.stanford.edu)
5  * @date January 28, 2020
6  * @see `icarusalg/Utilities/NonRandomCounter.h`
7  *
8  */
9 
10 // library header
12 
13 // C/C++ standard library
14 #include <fstream>
15 #include <iostream> // std::cout
16 
17 
18 // -----------------------------------------------------------------------------
20  (const char filename[] /* = "NonRandomCounter.conf" */) const
21 {
22  std::ofstream f { filename };
23  if (!f) return; // shouldn't we complain? HepJamesRandom does not
24 
25  f << count;
26 
27 } // util::NonRandomCounter::saveStatus()
28 
29 
30 // -----------------------------------------------------------------------------
32  (const char filename[] /* = "NonRandomCounter.conf" */)
33 {
34  std::ifstream f { filename };
35  if (!f) return; // shouldn't we complain? HepJamesRandom does not
36 
37  f >> count;
38 
39 } // util::NonRandomCounter::restoreStatus()
40 
41 
42 // -----------------------------------------------------------------------------
44  std::cout << "Counter: " << count << std::endl;
45 }
46 
47 
48 // -----------------------------------------------------------------------------
virtual void saveStatus(const char filename[]="NonRandomCounter.conf") const override
Non-random number engine for profiling purposes.
BEGIN_PROLOG could also be dds filename
virtual void showStatus() const override
virtual void restoreStatus(const char filename[]="NonRandomCounter.conf") override
std::size_t count(Cont const &cont)
BEGIN_PROLOG could also be cout