FEI Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Private Attributes | Friends | List of all members
fei::SharedPtr< T > Class Template Reference

#include <fei_SharedPtr.hpp>

Inheritance diagram for fei::SharedPtr< T >:
Inheritance graph
[legend]

Public Types

typedef T element_type
 

Public Member Functions

 SharedPtr (T *p)
 
 SharedPtr (void)
 
 ~SharedPtr ()
 
template<typename Y >
 SharedPtr (const SharedPtr< Y > &x)
 
template<typename Y >
SharedPtroperator= (const SharedPtr< Y > &x)
 
 SharedPtr (const SharedPtr &x)
 
SharedPtroperator= (const SharedPtr &x)
 
void reset (T *p=0)
 
T & operator* () const
 
T * operator-> () const
 
T * get () const
 
long use_count () const
 
bool unique () const
 
void share (T *xpointer, long *xcount)
 
void dispose ()
 

Private Attributes

T * pointer
 
long * count
 

Friends

template<typename Y >
class SharedPtr
 

Detailed Description

template<typename T>
class fei::SharedPtr< T >

A smart pointer with reference counted copy semantics. This class is a close copy of boost::shared_ptr. See www.boost.org, and www.boost.org/libs/smart_ptr/smart_ptr.htm. For logistical reasons it was deemed easier to make a copy of the boost::shared_ptr rather than having FEI be dependent on boost. According to TR1 (C++ Technical Report 1), referenced on the boost web site, shared_ptr will be migrating into the C++ standard.

fei::SharedPtr usage notes:

Construction:

Assignment:

Comparison:

The object pointed to is deleted when the last SharedPtr pointing to it is destroyed or reset.

Author
Kevin Copps
Date
12/4/2001

Definition at line 65 of file fei_SharedPtr.hpp.

Member Typedef Documentation

template<typename T>
typedef T fei::SharedPtr< T >::element_type

The type of the stored pointer.

Definition at line 72 of file fei_SharedPtr.hpp.

Constructor & Destructor Documentation

template<typename T>
fei::SharedPtr< T >::SharedPtr ( T *  p)
inlineexplicit

Constructs a SharedPtr, storing a copy of p, which must have been allocated via a C++ new expression or be 0. On exit, use_count() is 1 (even if p==0; see the destructor).

The only exception which may be thrown by this constructor is std::bad_alloc. If an exception is thrown, delete p is called.

Parameters
pthe pointer value recently allocated

Definition at line 84 of file fei_SharedPtr.hpp.

template<typename T>
fei::SharedPtr< T >::SharedPtr ( void  )
inline

Definition at line 95 of file fei_SharedPtr.hpp.

template<typename T>
fei::SharedPtr< T >::~SharedPtr ( )
inline

Destructor. If use_count() == 1, deletes the object pointed to by the stored pointer. Otherwise, use_count() for any remaining copies is decremented by 1. Note that in C++ delete on a pointer with a value of 0 is harmless.

Never throws an exception.

Definition at line 109 of file fei_SharedPtr.hpp.

template<typename T>
template<typename Y >
fei::SharedPtr< T >::SharedPtr ( const SharedPtr< Y > &  x)
inline

Constructs a SharedPtr, as if by storing a copy of the pointer stored in x. Afterwards, use_count() for all copies is 1 more than the initial x.use_count().

Never throws an exception.

Parameters
xa shared pointer to another type

Definition at line 122 of file fei_SharedPtr.hpp.

template<typename T>
fei::SharedPtr< T >::SharedPtr ( const SharedPtr< T > &  x)
inline

Constructs a SharedPtr, as if by storing a copy of the pointer stored in x. Afterwards, use_count() for all copies is 1 more than the initial x.use_count().

Never throws an exception.

Parameters
xthe shared pointer to copy

Definition at line 160 of file fei_SharedPtr.hpp.

Member Function Documentation

template<typename T>
template<typename Y >
SharedPtr& fei::SharedPtr< T >::operator= ( const SharedPtr< Y > &  x)
inline

Assignment to a shared pointer of another type.

First, if use_count() == 1, deletes the object pointed to by the stored pointer. Otherwise, use_count() for any remaining copies is decremented by 1. Note that in C++ delete on a pointer with a value of 0 is harmless.

Then replaces the contents of this, as if by storing a copy of the pointer stored in x. Afterwards, use_count() for all copies is 1 more than the initial x.use_count().

Never throws an exception.

Parameters
xa shared pointer to another type

Definition at line 145 of file fei_SharedPtr.hpp.

template<typename T>
SharedPtr& fei::SharedPtr< T >::operator= ( const SharedPtr< T > &  x)
inline

Assignment to another shared pointer. First, if use_count() == 1, deletes the object pointed to by the stored pointer. Otherwise, use_count() for any remaining copies is decremented by 1. Note that in C++ delete on a pointer with a value of 0 is harmless.

Then replaces the contents of this, as if by storing a copy of the pointer stored in x. Afterwards, use_count() for all copies is 1 more than the initial x.use_count().

Does not throw any exception.

Parameters
xthe shared pointer to copy

Definition at line 181 of file fei_SharedPtr.hpp.

template<typename T>
void fei::SharedPtr< T >::reset ( T *  p = 0)
inline

Reset the pointer value of this shared pointer. First, if use_count() == 1, deletes the object pointed to by the stored pointer. Otherwise, use_count() for any remaining copies is decremented by 1. Then replaces the contents of this, as if by storing a copy of p, which must have been allocated via a C++ new expression or be 0. Afterwards, use_count() is 1 (even if p==0; see ~SharedPtr).

Note that in C++ delete on a pointer with a value of 0 is harmless.

