AutoPtr< X, Del > Class Template Reference
[Application Framework]

Search Toolkit Book for AutoPtr

#include <ncbimisc.hpp>

Inheritance diagram for AutoPtr< X, Del >:

Inheritance graph
[legend]
Collaboration diagram for AutoPtr< X, Del >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<class X, class Del = Deleter<X>>
class AutoPtr< X, Del >

AutoPtr --.

Define an "auto_ptr" like class that can be used inside STL containers.

The Standard auto_ptr template from STL doesn't allow the auto_ptr to be put in STL containers (list, vector, map etc.). The reason for this is the absence of copy constructor and assignment operator. We decided that it would be useful to have an analog of STL's auto_ptr without this restriction - AutoPtr.

Due to nature of AutoPtr its copy constructor and assignment operator modify the state of the source AutoPtr object as it transfers ownership to the target AutoPtr object. Also, we added possibility to redefine the way pointer will be deleted: the second argument of template allows pointers from "malloc" in AutoPtr, or you can use "ArrayDeleter" (see above) to properly delete an array of objects using "delete[]" instead of "delete". By default, the internal pointer will be deleted by C++ "delete" operator.

See also:
Deleter(), ArrayDeleter(), CDeleter()

Definition at line 430 of file ncbimisc.hpp.

Public Types

typedef X element_type
 Define element type.
typedef Del deleter_type
 Alias for template argument.

Public Member Functions

 AutoPtr (element_type *p=0)
 Constructor.
 AutoPtr (element_type *p, const deleter_type &deleter)
 Constructor.
 AutoPtr (element_type *p, EOwnership ownership)
 Constructor, own the pointed object if ownership == eTakeOwnership.
 AutoPtr (element_type *p, const deleter_type &deleter, EOwnership ownership)
 Constructor, own the pointed object if ownership == eTakeOwnership.
 AutoPtr (const AutoPtr< X, Del > &p)
 Copy constructor.
 ~AutoPtr (void)
 Destructor.
AutoPtr< X, Del > & operator= (const AutoPtr< X, Del > &p)
 Assignment operator.
AutoPtr< X, Del > & operator= (element_type *p)
 Assignment operator.
 operator bool (void) const
element_typeoperator * (void) const
 Dereference operator.
element_typeoperator-> (void) const
 Reference operator.
element_typeget (void) const
 Get pointer.
element_typerelease (void)
 Release will release ownership of pointer to caller.
void reset (element_type *p=0, EOwnership ownership=eTakeOwnership)
 Reset will delete old pointer, set content to new value, and accept ownership upon the new pointer.
void Swap (AutoPtr< X, Del > &a)

Private Member Functions

void operator< (bool) const
 Bool operator for use in if() clause.
void operator> (bool) const
void operator<= (bool) const
void operator>= (bool) const
void operator== (bool) const
void operator!= (bool) const
void operator+ (bool) const
void operator- (bool) const
element_typex_Release (void) const
 Release for const object.

Private Attributes

element_typem_Ptr
 Internal pointer representation.
pair_base_member< deleter_type,
bool
m_Data
 State info.


Member Typedef Documentation

template<class X, class Del = Deleter<X>>
typedef Del AutoPtr< X, Del >::deleter_type
 

Alias for template argument.

Definition at line 434 of file ncbimisc.hpp.

template<class X, class Del = Deleter<X>>
typedef X AutoPtr< X, Del >::element_type
 

Define element type.

Definition at line 433 of file ncbimisc.hpp.


Constructor & Destructor Documentation

template<class X, class Del = Deleter<X>>
AutoPtr< X, Del >::AutoPtr element_type p = 0  )  [inline]
 

Constructor.

Definition at line 437 of file ncbimisc.hpp.

template<class X, class Del = Deleter<X>>
AutoPtr< X, Del >::AutoPtr element_type p,
const deleter_type deleter
[inline]
 

Constructor.

Definition at line 443 of file ncbimisc.hpp.

template<class X, class Del = Deleter<X>>
AutoPtr< X, Del >::AutoPtr element_type p,
EOwnership  ownership
[inline]
 

Constructor, own the pointed object if ownership == eTakeOwnership.

Definition at line 449 of file ncbimisc.hpp.

template<class X, class Del = Deleter<X>>
AutoPtr< X, Del >::AutoPtr element_type p,
const deleter_type deleter,
EOwnership  ownership
[inline]
 

Constructor, own the pointed object if ownership == eTakeOwnership.

