src/util/currenton.hpp

Go to the documentation of this file.
00001 /*
00002 **  Windstille - A Sci-Fi Action-Adventure Game
00003 **  Copyright (C) 2009 Ingo Ruhnke <grumbel@gmx.de>
00004 **
00005 **  This program is free software: you can redistribute it and/or modify
00006 **  it under the terms of the GNU General Public License as published by
00007 **  the Free Software Foundation, either version 3 of the License, or
00008 **  (at your option) any later version.
00009 **  
00010 **  This program is distributed in the hope that it will be useful,
00011 **  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 **  GNU General Public License for more details.
00014 **  
00015 **  You should have received a copy of the GNU General Public License
00016 **  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017 */
00018 
00019 #ifndef HEADER_WINDSTILLE_UTIL_CURRENTON_HPP
00020 #define HEADER_WINDSTILLE_UTIL_CURRENTON_HPP
00021 
00022 #include <assert.h>
00023 
00031 template<class C>
00032 class Currenton
00033 {
00034 private:
00035   static C* s_current; 
00036 
00037 protected:
00038   Currenton()  
00039   { 
00040     // FIXME: temporarly disabled, as Sector() for the main menu,
00041     // doesn't get cleaned up before a real Sector() starts
00042     // assert(!s_current); 
00043     s_current = static_cast<C*>(this); 
00044   }
00045 
00046   virtual ~Currenton()
00047   {
00048     s_current = 0; 
00049   }
00050   
00051 public:
00052   static C* current() { return s_current; }
00053 };
00054 
00055 template<class C> C* Currenton<C>::s_current = 0;
00056 
00057 #endif
00058 
00059 /* EOF */

Generated on Mon Jun 9 03:38:23 2014 for SuperTux by  doxygen 1.5.1