Jpp  17.2.1-pre0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JROOT/JCounter.hh
Go to the documentation of this file.
1 #ifndef __JROOT__JCOUNTER__
2 #define __JROOT__JCOUNTER__
3 
4 #include <limits>
5 
6 #include "Rtypes.h"
7 
8 
9 /**
10  * \file
11  *
12  * Type definition for counter for ROOT TTree and auxiliary methods.
13  * \author mdejong
14  */
15 namespace JROOT {}
16 namespace JPP { using namespace JROOT; }
17 
18 namespace JROOT {
19 
20 
21  /**
22  * Type definition for counter.
23  */
24  typedef Long64_t counter_type;
25 
26 
27  /**
28  * Advance counter.
29  *
30  * \param counter counter (I/O)
31  * \param value offset
32  * \param limit limit
33  * \return increment
34  */
36  const counter_type value,
37  const counter_type limit = std::numeric_limits<counter_type>::max())
38  {
39  const counter_type previous = counter;
40 
41  if (counter + value < limit)
42  counter += value;
43  else
44  counter = limit;
45 
46  return counter - previous;
47  }
48 }
49 
50 #endif
Long64_t counter_type
Type definition for counter.
counter_type advance(counter_type &counter, const counter_type value, const counter_type limit=std::numeric_limits< counter_type >::max())
Advance counter.