Definition at line 455 of file ncbimisc.hpp.

template<class X, class Del = Deleter<X>>
AutoPtr< X, Del >::AutoPtr const AutoPtr< X, Del > &  p  )  [inline]
 

Copy constructor.

Definition at line 461 of file ncbimisc.hpp.

template<class X, class Del = Deleter<X>>
AutoPtr< X, Del >::~AutoPtr void   )  [inline]
 

Destructor.

Definition at line 468 of file ncbimisc.hpp.


Member Function Documentation

template<class X, class Del = Deleter<X>>
element_type* AutoPtr< X, Del >::get void   )  const [inline]
 

Get pointer.

Definition at line 503 of file ncbimisc.hpp.

Referenced by CSeqMaskerUsetHash::add_ht_info(), CSeqMaskerUsetHash::add_vt_info(), CDataTypeModule::AddDefinition(), CFileModules::AddModule(), CBDB_BlobSplitStore< TBV, TObjDeMux, TL >::BlobSize(), BOOST_AUTO_TEST_CASE(), CAutomaticGenCodeSingleton::CAutomaticGenCodeSingleton(), CConfig::CConfig(), CLadder::CLadder(), CLadder::ClearHits(), CSearch< LEGACY, NHITS >::ClearLadderCalc(), CompressNcbi2na(), CReaderServiceConnector::Connect(), CBDB_BlobSplitStore< TBV, TObjDeMux, TL >::CreateReader(), CBDB_BlobSplitStore< TBV, TObjDeMux, TL >::Fetch(), CUniSequenceDataType::FixTypeTree(), CBDB_ExtBlobStore< TBV >::Flush(), CAliasTypeStrings::GenerateCode(), CSeqMaskerUsetArray::get_info(), CDataType::GetAnyTypeInfo(), CTemplate1TypeStrings::GetArg1Type(), CTemplate2TypeStrings::GetArg2Type(), CNcbiTestApplication::GetArgDescrs(), CTSE_ScopeInfo::GetBlobId(), CTSE_ScopeInfo::GetBlobOrder(), CBlastSeqVectorOM::GetCompressedPlusStrand(), CBlastSeqVectorFromCSeq_data::GetCompressedPlusStrand(), CReaderServiceConnector::GetConnDescription(), CAutoPtrTypeInfo< Data >::GetData(), CPointerTypeStrings::GetDataType(), CBDB_BlobSplitStore< TBV, TObjDeMux, TL >::GetDb(), CDataMember::GetDefault(), CUniSequenceDataType::GetElementType(), CLadder::GetHit(), CIdlerWrapper::GetIdler(), CNcbiTestApplication::GetIniParser(), CSearch< LEGACY, NHITS >::GetLadderCalc(), CMSHit::GetModInfo(), CMSPeakList::GetMZI(), CFileCode::GetPrimaryClass(), CDataType::GetRealTypeInfo(), GetSequenceNucleotideBothStrands(), CConfig::GetTree(), CDataMember::GetType(), CLadder::HitCount(), CBDB_BlobSplitStore< TBV, TObjDeMux, TL >::InitDbMutex(), CDiagMatcher::IsErrCodeMatcher(), CCgiTunnel2Grid::OnJobDone(), CLadder::operator[](), PrintRas(), PsiBlastComputePssmFromAlignment(), CBDB_ExtBlobStore< TBV >::ReadBlob(), CBDB_File::ReadCursor(), CBDB_BlobSplitStore< TBV, TObjDeMux, TL >::ReadRealloc(), CMergeVolumes::Run(), CIdlerWrapper::RunIdler(), s_CopyFile(), CSearch< LEGACY, NHITS >::SetLadderCalc(), CSearch< LEGACY, NHITS >::SetMassAndMask(), CMSHit::SetModInfo(), LinkHspTestFixture::setupLinkHspInputBlastn(), SetupSubjects_OMF(), CSQLITE_Blob::Write(), CStreamLineReader::x_AdvanceEOLUnknown(), CPsiBlastInputClustalW::x_CopyQueryToMsa(), CBDB_RawFile::x_DB_CPut(), CBDB_RawFile::x_DB_Fetch(), CBDB_RawFile::x_DB_Put(), CBDB_RawFile::x_DBC_Fetch(), CPsiBlastInputClustalW::x_ExtractQueryForPssm(), CPsiBlastInputClustalW::x_ExtractQueryFromMsa(), CGen_code_table::x_GetImplementation(), CBDB_BlobDictStore< Key, Dictionary, Store >::x_GetOpenDict(), CNCDBFile::x_GetStatement(), CGen_code_table::x_InitImplementation(), CId2FetchApp::x_InitPubSeqConnection(), CTar::x_PackName(), CPdfObject::x_PrintTo(), CBDB_ExtBlobStore< TBV >::x_ReadCache(), CNCBlobStorage::x_UnlockInstanceGuard(), and CPsiBlastInputClustalW::x_ValidateQueryInMsa().

