#include <ncbiobj.hpp>
Inheritance diagram for CObject:


Define the CObject which stores the reference count and the object.
CObject inherits from CDebugDumpable the ability to "dump" diagnostic information useful for debugging.
Definition at line 154 of file ncbiobj.hpp.
Public Types | |
| typedef CObjectCounterLocker | TLockerType |
| Default locker type for CRef. | |
| enum | EAllocFillMode { eAllocFillNone = 1, eAllocFillZero, eAllocFillPattern } |
| Controll filling of newly allocated memory. More... | |
Public Member Functions | |
| CObject (void) | |
| Constructor. | |
| CObject (const CObject &src) | |
| Copy constructor. | |
| virtual | ~CObject (void) |
| Destructor. | |
| CObject & | operator= (const CObject &src) THROWS_NONE |
| Assignment operator. | |
| bool | CanBeDeleted (void) const THROWS_NONE |
| Check if object can be deleted. | |
| bool | IsAllocatedInPool (void) const THROWS_NONE |
| Check if object is allocated in memory pool (not system heap). | |
| bool | Referenced (void) const THROWS_NONE |
| Check if object is referenced. | |
| bool | ReferencedOnlyOnce (void) const THROWS_NONE |
| Check if object is referenced only once. | |
| void | AddReference (void) const |
| Add reference to object. | |
| void | RemoveReference (void) const |
| Remove reference to object. | |
| void | ReleaseReference (void) const |
| Remove reference without deleting object. | |
| virtual void | DoNotDeleteThisObject (void) |
| Mark this object as not allocated in heap -- do not delete this object. | |
| virtual void | DoDeleteThisObject (void) |
| Mark this object as allocated in heap -- object can be deleted. | |
| void * | operator new (size_t size) |
| Define new operator for memory allocation. | |
| void * | operator new[] (size_t size) |
| Define new[] operator for 'array' memory allocation. | |
| void | operator delete (void *ptr) |
| Define delete operator for memory deallocation. | |
| void | operator delete[] (void *ptr) |
| Define delete[] operator for memory deallocation. | |
| void * | operator new (size_t size, void *place) |
| Define new operator. | |
| void | operator delete (void *ptr, void *place) |
| Define delete operator. | |
| void * | operator new (size_t size, CObjectMemoryPool *place) |
| Define new operator using memory pool. | |
| void | operator delete (void *ptr, CObjectMemoryPool *place) |
| Define delete operator. | |
| virtual void | DebugDump (CDebugDumpContext ddc, unsigned int depth) const |
| Define method for dumping debug information. | |
Static Public Member Functions | |
| static void | ThrowNullPointerException (void) |
| Define method to throw null pointer exception. | |
| static void | ThrowNullPointerException (const type_info &type) |
| static EAllocFillMode | GetAllocFillMode (void) |
| static void | SetAllocFillMode (EAllocFillMode mode) |
| static void | SetAllocFillMode (const string &value) |
| Set mode from configuration parameter value. | |
Protected Member Functions | |
| virtual void | DeleteThis (void) const |
| Virtual method "deleting" this object. | |
Private Types | |
| typedef CAtomicCounter | TCounter |
| Counter type is CAtomiCounter. | |
| typedef TCounter::TValue | TCount |
| Alias for value type of counter. | |
| enum | EObjectState { eStateBitsInHeap = 1 << 0, eStateBitsHeapSignature = 1 << 1, eStateBitsInHeapMask = eStateBitsInHeap | eStateBitsHeapSignature, eStateBitsValid = (unsigned int)(1 << (sizeof(TCount) * 8 - 2)), eStateMask = eStateBitsValid | eStateBitsInHeapMask, eCounterStep = 1 << 2, eCounterValid = eStateBitsValid, eCounterValidRef1 = eCounterValid + eCounterStep, eCounterValidRef2 = eCounterValid + eCounterStep*2, eInitCounterNotInHeap = eStateBitsValid, eInitCounterInHeap, eInitCounterInPool = eStateBitsValid | eStateBitsInHeap, eInitCounterInStack = eStateBitsValid | eStateBitsHeapSignature, eMagicCounterDeleted = 0x5b4d9f34 & ~eStateMask, eMagicCounterNew = 0x3423cb13 & ~eStateMask, eMagicCounterPoolDeleted = 0x4229775b & ~eStateMask, eMagicCounterPoolNew = 0x54917ec2 & ~eStateMask } |
| Define possible object states. More... | |
Private Member Functions | |
| void | InitCounter (void) |
| Initialize counter. | |
| void | RemoveLastReference (TCount count) const |
| Remove the last reference. | |
| void | InvalidObject (void) const |
| Report object is invalid. | |
| void | CheckReferenceOverflow (TCount count) const |
| Report that counter has overflowed. | |
Static Private Member Functions | |
| static bool | ObjectStateValid (TCount count) |
| Check if object state is valid. | |
| static bool | ObjectStateCanBeDeleted (TCount count) |
| Check if object can be deleted. | |
| static bool | ObjectStateIsAllocatedInPool (TCount count) |
| Check if object is allocated in memory pool. | |
| static bool | ObjectStateUnreferenced (TCount count) |
| Check if object can be referenced. | |
| static bool | ObjectStateReferenced (TCount count) |
| Check if object can be referenced. | |
| static bool | ObjectStateReferencedOnlyOnce (TCount count) |
| Check if object can be referenced only once. | |
Private Attributes | |
| TCounter | m_Counter |
| The actual reference counter. | |
Friends | |
| class | CObjectMemoryPool |
| class | CObjectEx |
|
|
|
Counter type is CAtomiCounter.
Reimplemented in CGBProject_Base, and CGBProject_ver2_Base. Definition at line 284 of file ncbiobj.hpp. |
|
|
Default locker type for CRef.
Definition at line 158 of file ncbiobj.hpp. |
|
|
Controll filling of newly allocated memory. Default mode is eAllocFillNone if not changed by configuration. eAllocFillNone - do not fill at all this mode is faster and is necessary to avoid interference with memory checker programs like valgrind. eAllocFillZero - fill new memory with zeros (old default mode) eAllocFillPattern - fill with non-zero pattern Definition at line 261 of file ncbiobj.hpp. |
|
|
Define possible object states. When TCounter is signed, all valid values start with 01; when it is unsigned, they start with 1. In other words, when TCounter is signed, the msb (most significant bit) is 0, and the bit after that is a 1; and if the counter is unsigned, then the msb is 1. Least significant bits are the "memory" bits and the most significant bit (or the one after it) is the "valid" bit. The following bit positions have special significance:
Possible bit patterns:
Definition at line 308 of file ncbiobj.hpp. |
|
|
Constructor.
Definition at line 435 of file ncbiobj.cpp. References InitCounter(). Referenced by CObjectMemoryPool::Delete(). |
|
|
Copy constructor.
Definition at line 441 of file ncbiobj.cpp. References InitCounter(). |
|
|
Destructor.
Definition at line 453 of file ncbiobj.cpp. References _ASSERT, eMagicCounterDeleted, eMagicCounterPoolDeleted, ERR_POST_X, CAtomicCounter::Get(), m_Counter, ObjectStateIsAllocatedInPool(), ObjectStateReferenced(), ObjectStateUnreferenced(), ObjectStateValid(), ObjFatal, and CAtomicCounter::Set(). |
|
|
Report that counter has overflowed.
Definition at line 488 of file ncbiobj.cpp. References eMagicCounterDeleted, eMagicCounterPoolDeleted, NCBI_THROW, and ObjectStateValid(). Referenced by AddReference(). |
|
||||||||||||
|
Define method for dumping debug information.
Implements CDebugDumpable. Reimplemented in CBLAST_SequenceBlk, CBlastQueryInfo, CQuerySetUpOptions, CLookupTableOptions, CLookupTableWrap, CBlastInitialWordOptions, CBlastInitialWordParameters, CBlast_ExtendWord, CBlastExtensionOptions, CBlastExtensionParameters, CBlastHitSavingOptions, CBlastHitSavingParameters, CPSIBlastOptions, CBlastDatabaseOptions, CBlastScoreBlk, CBlastScoringOptions, CBlastScoringParameters, CBlastEffectiveLengthsOptions, CBlastEffectiveLengthsParameters, CBlastGapAlignStruct, CBlastHSPResults, CPSIMsa, CPSIMatrix, CPSIDiagnosticsRequest, CPSIDiagnosticsResponse, CBlastSeqSrc, CBlastSeqSrcIterator, CBlast_Message, CBlastMaskLoc, CBlastSeqLoc, CSBlastProgress, CBlastOptions, CBlastDbDataLoader, CRemoteBlastDbDataLoader, CSerialObject, and CBlastOptionsLocal. Definition at line 669 of file ncbiobj.cpp. References CDebugDumpContext::Log(), and CDebugDumpContext::SetFrame(). Referenced by CSerialObject::DebugDump(). |
|
|
Virtual method "deleting" this object. Method is called whenever by all other indicators this object should be deleted. These indicators are: last reference to the object is removed, object created on heap and method DoNotDeleteThisObject() was not called. Default implementation actually deletes the object, but derived classes are free to do whatever they want (e.g. if they know that they are allocated at some pool they should return themselves to this pool). Reimplemented in CRWLockHolder, and CNCBlobLockHolder. Definition at line 512 of file ncbiobj.cpp. References _ASSERT, CObjectMemoryPool::Delete(), eInitCounterInHeap, eInitCounterInPool, CAtomicCounter::Get(), and m_Counter. Referenced by RemoveLastReference(). |
|
|
Mark this object as allocated in heap -- object can be deleted.
Definition at line 616 of file ncbiobj.cpp. References CAtomicCounter::Add(), eMagicCounterDeleted, eMagicCounterPoolDeleted, ERR_POST_X, eStateBitsHeapSignature, eStateBitsInHeap, eStateBitsValid, CAtomicCounter::Get(), m_Counter, NCBI_THROW, ObjectStateValid(), and ObjFatal. Referenced by CObjectMemoryPoolChunk::CreateChunk(), CThread::CThread(), and CTls< TValue >::CTls(). |
|
|
Mark this object as not allocated in heap -- do not delete this object.
Definition at line 587 of file ncbiobj.cpp. References CAtomicCounter::Add(), eMagicCounterDeleted, eMagicCounterPoolDeleted, eStateBitsInHeapMask, CAtomicCounter::Get(), m_Counter, NCBI_THROW, and ObjectStateValid(). |
|
|
Definition at line 203 of file ncbiobj.cpp. |
|
|
Initialize counter.
Definition at line 370 of file ncbiobj.cpp. References eInitCounterInHeap, eInitCounterInPool, eInitCounterInStack, eInitCounterNotInHeap, eMagicCounterNew, eMagicCounterPoolNew, GetSecondCounter(), m_Counter, CAtomicCounter::m_Value, CAtomicCounter::Set(), and STACK_THRESHOLD. Referenced by CObject(). |
|
|
Report object is invalid. Example: Attempt to use a deleted object. |
|
||||||||||||
|
Define delete operator.
Definition at line 331 of file ncbiobj.cpp. References _ASSERT, CObjectMemoryPool::Deallocate(), eMagicCounterPoolDeleted, eMagicCounterPoolNew, CAtomicCounter::Get(), and m_Counter. |
|
||||||||||||
|
Define delete operator.
|
|
|
Define delete operator for memory deallocation.
Definition at line 275 of file ncbiobj.cpp. References _ASSERT, eMagicCounterDeleted, eMagicCounterNew, CAtomicCounter::Get(), m_Counter, and operator(). |
|
|
Define delete[] operator for memory deallocation.
Definition at line 359 of file ncbiobj.cpp. References operator(). |
|
||||||||||||
|
Define new operator using memory pool.
Definition at line 313 of file ncbiobj.cpp. References _ASSERT, CObjectMemoryPool::Allocate(), eMagicCounterPoolNew, GetSecondCounter(), m_Counter, operator new(), and CAtomicCounter::Set(). |
|
||||||||||||
|
Define new operator.
Definition at line 290 of file ncbiobj.cpp. References _ASSERT, and sx_FillNewMemory(). |
|
|
Define new operator for memory allocation.
Definition at line 245 of file ncbiobj.cpp. References _ASSERT, eMagicCounterNew, GetSecondCounter(), m_Counter, operator(), CAtomicCounter::Set(), and sx_FillNewMemory(). Referenced by CObjectMemoryPoolChunk::CreateChunk(), and operator new(). |
|
|
Define new[] operator for 'array' memory allocation.
Definition at line 347 of file ncbiobj.cpp. References operator(), and sx_FillNewMemory(). |
|
|
Remove reference without deleting object.
Definition at line 563 of file ncbiobj.cpp. References CAtomicCounter::Add(), eCounterStep, eMagicCounterDeleted, eMagicCounterPoolDeleted, m_Counter, NCBI_THROW, and ObjectStateValid(). Referenced by CInterfaceObjectLocker< Interface >::UnlockRelease(), CObjectCounterLocker::UnlockRelease(), and impl::CDBHandlerStack::CUserHandlerWrapper::CObjGuard::~CObjGuard(). |
|
|
Remove the last reference.
Definition at line 527 of file ncbiobj.cpp. References CAtomicCounter::Add(), DeleteThis(), eCounterStep, eMagicCounterDeleted, eMagicCounterPoolDeleted, ERR_POST_X, m_Counter, ObjectStateCanBeDeleted(), ObjectStateUnreferenced(), ObjectStateValid(), and ObjFatal. Referenced by RemoveReference(). |
|
|
Set mode from configuration parameter value.
Definition at line 215 of file ncbiobj.cpp. References ALLOC_FILL_MODE_DEFAULT, NStr::CompareNocase(), eAllocFillNone, eAllocFillPattern, and eAllocFillZero. |
|
|
Definition at line 209 of file ncbiobj.cpp. Referenced by CNcbiApplication::x_HonorStandardSettings(). |
|
|
Definition at line 696 of file ncbiobj.cpp. References Abort(). |
|
|
Define method to throw null pointer exception. Static method through which all CRef<> / CConstRef<> null pointer throws travel. This is done to avoid an inline throw. Definition at line 683 of file ncbiobj.cpp. References Abort(). Referenced by CConstRef< IAppJobError, CInterfaceObjectLocker< IAppJobError > >::ThrowNullPointerException(), and CRef< CQueueItem >::ThrowNullPointerException(). |
|
|
Definition at line 364 of file ncbiobj.hpp. |
|
|
Definition at line 363 of file ncbiobj.hpp. |
|
|
The actual reference counter.
Reimplemented in CGBProject_Base, CGBProject_ver2_Base, and CSeqIdGenerator. Definition at line 404 of file ncbiobj.hpp. Referenced by AddReference(), CanBeDeleted(), DeleteThis(), DoDeleteThisObject(), DoNotDeleteThisObject(), InitCounter(), IsAllocatedInPool(), operator delete(), operator new(), Referenced(), ReferencedOnlyOnce(), ReleaseReference(), RemoveLastReference(), RemoveReference(), CObjectEx::WeakAddReference(), and ~CObject(). |
1.4.6
Modified on Mon Dec 07 16:23:35 2009 by modify_doxy.py rev. 173732