00001 /* 00002 * The Mana World Server 00003 * Copyright 2004 The Mana World Development Team 00004 * 00005 * This file is part of The Mana World. 00006 * 00007 * The Mana World is free software; you can redistribute it and/or modify it 00008 * under the terms of the GNU General Public License as published by the Free 00009 * Software Foundation; either version 2 of the License, or any later version. 00010 * 00011 * The Mana World is distributed in the hope that it will be useful, but 00012 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 00013 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 00014 * more details. 00015 * 00016 * You should have received a copy of the GNU General Public License along 00017 * with The Mana World; if not, write to the Free Software Foundation, Inc., 00018 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 */ 00020 00021 #ifndef _TMWSERV_SINGLETON_H_ 00022 #define _TMWSERV_SINGLETON_H_ 00023 00024 namespace utils 00025 { 00026 00027 00031 template <typename T> 00032 class Singleton 00033 { 00034 public: 00040 static T& 00041 instance(void) 00042 { 00043 static T theInstance; 00044 00045 return theInstance; 00046 } 00047 00048 00049 protected: 00053 Singleton(void) 00054 throw() 00055 { 00056 // NOOP 00057 } 00058 00059 00063 virtual 00064 ~Singleton(void) 00065 throw() 00066 { 00067 // NOOP 00068 } 00069 00070 00071 private: 00075 Singleton(const Singleton& rhs); 00076 00077 00081 Singleton& 00082 operator=(const Singleton& rhs); 00083 }; 00084 00085 00086 } // namespace utils 00087 00088 #endif // _TMWSERV_SINGLETON_H_