template<class X, class Del = Deleter<X>>
element_type& AutoPtr< X, Del >::operator * void   )  const [inline]
 

Dereference operator.

Definition at line 497 of file ncbimisc.hpp.

template<class X, class Del = Deleter<X>>
AutoPtr< X, Del >::operator bool void   )  const [inline]
 

Definition at line 492 of file ncbimisc.hpp.

template<class X, class Del = Deleter<X>>
void AutoPtr< X, Del >::operator!= bool   )  const [private]
 

template<class X, class Del = Deleter<X>>
void AutoPtr< X, Del >::operator+ bool   )  const [private]
 

template<class X, class Del = Deleter<X>>
void AutoPtr< X, Del >::operator- bool   )  const [private]
 

template<class X, class Del = Deleter<X>>
element_type* AutoPtr< X, Del >::operator-> void   )  const [inline]
 

Reference operator.

Definition at line 500 of file ncbimisc.hpp.

template<class X, class Del = Deleter<X>>
void AutoPtr< X, Del >::operator< bool   )  const [private]
 

Bool operator for use in if() clause.

template<class X, class Del = Deleter<X>>
void AutoPtr< X, Del >::operator<= bool   )  const [private]
 

template<class X, class Del = Deleter<X>>
AutoPtr<X, Del>& AutoPtr< X, Del >::operator= element_type p  )  [inline]
 

Assignment operator.

Definition at line 485 of file ncbimisc.hpp.

template<class X, class Del = Deleter<X>>
AutoPtr<X, Del>& AutoPtr< X, Del >::operator= const AutoPtr< X, Del > &  p  )  [inline]
 

Assignment operator.

Definition at line 474 of file ncbimisc.hpp.

template<class X, class Del = Deleter<X>>
void AutoPtr< X, Del >::operator== bool   )  const [private]
 

template<class X, class Del = Deleter<X>>
void AutoPtr< X, Del >::operator> bool   )  const [private]
 

template<class X, class Del = Deleter<X>>
void AutoPtr< X, Del >::operator>= bool   )  const [private]
 

template<class X, class Del = Deleter<X>>
element_type* AutoPtr< X, Del >::release void   )  [inline]
 

Release will release ownership of pointer to caller.

Definition at line 506 of file ncbimisc.hpp.

Referenced by AascanTestFixture::AascanTestFixture(), CTypeStrings::AdaptForSTL(), BOOST_AUTO_TEST_CASE(), CReaderServiceConnector::Connect(), CPrintTextProxy::CPrintTextProxy(), CObjectIStream::Create(), CObjectIStream::CreateFromBuffer(), CEnumDataType::CreateTypeInfo(), CDataType::GenerateCode(), CEnumDataType::GetFullCType(), CChoiceDataType::GetFullCType(), CIdlerWrapper::GetIdler(), CDataType::GetRefCType(), AalookupTestFixture::GetSeqBlk(), CNcbiTestApplication::Init(), CId2FetchApp::Init(), CWig2tableApplication::MakeTable(), AutoPtr< CNcbiOstrstream >::reset(), TestFixture::SetUpQuery(), TestFixture::SetUpSubject(), CPssmEngine::x_InitializeScoreBlock(), CDiagSyntaxParser::x_PutIntoFilter(), and ASNParser::x_Value().

template<class X, class Del = Deleter<X>>
void AutoPtr< X, Del >::reset element_type p = 0,
EOwnership  ownership = eTakeOwnership
[inline]
 

Reset will delete old pointer, set content to new value, and accept ownership upon the new pointer.

Definition at line 514 of file ncbimisc.hpp.

