CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
mayown_ptr< T, N > Class Template Reference

#include <mayown_ptr.h>

Public Member Functions

bool empty () const
 
T const * get () const
 
bool isOwn () const
 
 mayown_ptr (T *ip=nullptr)
 
 mayown_ptr (T const &ip)
 
 mayown_ptr (mayown_ptr &)=delete
 
 mayown_ptr (mayown_ptr &&rh)
 
T const & operator* () const
 
T const * operator-> () const
 
mayown_ptroperator= (mayown_ptr &)=delete
 
mayown_ptroperator= (mayown_ptr &&rh)
 
T const * raw () const
 
T const * release ()
 
void reset ()
 
void reset (T *ip)
 
void reset (T const &ip)
 
 ~mayown_ptr ()
 

Private Member Functions

void destroy ()
 
void markOwn ()
 
T const * pointer () const
 

Private Attributes

T const * p = nullptr
 

Detailed Description

template<typename T, int N = sizeof(T*)>
class mayown_ptr< T, N >

Definition at line 13 of file mayown_ptr.h.

Constructor & Destructor Documentation

template<typename T, int N = sizeof(T*)>
mayown_ptr< T, N >::mayown_ptr ( T ip = nullptr)
inlineexplicit

Definition at line 51 of file mayown_ptr.h.

References mayown_ptr< T, N >::markOwn().

51 : p(ip) { markOwn(); }
void markOwn()
Definition: mayown_ptr.h:17
T const * p
Definition: mayown_ptr.h:15
template<typename T, int N = sizeof(T*)>
mayown_ptr< T, N >::mayown_ptr ( T const &  ip)
inlineexplicit

Definition at line 52 of file mayown_ptr.h.

52 : p(&ip) {}
T const * p
Definition: mayown_ptr.h:15
template<typename T, int N = sizeof(T*)>
mayown_ptr< T, N >::~mayown_ptr ( )
inline

Definition at line 53 of file mayown_ptr.h.

References mayown_ptr< T, N >::destroy().

53 { destroy(); }
void destroy()
Definition: mayown_ptr.h:45
template<typename T, int N = sizeof(T*)>
mayown_ptr< T, N >::mayown_ptr ( mayown_ptr< T, N > &  )
delete
template<typename T, int N = sizeof(T*)>
mayown_ptr< T, N >::mayown_ptr ( mayown_ptr< T, N > &&  rh)
inline

Definition at line 55 of file mayown_ptr.h.

55 : p(rh.p) { rh.p = nullptr; }
T const * p
Definition: mayown_ptr.h:15

Member Function Documentation

template<typename T, int N = sizeof(T*)>
void mayown_ptr< T, N >::destroy ( )
inlineprivate

Definition at line 45 of file mayown_ptr.h.

References mayown_ptr< T, N >::isOwn(), and mayown_ptr< T, N >::pointer().

Referenced by mayown_ptr< T, N >::operator=(), mayown_ptr< T, N >::reset(), and mayown_ptr< T, N >::~mayown_ptr().

45  {
46  if (isOwn())
47  delete const_cast<T*>(pointer());
48  }
bool isOwn() const
Definition: mayown_ptr.h:28
T const * pointer() const
Definition: mayown_ptr.h:35
long double T
template<typename T, int N = sizeof(T*)>
bool mayown_ptr< T, N >::empty ( ) const
inline

Definition at line 85 of file mayown_ptr.h.

References mayown_ptr< T, N >::p.

Referenced by MultiHitGeneratorFromChi2::hitSets().

85 { return nullptr == p; }
T const * p
Definition: mayown_ptr.h:15
template<typename T, int N = sizeof(T*)>
T const* mayown_ptr< T, N >::get ( ) const
inline
template<typename T, int N = sizeof(T*)>
bool mayown_ptr< T, N >::isOwn ( ) const
inline

Definition at line 28 of file mayown_ptr.h.

References N, and mayown_ptr< T, N >::p.

Referenced by mayown_ptr< T, N >::destroy(), and MultiHitGeneratorFromChi2::hitSets().

28  {
29  unsigned char buff[N];
30  memcpy(buff, &p, N);
31  return 1 == (buff[N - 1] & 1);
32  }
#define N
Definition: blowfish.cc:9
T const * p
Definition: mayown_ptr.h:15
template<typename T, int N = sizeof(T*)>
void mayown_ptr< T, N >::markOwn ( )
inlineprivate

Definition at line 17 of file mayown_ptr.h.

References cms::cuda::assert(), N, and mayown_ptr< T, N >::p.

Referenced by mayown_ptr< T, N >::mayown_ptr(), and mayown_ptr< T, N >::reset().

