Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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.

:
m_data(0),
m_count(0),
m_size(0)
{
}
template<typename T>
Nektar::NekPtr< T >::NekPtr ( T *  d)
inlineexplicit

Definition at line 55 of file NekPtr.hpp.

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

:
m_data(d),
m_count(MemoryManager<unsigned int>::RawAllocate(1)),
m_size(1)
{
*m_count = 1;
}
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.

:
m_data(d),
m_count(MemoryManager<unsigned int>::RawAllocate(1)),
m_size(s)
{
*m_count = 1;
}
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.

:
m_data(rhs.m_data),
m_count(rhs.m_count),
m_size(rhs.m_size)
{
if( m_count != 0 )
{
*m_count += 1;
}
}
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, and Nektar::NekPtr< T >::m_size.

{
if( m_count == 0 )
{
return;
}
*m_count -= 1;
if( *m_count == 0 )
{
ArrayDestructionPolicy<T>::Destroy(m_data, m_size);
MemoryManager<T>::RawDeallocate(m_data, m_size);
MemoryManager<unsigned int>::RawDeallocate(m_count, 1);
}
}

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.

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

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

{
NekPtr temp(rhs);
Swap(temp);
return *this;
}
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=().

{
std::swap(m_data, rhs.m_data);
std::swap(m_count, rhs.m_count);
std::swap(m_size, rhs.m_size);
}

Member Data Documentation

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

Definition at line 117 of file NekPtr.hpp.

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

template<typename T>
T* Nektar::NekPtr< T >::m_data
private

Definition at line 116 of file NekPtr.hpp.

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

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