~efargaspro/+junk/codeblocks-16.01-release

« back to all changes in this revision

Viewing changes to src/plugins/contrib/wxContribItems/wxFlatNotebook/include/wx/wxFlatNotebook/fnb_singleton.h

  • Committer: damienlmoore at gmail
  • Date: 2016-02-02 02:43:22 UTC
  • Revision ID: damienlmoore@gmail.com-20160202024322-yql5qmtbwdyamdwd
Code::BlocksĀ 16.01

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
///////////////////////////////////////////////////////////////////////////////
 
2
// Name:                fnb_singleton.h 
 
3
// Purpose:     A template class that implements the wxFNBSingleton pattern.
 
4
// Author:      Eran Ifrah <erani.ifrah@gmail.com>
 
5
// Created:     30/12/2005
 
6
// Modified:    01/01/2006
 
7
// Copyright:   Eran Ifrah (c)
 
8
// Licence:     wxWindows license <http://www.wxwidgets.org/licence3.txt>
 
9
///////////////////////////////////////////////////////////////////////////////
 
10
#ifndef FNB_SINGLETON_H
 
11
#define FNB_SINGLETON_H
 
12
 
 
13
/**
 
14
 * A template class that implements the wxFNBSingleton pattern.
 
15
 *
 
16
 * \date 08-23-2006
 
17
 * \author eran
 
18
 */
 
19
template <typename T>
 
20
class wxFNBSingleton
 
21
{
 
22
        static T* ms_instance;
 
23
public:
 
24
        /**
 
25
         * Static method to access the only pointer of this instance.
 
26
         * \return a pointer to the only instance of this 
 
27
         */
 
28
        static T* Get();
 
29
 
 
30
        /**
 
31
         * Release resources.
 
32
         */
 
33
        static void Free();
 
34
 
 
35
protected:
 
36
        /**
 
37
         * Default constructor.
 
38
         */
 
39
        wxFNBSingleton();
 
40
 
 
41
        /**
 
42
         * Destructor.
 
43
         */
 
44
        virtual ~wxFNBSingleton();
 
45
};
 
46
template <typename T>
 
47
T* wxFNBSingleton<T>::ms_instance = 0;
 
48
 
 
49
template <typename T>
 
50
wxFNBSingleton<T>::wxFNBSingleton()
 
51
{
 
52
}
 
53
 
 
54
template <typename T>
 
55
wxFNBSingleton<T>::~wxFNBSingleton()
 
56
{
 
57
}
 
58
 
 
59
template <typename T>
 
60
T* wxFNBSingleton<T>::Get()
 
61
{
 
62
        if(!ms_instance)
 
63
                ms_instance = new T();
 
64
        return ms_instance;
 
65
}
 
66
 
 
67
template <typename T>
 
68
void wxFNBSingleton<T>::Free()
 
69
{
 
70
        if( ms_instance )
 
71
        {
 
72
                delete ms_instance;
 
73
                ms_instance = 0;
 
74
        }
 
75
}
 
76
 
 
77
#endif // FNB_SINGLETON_H