17  {
18  if (nullptr == p)
19  return;
20  unsigned char buff[N];
21  memcpy(buff, &p, N);
22  assert((buff[N - 1] & 1) == 0);
23  ++buff[N - 1];
24  memcpy(&p, buff, N);
25  }
assert(be >=bs)
#define N
Definition: blowfish.cc:9
T const * p
Definition: mayown_ptr.h:15
template<typename T, int N = sizeof(T*)>
T const& mayown_ptr< T, N >::operator* ( void  ) const
inline

Definition at line 64 of file mayown_ptr.h.

References mayown_ptr< T, N >::pointer().

64 { return *pointer(); }
T const * pointer() const
Definition: mayown_ptr.h:35
template<typename T, int N = sizeof(T*)>
T const* mayown_ptr< T, N >::operator-> ( ) const
inline

Definition at line 65 of file mayown_ptr.h.

References mayown_ptr< T, N >::pointer().

65 { return pointer(); }
T const * pointer() const
Definition: mayown_ptr.h:35
template<typename T, int N = sizeof(T*)>
mayown_ptr& mayown_ptr< T, N >::operator= ( mayown_ptr< T, N > &  )
delete
template<typename T, int N = sizeof(T*)>
mayown_ptr& mayown_ptr< T, N >::operator= ( mayown_ptr< T, N > &&  rh)
inline

Definition at line 57 of file mayown_ptr.h.

References mayown_ptr< T, N >::destroy(), and mayown_ptr< T, N >::p.

57  {
58  destroy();
59  p = rh.p;
60  rh.p = nullptr;
61  return *this;
62  }
void destroy()
Definition: mayown_ptr.h:45
T const * p
Definition: mayown_ptr.h:15
template<typename T, int N = sizeof(T*)>
T const* mayown_ptr< T, N >::pointer ( ) const
inlineprivate

Definition at line 35 of file mayown_ptr.h.

References cms::cuda::assert(), N, np, and mayown_ptr< T, N >::p.

Referenced by mayown_ptr< T, N >::destroy(), mayown_ptr< T, N >::get(), mayown_ptr< T, N >::operator*(), mayown_ptr< T, N >::operator->(), and mayown_ptr< T, N >::release().

35  {
36  unsigned char buff[N];
37  memcpy(buff, &p, N);
38  buff[N - 1] &= 0xFE;
39  assert((buff[N - 1] & 1) == 0);
40  T const* np;
41  memcpy(&np, buff, N);
42  return np;
43  }
assert(be >=bs)
int np
Definition: AMPTWrapper.h:43
#define N
Definition: blowfish.cc:9
T const * p
Definition: mayown_ptr.h:15
long double T
template<typename T, int N = sizeof(T*)>
T const* mayown_ptr< T, N >::raw ( ) const
inline

Definition at line 87 of file mayown_ptr.h.

References mayown_ptr< T, N >::p.

Referenced by operator==().

87 { return p; }
T const * p
Definition: mayown_ptr.h:15
template<typename T, int N = sizeof(T*)>
T const* mayown_ptr< T, N >::release ( )
inline

Definition at line 67 of file mayown_ptr.h.

References np, mayown_ptr< T, N >::p, and mayown_ptr< T, N >::pointer().

Referenced by MultiHitGeneratorFromChi2::hitSets().

67  {
68  auto np = pointer();
69  p = nullptr;
70  return np;
71  }
int np
Definition: AMPTWrapper.h:43
T const * p
Definition: mayown_ptr.h:15
T const * pointer() const
Definition: mayown_ptr.h:35
template<typename T, int N = sizeof(T*)>
void mayown_ptr< T, N >::reset ( void  )
inline

Definition at line 72 of file mayown_ptr.h.

References mayown_ptr< T, N >::destroy(), and mayown_ptr< T, N >::p.

Referenced by MultiHitGeneratorFromChi2::hitSets().

72  {
73  destroy();
74  p = nullptr;
75  }
void destroy()
Definition: mayown_ptr.h:45
T const * p
Definition: mayown_ptr.h:15
template<typename T, int N = sizeof(T*)>
void mayown_ptr< T, N >::reset ( T ip)
inline

Definition at line 76 of file mayown_ptr.h.

References mayown_ptr< T, N >::destroy(), mayown_ptr< T, N >::markOwn(), and mayown_ptr< T, N >::p.

76  {
77  destroy();
78  p = ip;
79  markOwn();
80  }
void markOwn()
Definition: mayown_ptr.h:17
void destroy()
Definition: mayown_ptr.h:45
T const * p
Definition: mayown_ptr.h:15
template<typename T, int N = sizeof(T*)>
void mayown_ptr< T, N >::reset ( T const &  ip)
inline

Definition at line 81 of file mayown_ptr.h.

References mayown_ptr< T, N >::destroy(), and mayown_ptr< T, N >::p.

81  {
82  destroy();
83  p = &ip;
84  }
void destroy()
Definition: mayown_ptr.h:45
T const * p
Definition: mayown_ptr.h:15

Member Data Documentation

template<typename T, int N = sizeof(T*)>
T const* mayown_ptr< T, N >::p = nullptr
private