CXXR (C++ R) API
SchwarzCounter.hpp
Go to the documentation of this file.
1 /*CXXR $Id: SchwarzCounter.hpp 1351 2013-03-08 15:12:28Z arr $
2  *CXXR
3  *CXXR This file is part of CXXR, a project to refactor the R interpreter
4  *CXXR into C++. It may consist in whole or in part of program code and
5  *CXXR documentation taken from the R project itself, incorporated into
6  *CXXR CXXR (and possibly MODIFIED) under the terms of the GNU General Public
7  *CXXR Licence.
8  *CXXR
9  *CXXR CXXR is Copyright (C) 2008-13 Andrew R. Runnalls, subject to such other
10  *CXXR copyrights and copyright restrictions as may be stated below.
11  *CXXR
12  *CXXR CXXR is not part of the R project, and bugs and other issues should
13  *CXXR not be reported via r-bugs or other R project channels; instead refer
14  *CXXR to the CXXR website.
15  *CXXR */
16 
22 #ifndef SCHWARZCOUNTER_HPP
23 #define SCHWARZCOUNTER_HPP
24 
25 namespace CXXR {
66  template <class T> class SchwarzCounter {
67  public:
69  {
70  if (!s_count++) T::initialize();
71  }
72 
74  {
75  if (!--s_count) T::cleanup();
76  }
77  private:
78  static unsigned int s_count;
79  };
80 
81  template <class T> unsigned int SchwarzCounter<T>::s_count = 0;
82 }
83 
84 #endif // SCHWARZCOUNTER_HPP