Imported Upstream version 14.45.0
[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 _IntT>
28     class Counter
29     {
30     public:
31       Counter( _IntT value_r = _IntT(0) )
32       : _value( _IntT( value_r ) )
33       {}
34
35       operator _IntT &()
36       { return _value; }
37
38       operator const _IntT &() const
39       { return _value; }
40
41     public:
42       _IntT _value;
43     };
44   ///////////////////////////////////////////////////////////////////
45
46   /////////////////////////////////////////////////////////////////
47 } // namespace zypp
48 ///////////////////////////////////////////////////////////////////
49 #endif // ZYPP_BASE_COUNTER_H