NCBI C++ ToolKit
Public Types | Public Member Functions | Private Attributes | List of all members
CSafeStatic_Callbacks< T > Class Template Reference

Search Toolkit Book for CSafeStatic_Callbacks

Initialization and cleanup of a safe-static object. More...

#include <corelib/ncbi_safe_static.hpp>

+ Inheritance diagram for CSafeStatic_Callbacks< T >:

Public Types

typedef T *(* FCreate) (void)
 The default implementation allows to use callback functions rather than a new class. More...
 
typedef void(* FCleanup) (T &value)
 
typedef CSafeStatic_Allocator< TTAllocator
 

Public Member Functions

 CSafeStatic_Callbacks (FCreate create=0, FCleanup cleanup=0)
 The constructor allows to use CSafeStatic_Callbacks as a simple wrapper for static functions. More...
 
TCreate (void)
 Create new object. More...
 
void Cleanup (T &value)
 Perform cleanup before destruction. More...
 

Private Attributes

FCreate m_Create
 
FCleanup m_Cleanup
 

Detailed Description

template<class T>
class CSafeStatic_Callbacks< T >

Initialization and cleanup of a safe-static object.

Must implement at least Create() and Cleanup() methods. Create() must create a new object and return the initialized pointer. Cleanup() can be a no-op. The default implementation allows to use it as a wrapper for static callback functions.

Definition at line 383 of file ncbi_safe_static.hpp.

Member Typedef Documentation

◆ FCleanup

template<class T >
typedef void(* CSafeStatic_Callbacks< T >::FCleanup) (T &value)

Definition at line 389 of file ncbi_safe_static.hpp.

◆ FCreate

template<class T >
typedef T*(* CSafeStatic_Callbacks< T >::FCreate) (void)

The default implementation allows to use callback functions rather than a new class.

Definition at line 388 of file ncbi_safe_static.hpp.

◆ TAllocator

template<class T >
typedef CSafeStatic_Allocator<T> CSafeStatic_Callbacks< T >::TAllocator

Definition at line 390 of file ncbi_safe_static.hpp.

Constructor & Destructor Documentation

◆ CSafeStatic_Callbacks()

template<class T >
CSafeStatic_Callbacks< T >::CSafeStatic_Callbacks ( FCreate  create = 0,
FCleanup  cleanup = 0 
)
inline

The constructor allows to use CSafeStatic_Callbacks as a simple wrapper for static functions.

Parameters
createInitialization function which must create a new object. If null, no special initialization is performed.
cleanupCleanup function. If null, no special cleanup is performed.

Definition at line 399 of file ncbi_safe_static.hpp.

Member Function Documentation

◆ Cleanup()

template<class T >
void CSafeStatic_Callbacks< T >::Cleanup ( T value)
inline

Perform cleanup before destruction.

Parameters
ptrObject to be destroyed using the selected allocator. The cleanup method should not destroy the object itself, just perform any additional actions (e.g. setting some external pointers to null).

Definition at line 414 of file ncbi_safe_static.hpp.

◆ Create()

template<class T >
T* CSafeStatic_Callbacks< T >::Create ( void  )
inline

Create new object.

Returns
The allocated object.

Definition at line 405 of file ncbi_safe_static.hpp.

Member Data Documentation

◆ m_Cleanup

template<class T >
FCleanup CSafeStatic_Callbacks< T >::m_Cleanup
private

◆ m_Create

template<class T >
FCreate CSafeStatic_Callbacks< T >::m_Create
private

The documentation for this class was generated from the following file:
Modified on Fri Sep 20 14:57:50 2024 by modify_doxy.py rev. 669887