SingletonPointer.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "Singleton.h"
5 
6 
7 namespace ion
8 {
9 
12  template <class T>
14  {
15 
16  public:
17 
19  {
20  return GetReference();
21  }
22 
23  T * Get()
24  {
25  return GetReference();
26  }
27 
28  operator T*()
29  {
30  return GetReference();
31  }
32 
33  T const * operator ->() const
34  {
35  return GetReference();
36  }
37 
38  T const * Get() const
39  {
40  return GetReference();
41  }
42 
43  operator T const *() const
44  {
45  return GetReference();
46  }
47 
48  private:
49 
50  mutable T * Reference = 0;
51 
52  T * GetReference()
53  {
54  if (! Reference)
55  Reference = T::GetPointer();
56  return Reference;
57  }
58 
59  T const * GetReference() const
60  {
61  if (! Reference)
62  Reference = T::GetPointer();
63  return Reference;
64  }
65 
66  };
67 
68 }
T const * Get() const
Definition: SingletonPointer.h:38
Wraps a pointer to a singleton object.
Definition: SingletonPointer.h:13
T * operator->()
Definition: SingletonPointer.h:18
Definition: CCatmullRomAdvancedSplineInterpolator.h:7
T * Get()
Definition: SingletonPointer.h:23