GenApi 3.5.1
Counter.h
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
2// (c) 2006 by Basler Vision Technologies
3// Author: Alexander Happe
4//
5// License: This file is published under the license of the EMVA GenICam Standard Group.
6// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'.
7// If for some reason you are missing this file please contact the EMVA or visit the website
8// (http://www.genicam.org) for a full copy.
9//
10// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS"
11// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
12// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
13// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP
14// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
15// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
16// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
17// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
18// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
19// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
20// POSSIBILITY OF SUCH DAMAGE.
21//
22//-----------------------------------------------------------------------------
29#ifndef GENAPI_COUNTER_H
30#define GENAPI_COUNTER_H
31
32namespace GENAPI_NAMESPACE {
33
34 class Counter
35 {
36 public:
37 Counter() : m_value(0)
38 {
39 }
40
41 unsigned int GetValue() const
42 { return m_value; }
43
44 unsigned int operator++() // prefix
45 {
46 return ++m_value;
47 }
48
49 unsigned int operator++(int) // postfix
50 {
51 return m_value++;
52 }
53
54 unsigned int operator--(int) // postfix
55 {
56 assert( m_value > 0);
57 return m_value--;
58 }
59
60 unsigned int operator--() // prefix
61 {
62 assert( m_value > 0);
63 return --m_value;
64 }
65
66 operator unsigned int()
67 {
68 return m_value;
69 }
70
71 bool IsZero()
72 {
73 return m_value == 0;
74 }
75
76 private:
77 unsigned int m_value;
78 };
79}
80
81#endif // GENAPI_COUNTER_H
82