2 ** Windstille - A Sci-Fi Action-Adventure Game
3 ** Copyright (C) 2009 Ingo Ruhnke <grumbel@gmx.de>
5 ** This program is free software: you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License as published by
7 ** the Free Software Foundation, either version 3 of the License, or
8 ** (at your option) any later version.
10 ** This program is distributed in the hope that it will be useful,
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ** GNU General Public License for more details.
15 ** You should have received a copy of the GNU General Public License
16 ** along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef HEADER_WINDSTILLE_UTIL_CURRENTON_HPP
20 #define HEADER_WINDSTILLE_UTIL_CURRENTON_HPP
25 * A 'Currenton' allows access to the currently active instance of a
26 * class via the static current() function. It is kind of like a
27 * singleton, but without handling the object construction itself or
28 * in other words its a glorified global variable that points to the
29 * current instance of a class.
40 // FIXME: temporarly disabled, as Sector() for the main menu,
41 // doesn't get cleaned up before a real Sector() starts
42 // assert(!s_current);
43 s_current = static_cast<C*>(this);
52 static C* current() { return s_current; }
55 template<class C> C* Currenton<C>::s_current = 0;