Referenced by CTypeStrings::AdaptForSTL(), CSeqMaskerUsetHash::add_ht_info(), CSeqMaskerUsetHash::add_vt_info(), CAutoEnvironmentVariable::CAutoEnvironmentVariable(), CConfig::CConfig(), CAsnSizer::CloseDataStream(), CSplitDataMaker::CloseDataStream(), CObjMgr_LocalQueryData::CObjMgr_LocalQueryData(), CReaderServiceConnector::Connect(), CPtbRegistry::CPtbRegistry(), CTSE_ScopeInfo::CTSE_ScopeInfo(), CEventHandler::CPostQueue::ExecuteFirstRequest(), CDataType::GetAnyTypeInfo(), CIdlerWrapper::GetIdler(), CDataType::GetRealTypeInfo(), GetSequenceProtein(), GetSequenceSingleNucleotideStrand(), SAnnotSelector::IncludeNamedAnnotAccession(), CBDB_BlobSplitStore< TBV, TObjDeMux, TL >::InitDbMutex(), CGen_code_table::LoadTransTable(), CAsnSizer::OpenDataStream(), CSplitDataMaker::OpenDataStream(), SAnnotSelector::operator=(), CMSHit::operator=(), AutoPtr< CNcbiOstrstream >::operator=(), CMSHit::RecordMatches(), SAnnotSelector::ResetSourceLoc(), CWig2tableApplication::Run(), CSearch< LEGACY, NHITS >::Search(), CSQLITE_Blob::SetAppendStatement(), CBDB_RawFile::SetCompressor(), CBDB_ExtBlobStore< TBV >::SetCompressor(), CTSE_ScopeInfo::SetEditTSE(), CIdlerWrapper::SetIdler(), CMergeVolumes::SetMergeAccumulator(), CMergeVolumes::SetMergeStore(), CMSPeakList::SetMZI(), SAnnotSelector::SetSourceLoc(), CVersion::SetVersionInfo(), CSQLITE_Blob::Write(), CPsiBlastInputClustalW::x_ExtractQueryFromMsa(), CId2FetchApp::x_InitConnection(), CGen_code_table::x_InitImplementation(), CBlastFastaInputSource::x_InitInputReader(), CId2FetchApp::x_InitPubSeqConnection(), CNCBlobStorage::x_OpenIndexDB(), CPdfObject::x_PrintTo(), CXcompareAnnotsApplication::x_ProcessSeqAlignSetFromFile(), CId2FetchApp::x_SendRequestPacket(), CNCBlobStorage::x_UnlockInstanceGuard(), AutoPtr< CNcbiOstrstream >::~AutoPtr(), and CNCBlobStorage::~CNCBlobStorage().

template<class X, class Del = Deleter<X>>
void AutoPtr< X, Del >::Swap AutoPtr< X, Del > &  a  )  [inline]
 

Definition at line 525 of file ncbimisc.hpp.

template<class X, class Del = Deleter<X>>
element_type* AutoPtr< X, Del >::x_Release void   )  const [inline, private]
 

Release for const object.

Definition at line 536 of file ncbimisc.hpp.

Referenced by AutoPtr< CNcbiOstrstream >::AutoPtr(), and AutoPtr< CNcbiOstrstream >::operator=().


Member Data Documentation

template<class X, class Del = Deleter<X>>
pair_base_member<deleter_type, bool> AutoPtr< X, Del >::m_Data [mutable, private]
 

State info.

Definition at line 533 of file ncbimisc.hpp.

Referenced by AutoPtr< CNcbiOstrstream >::operator=(), AutoPtr< CNcbiOstrstream >::release(), AutoPtr< CNcbiOstrstream >::reset(), AutoArray< CS_INT >::Swap(), and AutoPtr< CNcbiOstrstream >::Swap().

template<class X, class Del = Deleter<X>>
element_type* AutoPtr< X, Del >::m_Ptr [private]
 

Internal pointer representation.

Definition at line 532 of file ncbimisc.hpp.

Referenced by AutoPtr< CNcbiOstrstream >::AutoPtr(), AutoPtr< CNcbiOstrstream >::get(), AutoPtr< CNcbiOstrstream >::operator *(), AutoPtr< CNcbiOstrstream >::operator->(), AutoPtr< CNcbiOstrstream >::release(), AutoPtr< CNcbiOstrstream >::reset(), AutoArray< CS_INT >::Swap(), and AutoPtr< CNcbiOstrstream >::Swap().


The documentation for this class was generated from the following file:
Generated on Wed Dec 9 07:49:10 2009 for NCBI C++ ToolKit by  doxygen 1.4.6
Modified on Wed Dec 09 08:18:47 2009 by modify_doxy.py rev. 173732