From 046f71e1a2486868711836ad4083bbdff1c84afd Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <dmitri.naumov@ufz.de> Date: Wed, 27 Feb 2013 15:50:37 +0100 Subject: [PATCH] Add Counter struct. This can be used for counting of meshes or other object instantiations etc. --- BaseLib/Counter.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 BaseLib/Counter.h diff --git a/BaseLib/Counter.h b/BaseLib/Counter.h new file mode 100644 index 00000000000..3c9c30a5da2 --- /dev/null +++ b/BaseLib/Counter.h @@ -0,0 +1,31 @@ +/** + * \copyright + * Copyright (c) 2013, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + */ + +#ifndef BASELIB_GLOBALCOUNTER_H +#define BASELIB_GLOBALCOUNTER_H + +#include <cstddef> + +namespace BaseLib +{ +template <typename X> +struct Counter +{ + Counter() + { + _counter_value++; + } + static std::size_t _counter_value; +}; + +template <typename X> std::size_t Counter<X>::_counter_value(0); + +} // end namespace BaseLib + +#endif // BASELIB_GLOBALCOUNTER_H -- GitLab