LCOV - code coverage report
Current view: top level - data - Progress.cpp (source / functions) Hit Total Coverage
Test: Lexis Lines: 24 24 100.0 %
Date: 2017-10-26 03:19:55 Functions: 5 5 100.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2016, Human Brain Project
       3             :  *                     Stefan.Eilemann@epfl.ch
       4             :  */
       5             : 
       6             : #include "Progress.h"
       7             : 
       8             : namespace lexis
       9             : {
      10             : namespace data
      11             : {
      12           4 : Progress::Progress( const unsigned long expected )
      13             :     : _expected( expected )
      14           4 :     , _count( 0 )
      15             : {
      16           4 :     _update();
      17           4 : }
      18             : 
      19           1 : Progress::Progress( const std::string& operation, const unsigned long expected )
      20             :     : detail::Progress( operation, 0.f )
      21             :     , _expected( expected )
      22           1 :     , _count( 0 )
      23             : {
      24           1 :     _update();
      25           1 : }
      26             : 
      27           1 : void Progress::restart( const unsigned long expected )
      28             : {
      29           1 :     _expected = expected;
      30           1 :     _count = 0;
      31           1 :     _update();
      32           1 : }
      33             : 
      34           5 : unsigned long Progress::operator+=( const unsigned long inc )
      35             : {
      36           5 :     _count += inc;
      37           5 :     return _update();
      38             : }
      39             : 
      40          11 : unsigned long Progress::_update()
      41             : {
      42          11 :     _count = std::min( _count, _expected );
      43          21 :     const float amount = _expected == 0 ? 1.f :
      44          21 :                          float( _count ) / float( _expected );
      45          11 :     if( amount == getAmount( ))
      46           4 :         return _count;
      47             : 
      48           7 :     setAmount( amount );
      49           7 :     return _count;
      50             : }
      51             : 
      52             : }
      53             : }

Generated by: LCOV version 1.11