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.

41 {
42 _handle = __GCHANDLE_TO_VOIDPTR(GCHandle::Alloc(__NULLPTR, GCHandleType::Pinned));
43 }
#define __GCHANDLE_TO_VOIDPTR(x)
#define __NULLPTR

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

◆ pinned_gcroot() [2/3]

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

Definition at line 48 of file pinned_gcroot.h.

48 {
49 _handle = __GCHANDLE_TO_VOIDPTR(GCHandle::Alloc(t, GCHandleType::Pinned));
50 }

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

◆ 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.

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 __VOIDPTR_TO_GCHANDLE(x)

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

◆ ~pinned_gcroot()

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

Definition at line 64 of file pinned_gcroot.h.

64 {
66 g.Free();
67 _handle = 0; // should fail if reconstituted
68 }
System::Runtime::InteropServices::GCHandle GCHandle

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

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.

72 {
73 // no need to check for valid handle; was allocated in ctor
75 return *this;
76 }

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

◆ 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.

78 {
79 // no need to check for valid handle; was allocated in ctor
80 T t = (T)r;
82 return *this;
83 }

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

◆ swap()

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

Definition at line 85 of file pinned_gcroot.h.

86 {
87 using std::swap;
88 swap(_handle, _right._handle);
89 }
void swap(pwiz::util::BinaryData< T > &lhs, std::vector< T > &rhs)
void swap(pinned_gcroot< T > &_right)

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

Referenced by msclr::swap(), and msclr::pinned_gcroot< T >::swap().

◆ operator T()

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

Definition at line 93 of file pinned_gcroot.h.

93 {
94 // gcroot is typesafe, so use static_cast
95 return static_cast<T>(__VOIDPTR_TO_GCHANDLE(_handle).Target);
96 }

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

◆ operator->()

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

Definition at line 101 of file pinned_gcroot.h.

101 {
102 // gcroot is typesafe, so use static_cast
103 return static_cast<T>(__VOIDPTR_TO_GCHANDLE(_handle).Target);
104 }

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

◆ operator&()

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

Definition at line 106 of file pinned_gcroot.h.

106 {
107 return __VOIDPTR_TO_GCHANDLE(_handle).AddrOfPinnedObject();
108 }

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

◆ handle()

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

Definition at line 110 of file pinned_gcroot.h.

110 {
111 return _handle;
112 }

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

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: