NCBI C++ ToolKit
|
Search Toolkit Book for CSafeStatic
CSafeStatic<>:: More...
#include <corelib/ncbi_safe_static.hpp>
Public Types | |
typedef Callbacks | TCallbacks |
typedef CSafeStatic< T, TCallbacks > | TThisType |
typedef CSafeStaticLifeSpan | TLifeSpan |
typedef CSafeStatic_Allocator< T > | TAllocator |
typedef CSafeStatic_Callbacks< T >::FCreate | FCreate |
Callback function types. More... | |
typedef CSafeStatic_Callbacks< T >::FCleanup | FCleanup |
![]() | |
typedef void(* | FUserCleanup) (void *ptr) |
User cleanup function type. More... | |
typedef CSafeStaticLifeSpan | TLifeSpan |
Life span. More... | |
Public Member Functions | |
CSafeStatic (TLifeSpan life_span=TLifeSpan::GetDefault()) | |
Constructor. More... | |
CSafeStatic (FCreate create, FCleanup cleanup, TLifeSpan life_span=TLifeSpan::GetDefault()) | |
Constructor. More... | |
CSafeStatic (TCallbacks callbacks, TLifeSpan life_span=TLifeSpan::GetDefault()) | |
Constructor. More... | |
T & | Get (void) |
Create the variable if not created yet, return the reference. More... | |
T * | operator-> (void) |
T & | operator* (void) |
![]() | |
~CSafeStaticPtr_Base (void) | |
Private Member Functions | |
CSafeStatic (const CSafeStatic &)=delete | |
CSafeStatic & | operator= (const CSafeStatic &)=delete |
void | x_Init (void) |
Static Private Member Functions | |
static T * | x_CastPtr (const void *ptr) |
static void | sx_SelfCleanup (CSafeStaticPtr_Base *safe_static, TInstanceMutexGuard &guard) |
Private Attributes | |
TCallbacks | m_Callbacks |
CSafeStatic<>::
For on-demand object access, both non-CObject and CObject based. Create the variable of type "T" on the first access. The default implementation of allocator uses reference counter of CObject class to prevent premature destruction. Should be used only as static object. Otherwise the correct initialization is not guaranteed.
T | Type of the variable to be stored. |
Callbacks | A class implementing two methods to perform additional initialization and cleanup: void Create(T* ptr) void Cleanup(T* ptr) NOTE: The Cleanup callback must not destroy the object itself, just perform any additional actions. |
Definition at line 447 of file ncbi_safe_static.hpp.
typedef CSafeStatic_Callbacks<T>::FCleanup CSafeStatic< T, Callbacks >::FCleanup |
Definition at line 462 of file ncbi_safe_static.hpp.
typedef CSafeStatic_Callbacks<T>::FCreate CSafeStatic< T, Callbacks >::FCreate |
Callback function types.
The default callback class can be used as a simple wrapper for static functions.
Definition at line 461 of file ncbi_safe_static.hpp.
typedef CSafeStatic_Allocator<T> CSafeStatic< T, Callbacks >::TAllocator |
Definition at line 456 of file ncbi_safe_static.hpp.
typedef Callbacks CSafeStatic< T, Callbacks >::TCallbacks |
Definition at line 453 of file ncbi_safe_static.hpp.
typedef CSafeStaticLifeSpan CSafeStatic< T, Callbacks >::TLifeSpan |
Definition at line 455 of file ncbi_safe_static.hpp.
typedef CSafeStatic<T, TCallbacks> CSafeStatic< T, Callbacks >::TThisType |
Definition at line 454 of file ncbi_safe_static.hpp.
|
inline |
Constructor.
life_span | Life span allows to control destruction of objects. Objects with the same life span are destroyed in the order reverse to their creation order. |
Definition at line 470 of file ncbi_safe_static.hpp.
|
inline |
Constructor.
init | Callback function to be used to create the stored object. |
cleanup | Callback function to be used for additional cleanup. |
life_span | Life span allows to control destruction of objects. Objects with the same life span are destroyed in the order reverse to their creation order. |
Definition at line 484 of file ncbi_safe_static.hpp.
|
inline |
Constructor.
callbacks | Callbacks class instance. |
life_span | Life span allows to control destruction of objects. Objects with the same life span are destroyed in the order reverse to their creation order. |
Definition at line 499 of file ncbi_safe_static.hpp.
|
privatedelete |
|
inline |
Create the variable if not created yet, return the reference.
Definition at line 506 of file ncbi_safe_static.hpp.
Referenced by CUsedTlsBases::ClearAll(), CDiagContextThreadData::CollectDiagMessage(), CCgiApplication::ConfigureDiagFormat(), CNcbiEncrypt::Encrypt(), CObjectIStreamAsnBinary::ExpectStringTag(), get_date_range_rule_collection(), get_date_rule_collection(), GetBioseqInfoStack(), CDataSource::GetDefaultBlobCacheSizeLimit(), GetDefaultCDBErrorHandler(), CUrl::GetDefaultEncoder(), CSequenceAmbigTrimmer::GetDefaultTrimRules(), GetDiagContext(), CCgiRequest::GetEntry(), CGridGlobals::GetInstance(), CDriverManager::GetInstance(), CGraphCache< TData >::GetInstance(), CBlastLMDBManager::GetInstance(), NWinHook::CPEi386::GetInstance(), NWinHook::CApiHookMgr::GetInstance(), CSmallDNS::GetLocalHost(), GetModuleName(), GetObjStore(), CNcbiArguments::GetProgramName(), CCgiContext::GetRequestValue(), CObjectIStream::GetSource(), CUsedTlsBases::Init(), CDbapiConnMgr::Instance(), CTLibContextRegistry::Instance(), NWinHook::COnExitProcess::Instance(), CObjectOStreamAsnBinary::MakeUTF8StringTag(), CSafeStatic< CTls< TValue >, CStaticTls_Callbacks< TValue > >::operator*(), CSafeStatic< CTls< TValue >, CStaticTls_Callbacks< TValue > >::operator->(), CAsyncDiagHandler::Post(), CNcbiEncrypt::Reload(), s_GetCookieNameBannedSymbols(), s_GetFastTime(), s_GetNewIdHandle(), s_GetScopeAutoReleaseEnabled(), s_GetScopeAutoReleaseSize(), s_GetScopePostponeDelete(), CNcbiEncrypt::x_Decrypt(), CObjectIStream::x_GetFixCharsMethodDefault(), CObjectOStream::x_GetFixCharsMethodDefault(), CBV_PoolBlockAlloc< BA, Lock >::x_Instance(), CDiagContext::x_LogEnvironment(), SDiagMessage::x_OldWrite(), and CSharedHitId::x_SetHitId().
|
inline |
Definition at line 515 of file ncbi_safe_static.hpp.
|
inline |
Definition at line 514 of file ncbi_safe_static.hpp.
|
privatedelete |
|
inlinestaticprivate |
Definition at line 545 of file ncbi_safe_static.hpp.
|
inlinestaticprivate |
Definition at line 449 of file ncbi_safe_static.hpp.
Referenced by CSafeStatic< CTls< TValue >, CStaticTls_Callbacks< TValue > >::Get(), and CSafeStatic< CTls< TValue >, CStaticTls_Callbacks< TValue > >::sx_SelfCleanup().
|
inlineprivate |
Definition at line 521 of file ncbi_safe_static.hpp.
Referenced by CSafeStatic< CTls< TValue >, CStaticTls_Callbacks< TValue > >::Get().
|
private |
Definition at line 557 of file ncbi_safe_static.hpp.
Referenced by CSafeStatic< CTls< TValue >, CStaticTls_Callbacks< TValue > >::sx_SelfCleanup(), and CSafeStatic< CTls< TValue >, CStaticTls_Callbacks< TValue > >::x_Init().