~ubuntu-branches/ubuntu/hardy/codeblocks/hardy-backports

« back to all changes in this revision

Viewing changes to src/include/wxFlatNotebook/include/wx/wxFlatNotebook/fnb_singleton.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Casadevall
  • Date: 2008-07-17 04:39:23 UTC
  • Revision ID: james.westby@ubuntu.com-20080717043923-gmsy5cwkdjswghkm
Tags: upstream-8.02
ImportĀ upstreamĀ versionĀ 8.02

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef FNB_SINGLETON_H
 
2
#define FNB_SINGLETON_H
 
3
 
 
4
/**
 
5
 * A template class that implements the wxFNBSingleton pattern.
 
6
 *
 
7
 * \date 08-23-2006
 
8
 * \author eran
 
9
 */
 
10
template <typename T>
 
11
class wxFNBSingleton
 
12
{
 
13
        static T* ms_instance;
 
14
public:
 
15
        /**
 
16
         * Static method to access the only pointer of this instance.
 
17
         * \return a pointer to the only instance of this 
 
18
         */
 
19
        static T* Get();
 
20
 
 
21
        /**
 
22
         * Release resources.
 
23
         */
 
24
        static void Free();
 
25
 
 
26
protected:
 
27
        /**
 
28
         * Default constructor.
 
29
         */
 
30
        wxFNBSingleton();
 
31
 
 
32
        /**
 
33
         * Destructor.
 
34
         */
 
35
        virtual ~wxFNBSingleton();
 
36
};
 
37
template <typename T>
 
38
T* wxFNBSingleton<T>::ms_instance = 0;
 
39
 
 
40
template <typename T>
 
41
wxFNBSingleton<T>::wxFNBSingleton()
 
42
{
 
43
}
 
44
 
 
45
template <typename T>
 
46
wxFNBSingleton<T>::~wxFNBSingleton()
 
47
{
 
48
}
 
49
 
 
50
template <typename T>
 
51
T* wxFNBSingleton<T>::Get()
 
52
{
 
53
        if(!ms_instance)
 
54
                ms_instance = new T();
 
55
        return ms_instance;
 
56
}
 
57
 
 
58
template <typename T>
 
59
void wxFNBSingleton<T>::Free()
 
60
{
 
61
        if( ms_instance )
 
62
        {
 
63
                delete ms_instance;
 
64
                ms_instance = 0;
 
65
        }
 
66
}
 
67
 
 
68
#endif // FNB_SINGLETON_H