Imported Upstream version 16.3.2
[platform/upstream/libzypp.git] / zypp / base / Counter.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/base/Counter.h
10  *
11 */
12 #ifndef ZYPP_BASE_COUNTER_H
13 #define ZYPP_BASE_COUNTER_H
14
15 #include <iosfwd>
16
17 ///////////////////////////////////////////////////////////////////
18 namespace zypp
19 { /////////////////////////////////////////////////////////////////
20
21   ///////////////////////////////////////////////////////////////////
22   //
23   //    CLASS NAME : Counter
24   //
25   /** Integral type with initial value \c 0.
26   */
27   template<class TInt>
28     class Counter
29     {
30     public:
31       Counter( TInt value_r = TInt(0) )
32       : _value( TInt( value_r ) )
33       {}
34
35       operator TInt &()
36       { return _value; }
37
38       operator const TInt &() const
39       { return _value; }
40
41     public:
42       TInt _value;
43     };
44   ///////////////////////////////////////////////////////////////////
45
46   /////////////////////////////////////////////////////////////////
47 } // namespace zypp
48 ///////////////////////////////////////////////////////////////////
49 #endif // ZYPP_BASE_COUNTER_H