AQUAgpusph 4.1.2
Loading...
Searching...
No Matches
Singleton.h
Go to the documentation of this file.
1/*
2 * This file is part of AQUAgpusph, a free CFD program based on SPH.
3 * Copyright (C) 2012 Jose Luis Cercos Pita <jl.cercos@upm.es>
4 *
5 * AQUAgpusph 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.
9 *
10 * AQUAgpusph 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.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with AQUAgpusph. If not, see <http://www.gnu.org/licenses/>.
17 */
18
24#ifndef SINGLETON_H_INCLUDED
25#define SINGLETON_H_INCLUDED
26
27namespace Aqua {
28
55template<typename T>
57{
58 public:
62 static T* singleton() { return _singletonPtr; }
63
64 protected:
66 Singleton() { _singletonPtr = (T*)this; }
68 virtual ~Singleton() { _singletonPtr = NULL; }
69
70 private:
72 static T* _singletonPtr;
73};
74
76template<typename T>
77T* Singleton<T>::_singletonPtr = NULL;
78
79} // namespaces
80
81#endif // SINGLETON_H_INCLUDED
Simple but versatile singleton instance (Meyers singleton).
Definition: Singleton.h:57
static T * singleton()
Returns the instance of the class.
Definition: Singleton.h:62
virtual ~Singleton()
Destructor.
Definition: Singleton.h:68
Singleton()
Constructor.
Definition: Singleton.h:66
Main AQUAgpusph namespace.
Definition: ArgumentsManager.cpp:45