00001 /* 00002 * (c) 2005, 2008 Nico Pranke <Nico.Pranke@googlemail.com>, Robin Luedtke <RobinLu@gmx.de> 00003 * 00004 * This file is part of avcap. 00005 * 00006 * avcap is free software: you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation, either version 3 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * avcap is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with avcap. If not, see <http://www.gnu.org/licenses/>. 00018 */ 00019 00020 /* avcap is free for non-commercial use. 00021 * To use it in commercial endeavors, please contact Nico Pranke <Nico.Pranke@googlemail.com> 00022 */ 00023 00024 #ifndef SINGLETON_H_ 00025 #define SINGLETON_H_ 00026 00027 00028 00029 namespace avcap 00030 { 00032 00035 template <class T> 00036 class Singleton 00037 { 00038 public: 00039 00041 static T& instance() 00042 { 00043 static T _instance; 00044 return _instance; 00045 } 00046 00047 private: 00048 00049 Singleton(); // ctor hidden 00050 ~Singleton(); // dtor hidden 00051 Singleton(Singleton const&); // copy ctor hidden 00052 Singleton& operator=(Singleton const&); // assign op hidden 00053 }; 00054 } 00055 00056 #endif // SINGLETON_H_ 00057