ProteoWizard
Public Types | Public Member Functions | Private Attributes | List of all members
msclr::pinned_gcroot< T > Struct Template Reference

pinned_gcroot: a slightly modified gcroot that pins its GCHandle More...

#include <pinned_gcroot.h>

Public Types

typedef System::Runtime::InteropServices::GCHandle GCHandle
 
typedef System::Runtime::InteropServices::GCHandleType GCHandleType
 

Public Member Functions

 pinned_gcroot ()
 
 pinned_gcroot (T t)
 
 pinned_gcroot (const pinned_gcroot &r)
 
 ~pinned_gcroot ()
 
pinned_gcrootoperator= (T t)
 
pinned_gcrootoperator= (const pinned_gcroot &r)
 
void swap (pinned_gcroot< T > &_right)
 
 operator T () const
 
operator-> () const
 
System::IntPtr operator & () const
 
void * handle () const
 

Private Attributes

void * _handle
 

Detailed Description

template<class T>
struct msclr::pinned_gcroot< T >

pinned_gcroot: a slightly modified gcroot that pins its GCHandle

Definition at line 31 of file pinned_gcroot.h.

Member Typedef Documentation

◆ GCHandle

template<class T>
typedef System::Runtime::InteropServices::GCHandle msclr::pinned_gcroot< T >::GCHandle

Definition at line 33 of file pinned_gcroot.h.

◆ GCHandleType

template<class T>
typedef System::Runtime::InteropServices::GCHandleType msclr::pinned_gcroot< T >::GCHandleType

Definition at line 34 of file pinned_gcroot.h.

Constructor & Destructor Documentation

◆ pinned_gcroot() [1/3]

template<class T>
msclr::pinned_gcroot< T >::pinned_gcroot ( )
inline

Definition at line 41 of file pinned_gcroot.h.

References __GCHANDLE_TO_VOIDPTR, __NULLPTR, and msclr::pinned_gcroot< T >::_handle.

41  {
42  _handle = __GCHANDLE_TO_VOIDPTR(GCHandle::Alloc(__NULLPTR, GCHandleType::Pinned));
43  }
#define __GCHANDLE_TO_VOIDPTR(x)
Definition: pinned_gcroot.h:20
#define __NULLPTR
Definition: pinned_gcroot.h:22

◆ pinned_gcroot() [2/3]

template<class T>
msclr::pinned_gcroot< T >::pinned_gcroot ( t)
inline

Definition at line 48 of file pinned_gcroot.h.

References __GCHANDLE_TO_VOIDPTR, and msclr::pinned_gcroot< T >::_handle.

48  {
49  _handle = __GCHANDLE_TO_VOIDPTR(GCHandle::Alloc(t, GCHandleType::Pinned));
50  }
#define __GCHANDLE_TO_VOIDPTR(x)
Definition: pinned_gcroot.h:20

◆ pinned_gcroot() [3/3]

template<class T>
msclr::pinned_gcroot< T >::pinned_gcroot ( const pinned_gcroot< T > &  r)
inline

Definition at line 52 of file pinned_gcroot.h.

References __GCHANDLE_TO_VOIDPTR, __VOIDPTR_TO_GCHANDLE, and msclr::pinned_gcroot< T >::_handle.

52  {
53  // don't copy a handle, copy what it points to (see above)
55  GCHandle::Alloc(
56  __VOIDPTR_TO_GCHANDLE(r._handle).Target, GCHandleType::Pinned));
57  }
#define __GCHANDLE_TO_VOIDPTR(x)
Definition: pinned_gcroot.h:20
#define __VOIDPTR_TO_GCHANDLE(x)
Definition: pinned_gcroot.h:21

◆ ~pinned_gcroot()

template<class T>
msclr::pinned_gcroot< T >::~pinned_gcroot ( )
inline

Definition at line 64 of file pinned_gcroot.h.

References __VOIDPTR_TO_GCHANDLE, and msclr::pinned_gcroot< T >::_handle.