The only exception which may be thrown is std::bad_alloc. If an exception is thrown, delete p is called.

Parameters
pa pointer value, or 0 if not present

Definition at line 203 of file fei_SharedPtr.hpp.

Referenced by beam_oldfei_main(), snl_fei::Factory::clone(), fei::create_LibraryWrapper(), test_VectorSpace::create_VectorSpace(), FEI_tester::createFEIinstance(), fei::MatrixGraph_Impl2::createGraph(), snl_fei::Broker_FEData::createMatrix(), snl_fei::Broker_LinSysCore::createMatrix(), snl_fei::Broker_FEData::createVector(), snl_fei::Broker_LinSysCore::createVector(), Factory_Aztec::createVector(), snl_fei::LinearSystem_General::enforceEssentialBC_LinSysCore(), extractDirichletBCs(), feiDriver_main(), fei::FEI_Impl::initComplete(), main(), poisson_main(), and test_FEI::test1().

template<typename T>
T& fei::SharedPtr< T >::operator* ( ) const
inline

Returns a reference to the object pointed to by the stored pointer.

Never throws an exception.

Definition at line 228 of file fei_SharedPtr.hpp.

template<typename T>
T* fei::SharedPtr< T >::operator-> ( ) const
inline

Return the stored pointer.

Never throws an exception.

Definition at line 235 of file fei_SharedPtr.hpp.

template<typename T>
T* fei::SharedPtr< T >::get ( ) const
inline

Return the stored pointer. T is not required to be a complete type.

Never throws an exception.

Definition at line 242 of file fei_SharedPtr.hpp.

Referenced by fei::FEI_Impl::aggregateSystem_LinSysCore(), FEI_Implementation::allocateInternalFEIs(), beam_main(), beam_oldfei_main(), fei::create_fei_Factory(), fei::create_LibraryWrapper(), test_MatrixGraph::create_MatrixGraph(), test_VectorSpace::create_VectorSpace(), FEI_tester::createFEIinstance(), fei::MatrixGraph_Impl2::createGraph(), snl_fei::Broker_FEData::createLinearSystem(), snl_fei::Broker_LinSysCore::createLinearSystem(), snl_fei::Broker_FEData::createMatrix(), snl_fei::Broker_LinSysCore::createMatrix(), Factory_Aztec::createMatrix(), snl_fei::Broker_FEData::createVector(), snl_fei::Broker_LinSysCore::createVector(), Factory_Aztec::createVector(), snl_fei::LinearSystem_General::enforceEssentialBC_LinSysCore(), snl_fei::LinearSystem_General::enforceEssentialBC_step_1(), snl_fei::LinearSystem_General::enforceEssentialBC_step_2(), extractDirichletBCs(), snl_fei::Factory::Factory(), test_Factory::factory_test1(), fei_Solver_solve(), feiDriver_main(), fei::DirichletBCManager::finalizeBCEqns(), fei::utils::get_LinearSystemCore(), fei::DirichletBCManager::getEqnNumber(), fei::FEI_Impl::initComplete(), main(), fei::Matrix_core::Matrix_core(), fei::Matrix_Impl< T >::Matrix_Impl(), fei::MatrixGraph_Impl2::MatrixGraph_Impl2(), fei::MatrixReducer::MatrixReducer(), fei::operator!=(), fei::operator==(), snl_fei::LinearSystem_General::parameters(), poisson3_main(), poisson_main(), fei::FEI_Impl::putNodalFieldData(), fei::Reducer::Reducer(), fei::FEI_Impl::residualNorm(), snl_fei::Broker_LinSysCore::setGlobalOffsets(), fei::FEI_Impl::setIDLists(), snl_fei::Broker_LinSysCore::setMatrixStructure(), snl_fei::Broker_FEData::setStructure(), fei::Matrix_Impl< T >::sumIn(), test_FEI::test1(), test_LinearSystem::test2(), test_LinearSystem::test3(), test_VectorSpace::test3(), test_MatrixGraph::test3(), test_Matrix::test3(), test_LinearSystem::test4(), snl_fei_tester::testCheckResult(), snl_fei_tester::testInitialization(), FEI_tester::testInitialization(), snl_fei_tester::testSolve(), fei::VectorReducer::VectorReducer(), fei::Matrix_Impl< T >::writeToFile(), fei::Matrix_Impl< T >::writeToStream(), and fei::FEI_Impl::~FEI_Impl().

template<typename T>
long fei::SharedPtr< T >::use_count ( ) const
inline

Returns the number of SharedPtr's sharing ownership of the stored pointer. T is not required to be a complete type.

Never throws an exception.

Definition at line 250 of file fei_SharedPtr.hpp.

template<typename T>
bool fei::SharedPtr< T >::unique ( ) const
inline

Returns use_count() == 1. T is not required to be a complete type.

Never throws an exception.

Definition at line 258 of file fei_SharedPtr.hpp.

template<typename T>
void fei::SharedPtr< T >::share ( T *  xpointer,
long *  xcount 
)
inline

power users only

Definition at line 261 of file fei_SharedPtr.hpp.

Referenced by fei::SharedPtr< fei::LinearProblemManager >::operator=().

template<typename T>
void fei::SharedPtr< T >::dispose ( )
inline

Friends And Related Function Documentation

template<typename T>
template<typename Y >
friend class SharedPtr
friend

Definition at line 288 of file fei_SharedPtr.hpp.

Member Data Documentation

template<typename T>
T* fei::SharedPtr< T >::pointer
private
template<typename T>
long* fei::SharedPtr< T >::count
private

The documentation for this class was generated from the following file: