X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Ftimer.h;h=bd4e652f811cfe04d254e252f680973e5c2ed2c7;hp=9ea95c7203850f329b67178c3a3e5c9f5f73c822;hb=8f12e84009d7c2685bb2eeb32665876463d4e6e5;hpb=c6871fe8617b3de03662b7630355059393bf8043 diff --git a/src/lib/timer.h b/src/lib/timer.h index 9ea95c720..bd4e652f8 100644 --- a/src/lib/timer.h +++ b/src/lib/timer.h @@ -1,6 +1,6 @@ /* - Copyright (C) 2012 Carl Hetherington - Copyright (C) 2000-2007 Paul Davis + Copyright (C) 2012-2019 Carl Hetherington + This file is part of DCP-o-matic. DCP-o-matic is free software; you can redistribute it and/or modify @@ -26,6 +26,7 @@ #define DCPOMATIC_TIMER_H #include +#include #include #include @@ -59,20 +60,44 @@ private: class StateTimer { public: + explicit StateTimer (std::string n); StateTimer (std::string n, std::string s); ~StateTimer (); - void set_state (std::string s); + void set (std::string s); + void unset (); + + std::string name () const { + return _name; + } + + class Counts + { + public: + Counts () + : total_time (0) + , number (0) + {} + + double total_time; + int number; + }; + + std::map counts () const { + return _counts; + } private: + void set_internal (boost::optional s); + /** name to add to the output */ std::string _name; /** current state */ - std::string _state; + boost::optional _state; /** time that _state was entered */ double _time; - /** time that has been spent in each state so far */ - std::map _totals; + /** total time and number of entries for each state */ + std::map _counts; }; #endif