1#!/usr/bin/env python 2# -*- coding: utf-8 -*- 3 4# 5# Copyright 2017, Data61 6# Commonwealth Scientific and Industrial Research Organisation (CSIRO) 7# ABN 41 687 119 230. 8# 9# This software may be distributed and modified according to the terms of 10# the BSD 2-Clause license. Note that NO WARRANTY is provided. 11# See "LICENSE_BSD2.txt" for details. 12# 13# @TAG(DATA61_BSD) 14# 15 16''' 17An object representation of an integer. This is frustratingly necessary for 18expressing things like a counter in a Jinja template that can be modified 19within a loop. 20''' 21 22from __future__ import absolute_import, division, print_function, \ 23 unicode_literals 24from camkes.internal.seven import cmp, filter, map, zip 25 26class Counter(object): 27 def __init__(self): 28 self.value = 0 29 30 def set(self, value): 31 self.value = value 32 33 def __repr__(self): 34 return str(self.value) 35 36 def increment(self, offset=1): 37 self.value += offset 38 39 def decrement(self, offset=1): 40 self.value -= offset 41