/*************************************************************************** * * * begin : 22 Nov 2003 * * copyright : (C) 2003 by Samokhvalov Anton :) * * * ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef __templates__h__809cvlkj #define __templates__h__809cvlkj #include #include template< class A > class StaticClass { public: static void initialize() { if ( !d_a ) { d_a = new A(); } } static void finalize() { if ( d_a ) { delete d_a; d_a = 0; } } static A* instance() { if ( d_a ) { return d_a; } else { throw FatalException( i18n("can not get static class instance") ); } } private: static A* d_a; }; template< class A > A* StaticClass::d_a = 0; #endif