Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Nektar::NekPtr< T > Class Template Reference

#include <NekPtr.hpp>

Public Member Functions

 NekPtr ()
 
 NekPtr (T *d)
 
 NekPtr (T *d, unsigned int s)
 
 NekPtr (const NekPtr< T > &rhs)
 
NekPtr< T > & operator= (const NekPtr< T > &rhs)
 
 ~NekPtr ()
 
T * get ()
 
const T * get () const
 

Private Member Functions

void Swap (NekPtr< T > &rhs)
 

Private Attributes

T * m_data
 
unsigned int * m_count
 
int m_size
 

Detailed Description

template<typename T>
class Nektar::NekPtr< T >

Definition at line 45 of file NekPtr.hpp.

Constructor & Destructor Documentation

template<typename T>
Nektar::NekPtr< T >::NekPtr ( )
inline

Definition at line 48 of file NekPtr.hpp.

48  :
49  m_data(0),
50  m_count(0),
51  m_size(0)
52  {
53  }
unsigned int * m_count
Definition: NekPtr.hpp:117
template<typename T>
Nektar::NekPtr< T >::NekPtr ( T *  d)
inlineexplicit

Definition at line 55 of file NekPtr.hpp.

References Nektar::NekPtr< T >::m_count.

55  :
56  m_data(d),
57  m_count(MemoryManager<unsigned int>::RawAllocate(1)),
58  m_size(1)
59  {
60  *m_count = 1;
61  }
unsigned int * m_count
Definition: NekPtr.hpp:117
template<typename T>
Nektar::NekPtr< T >::NekPtr ( T *  d,
unsigned int  s 
)
inline

Definition at line 63 of file NekPtr.hpp.

References Nektar::NekPtr< T >::m_count.

63  :
64  m_data(d),
65  m_count(MemoryManager<unsigned int>::RawAllocate(1)),
66  m_size(s)
67  {
68  *m_count = 1;
69  }
unsigned int * m_count
Definition: NekPtr.hpp:117
template<typename T>
Nektar::NekPtr< T >::NekPtr ( const NekPtr< T > &  rhs)
inline

Definition at line 71 of file NekPtr.hpp.

References Nektar::NekPtr< T >::m_count.

71  :
72  m_data(rhs.m_data),
73  m_count(rhs.m_count),
74  m_size(rhs.m_size)
75  {
76  if( m_count != 0 )
77  {
78  *m_count += 1;
79  }
80  }
unsigned int * m_count
Definition: NekPtr.hpp:117
template<typename T>
Nektar::NekPtr< T >::~NekPtr ( )
inline

Definition at line 89 of file NekPtr.hpp.

References Nektar::NekPtr< T >::m_count, Nektar::NekPtr< T >::m_data, Nektar::NekPtr< T >::m_size, and Nektar::MemoryManager< DataType >::RawDeallocate().

90  {
91  if( m_count == 0 )
92  {
93  return;
94  }
95 
96  *m_count -= 1;
97  if( *m_count == 0 )
98  {
99  ArrayDestructionPolicy<T>::Destroy(m_data, m_size);
102  }
103  }
static void RawDeallocate(DataType *array, unsigned int NumberOfElements)
Deallocates memory allocated from RawAllocate.
unsigned int * m_count
Definition: NekPtr.hpp:117

Member Function Documentation

template<typename T>
T* Nektar::NekPtr< T >::get ( )
inline

Definition at line 105 of file NekPtr.hpp.

References Nektar::NekPtr< T >::m_data.

105 { return m_data; }
template<typename T>
const T* Nektar::NekPtr< T >::get ( ) const
inline

Definition at line 106 of file NekPtr.hpp.

References Nektar::NekPtr< T >::m_data.

106 { return m_data; }
template<typename T>
NekPtr<T>& Nektar::NekPtr< T >::operator= ( const NekPtr< T > &  rhs)
inline

Definition at line 82 of file NekPtr.hpp.

References Nektar::NekPtr< T >::Swap().

83  {
84  NekPtr temp(rhs);
85  Swap(temp);
86  return *this;
87  }
void Swap(NekPtr< T > &rhs)
Definition: NekPtr.hpp:109
template<typename T>
void Nektar::NekPtr< T >::Swap ( NekPtr< T > &  rhs)
inlineprivate

Definition at line 109 of file NekPtr.hpp.

References Nektar::NekPtr< T >::m_count, Nektar::NekPtr< T >::m_data, and Nektar::NekPtr< T >::m_size.

Referenced by Nektar::NekPtr< T >::operator=().

110  {
111  std::swap(m_data, rhs.m_data);
112  std::swap(m_count, rhs.m_count);
113  std::swap(m_size, rhs.m_size);
114  }
unsigned int * m_count
Definition: NekPtr.hpp:117

Member Data Documentation

template<typename T>
unsigned int* Nektar::NekPtr< T >::m_count
private
template<typename T>
T* Nektar::NekPtr< T >::m_data
private
template<typename T>
int Nektar::NekPtr< T >::m_size
private

Definition at line 118 of file NekPtr.hpp.

Referenced by Nektar::NekPtr< T >::Swap(), and Nektar::NekPtr< T >::~NekPtr().