CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 14 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 44 of file mayown_ptr.h.

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

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

Definition at line 45 of file mayown_ptr.h.

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

Definition at line 46 of file mayown_ptr.h.

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

46 { destroy();}
void destroy()
Definition: mayown_ptr.h:40
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 48 of file mayown_ptr.h.

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

Member Function Documentation

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

Definition at line 40 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().

40  {
41  if (isOwn()) delete const_cast<T*>(pointer());
42  }
bool isOwn() const
Definition: mayown_ptr.h:26
T const * pointer() const
Definition: mayown_ptr.h:31
long double T
template<typename T, int N = sizeof(T*)>
bool mayown_ptr< T, N >::empty ( ) const
inline
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 26 of file mayown_ptr.h.

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

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

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

Definition at line 18 of file mayown_ptr.h.

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

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

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

Definition at line 52 of file mayown_ptr.h.

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

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

Definition at line 53 of file mayown_ptr.h.

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

53 { return pointer();}
T const * pointer() const
Definition: mayown_ptr.h:31
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 50 of file mayown_ptr.h.

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

50 { destroy(); p=rh.p; rh.p=nullptr; return *this;}
void destroy()
Definition: mayown_ptr.h:40
T const * p
Definition: mayown_ptr.h:16
template<typename T, int N = sizeof(T*)>
T const* mayown_ptr< T, N >::pointer ( ) const
inlineprivate

Definition at line 31 of file mayown_ptr.h.

References 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().

31  {
32  unsigned char buff[N]; memcpy(buff,&p,N);
33  buff[N-1] &= 0xFE;
34  assert((buff[N-1]&1)==0);
35  T const * np;
36  memcpy(&np,buff,N);
37  return np;
38  }
assert(m_qm.get())
int np
Definition: AMPTWrapper.h:33
#define N
Definition: blowfish.cc:9
T const * p
Definition: mayown_ptr.h:16
long double T
template<typename T, int N = sizeof(T*)>
T const* mayown_ptr< T, N >::raw ( ) const
inline

Definition at line 61 of file mayown_ptr.h.

References mayown_ptr< T, N >::p.

Referenced by operator==().

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

Definition at line 55 of file mayown_ptr.h.

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

Referenced by cuy.ValElement::__init__(), and MultiHitGeneratorFromChi2::hitSets().

55 { auto np=pointer(); p=nullptr; return np;}
int np
Definition: AMPTWrapper.h:33
T const * p
Definition: mayown_ptr.h:16
T const * pointer() const
Definition: mayown_ptr.h:31
template<typename T, int N = sizeof(T*)>
void mayown_ptr< T, N >::reset ( void  )
inline

Definition at line 56 of file mayown_ptr.h.

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

Referenced by MultiHitGeneratorFromChi2::hitSets(), and MultiHitGeneratorFromChi2::refit2Hits().

56 { destroy(); p=nullptr;}
void destroy()
Definition: mayown_ptr.h:40
T const * p
Definition: mayown_ptr.h:16
template<typename T, int N = sizeof(T*)>
void mayown_ptr< T, N >::reset ( T ip)
inline

Definition at line 57 of file mayown_ptr.h.

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

57 { destroy(); p=ip; markOwn();}
void markOwn()
Definition: mayown_ptr.h:18
void destroy()
Definition: mayown_ptr.h:40
T const * p
Definition: mayown_ptr.h:16
template<typename T, int N = sizeof(T*)>
void mayown_ptr< T, N >::reset ( T const &  ip)
inline

Definition at line 58 of file mayown_ptr.h.

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

58 { destroy(); p=&ip;}
void destroy()
Definition: mayown_ptr.h:40
T const * p
Definition: mayown_ptr.h:16

Member Data Documentation

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