64  {
66  g.Free();
67  _handle = 0; // should fail if reconstituted
68  }
System::Runtime::InteropServices::GCHandle GCHandle
Definition: pinned_gcroot.h:33
#define __VOIDPTR_TO_GCHANDLE(x)
Definition: pinned_gcroot.h:21

Member Function Documentation

◆ operator=() [1/2]

template<class T>
pinned_gcroot& msclr::pinned_gcroot< T >::operator= ( t)
inline

Definition at line 72 of file pinned_gcroot.h.

References __VOIDPTR_TO_GCHANDLE, and msclr::pinned_gcroot< T >::_handle.

72  {
73  // no need to check for valid handle; was allocated in ctor
74  __VOIDPTR_TO_GCHANDLE(_handle).Target = t;
75  return *this;
76  }
#define __VOIDPTR_TO_GCHANDLE(x)
Definition: pinned_gcroot.h:21

◆ operator=() [2/2]

template<class T>
pinned_gcroot& msclr::pinned_gcroot< T >::operator= ( const pinned_gcroot< T > &  r)
inline

Definition at line 78 of file pinned_gcroot.h.

References __VOIDPTR_TO_GCHANDLE, and msclr::pinned_gcroot< T >::_handle.

78  {
79  // no need to check for valid handle; was allocated in ctor
80  T t = (T)r;
81  __VOIDPTR_TO_GCHANDLE(_handle).Target = t;
82  return *this;
83  }
#define __VOIDPTR_TO_GCHANDLE(x)
Definition: pinned_gcroot.h:21

◆ swap()

template<class T>
void msclr::pinned_gcroot< T >::swap ( pinned_gcroot< T > &  _right)
inline

Definition at line 85 of file pinned_gcroot.h.

References msclr::pinned_gcroot< T >::_handle, and msclr::swap().

Referenced by msclr::swap().

86  {
87  using std::swap;
88  swap(_handle, _right._handle);
89  }
void swap(pinned_gcroot< T > &_left, pinned_gcroot< T > &_right)
void swap(pinned_gcroot< T > &_right)
Definition: pinned_gcroot.h:85

◆ operator T()

template<class T>
msclr::pinned_gcroot< T >::operator T ( ) const
inline

Definition at line 93 of file pinned_gcroot.h.

References __VOIDPTR_TO_GCHANDLE, and msclr::pinned_gcroot< T >::_handle.

93  {
94  // gcroot is typesafe, so use static_cast
95  return static_cast<T>(__VOIDPTR_TO_GCHANDLE(_handle).Target);
96  }
#define __VOIDPTR_TO_GCHANDLE(x)
Definition: pinned_gcroot.h:21

◆ operator->()

template<class T>
T msclr::pinned_gcroot< T >::operator-> ( ) const
inline

Definition at line 101 of file pinned_gcroot.h.

References __VOIDPTR_TO_GCHANDLE, and msclr::pinned_gcroot< T >::_handle.

101  {
102  // gcroot is typesafe, so use static_cast
103  return static_cast<T>(__VOIDPTR_TO_GCHANDLE(_handle).Target);
104  }
#define __VOIDPTR_TO_GCHANDLE(x)
Definition: pinned_gcroot.h:21

◆ operator &()

template<class T>
System::IntPtr msclr::pinned_gcroot< T >::operator& ( ) const
inline

Definition at line 106 of file pinned_gcroot.h.

References __VOIDPTR_TO_GCHANDLE, and msclr::pinned_gcroot< T >::_handle.

106  {
107  return __VOIDPTR_TO_GCHANDLE(_handle).AddrOfPinnedObject();
108  }
#define __VOIDPTR_TO_GCHANDLE(x)
Definition: pinned_gcroot.h:21

◆ handle()

template<class T>
void* msclr::pinned_gcroot< T >::handle ( ) const
inline

Definition at line 110 of file pinned_gcroot.h.

References msclr::pinned_gcroot< T >::_handle.

110  {
111  return _handle;
112  }

Member Data Documentation

◆ _handle

template<class T>
void* msclr::pinned_gcroot< T >::_handle
private

The documentation for this struct was generated from the following file: