a template based object counter class