Sleeping Wombat GUI  0.100
swGUI
UPtr.h
Go to the documentation of this file.
1 #pragma once
2 
9 template< typename WrappedType >
10 class UPtr
11 {
12 private:
13  WrappedType* m_ptr;
14 
15 public:
16  UPtr()
17  : m_ptr( nullptr )
18  {}
19 
20  UPtr( WrappedType* ptr )
21  : m_ptr( ptr )
22  {}
23 
25  { ReleaseResource(); }
26 
27  UPtr( const UPtr< WrappedType >& other ) = delete;
29  {
30  if( this != &other)
31  {
32  m_resource = other.m_resource;
33  other.m_resource = nullptr;
34  }
35  }
36 
37 
38  void operator=( const UPtr< WrappedType >& other ) = delete;
39 
41  {
43 
44  m_ptr = other.m_ptr;
45  other.m_ptr = nullptr;
46  }
47 
48 
49 
50 
52  {
53  if( m_ptr )
54  delete m_ptr;
55  m_ptr = nullptr;
56  }
57 
58  void AssignPointer( WrappedType* ptr )
59  {
60  m_ptr = ptr;
61  }
62 };
Definition: UPtr.h:10
UPtr(WrappedType *ptr)
Definition: UPtr.h:20
UPtr(UPtr< WrappedType > &&other)
Definition: UPtr.h:28
WrappedType * m_ptr
Definition: UPtr.h:13
~UPtr()
Definition: UPtr.h:24
void operator=(UPtr< WrappedType > &&other)
Definition: UPtr.h:40
void AssignPointer(WrappedType *ptr)
Definition: UPtr.h:58
void ReleaseResource()
Definition: UPtr.h:51
UPtr()
Definition: UPtr.h:16
void operator=(const UPtr< WrappedType > &other)=delete