1 #ifndef CORELIB___NCBIOBJ__HPP
2 #define CORELIB___NCBIOBJ__HPP
45 #if defined(NCBI_OS_MSWIN)
112 # define NCBI_OBJECT_LOCKER_EXPORT NCBI_XNCBI_EXPORT
114 # define NCBI_OBJECT_LOCKER_EXPORT
115 # define NCBI_OBJECT_LOCKER_INLINE
234 void*
operator new(
size_t size);
238 void*
operator new[](
size_t size);
242 void operator delete(
void* ptr);
246 void operator delete[](
void* ptr);
250 void*
operator new(
size_t size,
void* place);
254 void operator delete(
void* ptr,
void* place);
347 #ifdef NCBI_COUNTER_UNSIGNED
456 return ObjectStateCanBeDeleted(m_Counter);
463 return ObjectStateIsAllocatedInPool(m_Counter);
470 return ObjectStateReferenced(m_Counter);
477 return ObjectStateReferencedOnlyOnce(m_Counter);
513 #ifdef NCBI_OBJECT_LOCKER_INLINE
518 object->AddReference();
532 object->RemoveReference();
539 object->ReleaseReference();
555 template<
class Interface>
559 void Lock(
const Interface*
object)
const
568 void Relock(
const Interface*
object)
const
575 void Unlock(
const Interface*
object)
const
589 #ifdef NCBI_OBJECT_LOCKER_INLINE
614 template<class C, class Locker = typename CLockerTraits<C>::TLockerType>
class CRef;
615 template<class C, class Locker = typename CLockerTraits<C>::TLockerType>
class CConstRef;
617 template<
class C,
class Locker>
629 template<
class TDerived,
class TLocker>
friend class CRef;
630 template<
class TDerived,
class TLocker>
friend class CConstRef;
653 :
m_Data(locker_value, ptr)
666 template<
class TDerived,
679 ref.m_Data.second() = 0;
683 template<
class TDerived,
689 ref.m_Data.second() = 0;
793 if ( newPtr != oldPtr ) {
910 template<
class TDerived,
921 #ifdef NCBI_COMPILER_MSVC
929 ref.m_Data.second() = 0;
934 template<
class TDerived,
939 ref.m_Data.second() = 0;
1265 template<
class C,
class Locker>
1277 template<
class TDerived,
class TLocker>
friend class CConstRef;
1300 :
m_Data(locker_value, ptr)
1313 template<
class TDerived,
1326 ref.m_Data.second() = 0;
1330 template<
class TDerived,
1336 ref.m_Data.second() = 0;
1340 template<
class TDerived,
1349 template<
class TDerived,
1355 ref.m_Data.second() = 0;
1459 if ( newPtr != oldPtr ) {
1576 template<
class TDerived,
1588 #ifdef NCBI_COMPILER_MSVC
1596 ref.m_Data.second() = 0;
1601 template<
class TDerived,
1606 ref.m_Data.second() = 0;
1611 template<
class TDerived,
1620 template<
class TDerived,
1625 ref.m_Data.second() = 0;
1786 const_cast<C*
>(ptr)));
1803 template<
class T,
class L>
1811 template<
class T,
class L>
1819 template<
class T,
class L>
1827 template<
class T,
class L>
1835 template<
class T,
class L>
1843 template<
class T,
class L>
1851 template<
class T,
class L>
1859 template<
class T,
class L>
1867 #if defined(NCBI_COMPILER_WORKSHOP)
1873 template<
class T,
class L>
1881 template<
class T,
class L>
1889 template<
class T,
class L>
1897 template<
class T,
class L>
1905 template<
class T,
class L>
1913 template<
class T,
class L>
1924 template<
class T,
class L>
1932 template<
class T,
class L>
1940 template<
class T,
class L>
1948 template<
class T,
class L>
1956 template<
class T,
class L>
1964 template<
class T,
class L>
1976 template<
class T,
class L>
1984 template<
class T,
class L>
1992 template<
class T,
class L>
2000 template<
class T,
class L>
2031 template<
class Interface,
class Locker = CInterfaceObjectLocker<Interface> >
2070 template<
class TDerived,
2084 template<
class TDerived,
2106 template<
class TDerived,
2122 template<
class TDerived,
2127 ref.ReleaseOrNull();
2157 template<
class Interface,
class Locker = CInterfaceObjectLocker<Interface> >
2202 template<
class TDerived,
2216 template<
class TDerived,
2225 template<
class TDerived,
2233 template<
class TDerived,
2249 template<
class TDerived,
2265 template<
class TDerived,
2270 ref.ReleaseOrNull();
2275 template<
class TDerived,
2284 template<
class TDerived,
2289 ref.ReleaseOrNull();
2333 template<
typename T>
2339 template<
class... Args>
2341 :
m_Data(std::forward<Args>(args)...)
2370 operator const T& (void)
const
2508 "Weak referenced object must be managed by CRef");
2559 return object->GetPtrProxy();
2568 ref.
Reset(
static_cast<C*
>(
object));
2569 object->RemoveReference();
2582 template <
class Interface>
2598 return object->GetPtrProxy();
2611 ref.
Reset(
dynamic_cast<Interface*
>(
object));
2612 object->RemoveReference();
2630 template<
class Interface,
class Locker>
2656 template<class C, class Locker = typename CWeakLockerTraits<C>::TLockerType>
2777 return !(*
this == right);
2804 template<
class Interface,
class Locker = CWeakInterfaceLocker<Interface> >
2881 template<
class C,
class L>
2883 void swap(NCBI_NS_NCBI::CRef<C,L>& ref1,
2884 NCBI_NS_NCBI::CRef<C,L>& ref2)
2890 template<
class C,
class L>
2892 void swap(NCBI_NS_NCBI::CConstIRef<C,L>& ref1,
2893 NCBI_NS_NCBI::CConstIRef<C,L>& ref2)
2899 template<
class C,
class L>
2901 void swap(NCBI_NS_NCBI::CIRef<C,L>& ref1,
2902 NCBI_NS_NCBI::CIRef<C,L>& ref2)
2908 template<
class C,
class L>
2910 void swap(NCBI_NS_NCBI::CConstRef<C,L>& ref1,
2911 NCBI_NS_NCBI::CConstRef<C,L>& ref2)
2917 template<
class C,
class L>
2919 void swap(NCBI_NS_NCBI::CWeakRef<C,L>& ref1,
2920 NCBI_NS_NCBI::CWeakRef<C,L>& ref2)
2926 template<
class C,
class L>
2928 void swap(NCBI_NS_NCBI::CWeakIRef<C,L>& ref1,
2929 NCBI_NS_NCBI::CWeakIRef<C,L>& ref2)
Interface IAlignRow - abstracts row rendering in Multiple Alignment Widget.
static unsigned char depth[2 *(256+1+29)+1]
bool operator<(const CEquivRange &A, const CEquivRange &B)
const first_type & first() const
const second_type & second() const
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
virtual void x_InitErrCode(CException::EErrCode err_code)
Helper method for initializing error code.
virtual const char * GetErrCodeString(void) const override
Translate from the error code value to its string representation.
#define THROWS_NONE
Do not use 'throw' dynamic exception specification for C++11 compilers.
EErrCode
Error types that an application can generate.
CExpression operator>=(CREATED, time_point)
CExpression operator<=(time_point, CREATED)
void RemoveLastReference(TCount count) const
Remove the last reference.
CConstIRef(TObjectType *ptr, const locker_type &locker_value)
Constructor for explicit type conversion from pointer to object.
CIRef< Interface, Locker > TThisType
void TransferLock(const CObject *object, const CObjectCounterLocker &old_locker) const
CConstRef(const TThisType &ref)
Constructor from an existing CConstRef object.
const T & GetData(void) const
Get data as a reference – const version.
TObjectType * operator->(void) const
Reference operator.
TObjectType * GetNonNullPointer(void)
Get pointer value and throw a null pointer exception if pointer is null.
CWeakObjectLocker< C > TThisType
Alias for this type.
static const int eCounterStep
Skip over the "in heap" bits.
TParent::locker_type locker_type
CConstIRef(CIRef< TDerived > &&ref)
Move constructor from an existing CRef object of derived type.
TPtrProxyType * GetPtrProxy(Interface *ptr) const
Get proxy storage for pointer to object.
TObjectType * GetNCPointerOrNull(void) const THROWS_NONE
Get pointer value.
void Clear(void)
Set pointer to NULL from object's destructor.
void operator-(int) const
TThisType & operator=(TObjectType *ptr)
Assignment operator for const references with right hand side set to a pointer.
CRef< C, Locker > TRefType
Alias for the CRef type.
Locker::TPtrProxyType proxy_type
Alias for pointer proxy type.
bool Empty(void) const THROWS_NONE
Check if CConstRef is empty – not pointing to any object which means having a null value.
TObjectType * GetPointer(void) const THROWS_NONE
Get pointer,.
TThisType & operator=(TThisType &&ref)
Move assignment operator for const references.
CConstIRef(TThisType &&ref)
Move constructor from an existing CConstRef object.
TObjectType & operator*(void)
Dereference operator returning object.
BEGIN_STD_SCOPE void swap(NCBI_NS_NCBI::CRef< C, L > &ref1, NCBI_NS_NCBI::CRef< C, L > &ref2)
CWeakRef(TObjectType *ptr, const locker_type &locker_value)
Constructor for explicit type conversion from pointer to object.
pair_base_member< locker_type, TObjectType * > m_Data
Pointer to object.
Locker locker_type
Define alias for locking type.
CRef(const TThisType &ref)
Copy constructor from an existing CRef object.
void TransferLock(const Interface *object, const CInterfaceObjectLocker< Interface > &old_locker) const
TThisType & operator=(const CRef< TDerived, Locker > &ref)
Assignment operator for references of derived types.
TParent::locker_type locker_type
static void ThrowNullPointerException(void)
TThisType & operator=(const CConstIRef< TDerived > &ref)
Assignment operator for references of derived types.
TThisType & operator=(CRef< TDerived, Locker > &&ref)
Move assignment operator for assigning a reference of derived type.
TPtrProxyType * GetPtrProxy(C *object) const
Get proxy storage for pointer to object.
TThisType & operator=(TThisType &&ref)
Move assignment operator for references.
TThisType & operator=(ENull null)
Assignment operator with right hand side set to ENull.
TThisType & operator=(const CIRef< TDerived > &ref)
Assignment operator for assigning a reference to a const reference.
bool operator!(void) const THROWS_NONE
Check if CRef is empty – not pointing to any object, which means having a null value.
TParent::locker_type locker_type
TThisType & operator=(TObjectType *ptr)
Assignment operator for references with right hand side set to a pointer.
void CleanWeakRefs(void) const
Method cleaning all CWeakRefs referencing at this moment to the object After calling to this method a...
CRef(void) THROWS_NONE
Constructor for null pointer.
TObjectType * AtomicSwap(TObjectType *ptr)
TParent::TObjectType TObjectType
void operator-(TObjectType *) const
bool IsNull(void) const THROWS_NONE
Check if pointer is null – same effect as Empty().
const TObjectType * GetPointer(void) const THROWS_NONE
Get pointer – constant version,.
CObjectCounterLocker TLockerType
Default locker type for CRef.
Uint8 TCount
Alias for value type of counter.
TThisType & operator=(const CIRef< TDerived > &ref)
Assignment operator for references of derived types.
bool NotNull(void) const THROWS_NONE
Check if pointer is not null – same effect as NotEmpty().
CWeakIRef(TObjectType *ptr, const locker_type &locker_value)
Constructor for explicit type conversion from pointer to object.
TObjectType & operator*(void) const
Dereference operator returning object.
void AtomicResetFrom(const TThisType &ref)
Reset reference object to new pointer.
void x_LockFromMoveConstructor(const Locker &src_locker)
static const TCount eCounterBitsPlaceMask
Mask for 'in heap' state flags.
static void ReportLockedObjects(bool clear=false)
Print all currently locked objects of monitored type.
TObjectType * GetNCPointer(void) const THROWS_NONE
Get pointer,.
virtual void DoDeleteThisObject(void)
Mark this object as allocated in heap – object can be deleted.
TThisType & operator=(TObjectType *ptr)
Assignment operator for references with right hand side set to a pointer.
void InvalidObject(void) const
Report object is invalid.
CConstRef< C > ConstRef(const C *object)
Template function for conversion of const object pointer to CConstRef.
CWeakRef< Interface, Locker > TParent
void Unlock(const Interface *object) const
static void StopMonitoring(void)
Stop lock/unlock monitoring.
void x_LockFromMoveConstructor(const Locker &src_locker)
CWeakRef(void)
Constructor for null pointer.
const TObjectType * GetNonNullPointer(void) const
Get pointer value and throw a null pointer exception if pointer is null – constant version.
EAllocFillMode
Control filling of newly allocated memory.
TThisType & operator=(ENull)
Assignment operator with right hand side set to ENull.
void Reset(TObjectType *ptr)
Reset the containing pointer to another object.
static void SetAllocFillMode(EAllocFillMode mode)
TThisType & operator=(ENull null)
Assignment operator with right hand side set to ENull.
void operator-(int) const
CRef< proxy_type > m_Proxy
CConstIRef(void) THROWS_NONE
Constructor for null pointer.
CPtrToObjectProxy(CWeakObject *ptr)
typename std::enable_if< std::is_convertible< T *, TObjectType * >::value > enable_if_derived
Helper template to template enable methods only for derived types.
TObjectType * ReleaseOrNull(void)
Release a reference to the object and return a pointer to the object.
static EAllocFillMode GetAllocFillMode(void)
void InitCounter(void)
Initialize counter.
TObjectType * ReleaseOrNull(void)
Release a reference to the object and return a pointer to the object.
CRef(TObjectType *ptr)
Constructor for explicit type conversion from pointer to object.
bool x_AddWeakReference(CObject *obj)
Add reference to the object in "weak" manner.
virtual ~CObject(void)
Destructor.
void Reset(TObjectType *newPtr)
Reset reference object to new pointer.
void x_MoveAssign(const Locker &src_locker, TObjectType *newPtr)
CConstRef(CRef< TDerived, Locker > &&ref)
Move constructor from an existing CRef object of derived type.
virtual void DoNotDeleteThisObject(void)
Mark this object as not allocated in heap – do not delete this object.
void x_AssignFromRef(TObjectType *newPtr)
CConstRef(TObjectType *ptr)
Constructor for explicit type conversion from pointer to object.
void Swap(TThisType &ref)
Swaps the pointer with another reference.
CRef< C > Ref(C *object)
Helper functions to get CRef<> and CConstRef<> objects.
TObjectType * AtomicSwap(TObjectType *ptr)
TObjectType * GetNonNullNCPointer(void) const
Get pointer value and throw a null pointer exception if pointer is null.
void Relock(const CObject *object) const
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
void Reset(void)
Reset reference object.
CRef< Interface, Locker > TParent
CConstRef(void) THROWS_NONE
Constructor for null pointer.
T & GetData(void)
Get data as a reference.
CIRef< Interface, Locker > TRefType
bool operator!=(const TThisType &right)
operator!= to compare with another CWeakRef
CConstRef(TObjectType *ptr, const locker_type &locker_value)
Constructor for explicit type conversion from pointer to object.
void ReleaseReference(void) const
Remove reference without deleting object.
CObjectFor(Args &&... args)
static bool ObjectStateReferencedOnlyOnce(TCount count)
Check if object can be referenced only once.
CConstIRef(CConstIRef< TDerived > &&ref)
Move constructor from an existing CConstRef object of derived type.
CConstIRef(const CIRef< TDerived > &ref)
Constructor from an existing CRef object of derived type.
TThisType & operator=(const TThisType &ref)
Assignment operator for references.
static NCBI_XNCBI_EXPORT void ThrowNullPointerException(void)
Define method to throw null pointer exception.
C element_type
Define alias element_type.
virtual void DebugDump(CDebugDumpContext ddc, unsigned int depth) const
Define method for dumping debug information.
C element_type
Define alias element_type.
CConstRef(TThisType &&ref)
Move constructor from an existing CConstRef object.
CConstIRef(const TThisType &ref)
Constructor from an existing CConstRef object.
virtual ~CWeakObject(void)
static const TCount eCounterBitsCanBeDeleted
Define possible object states.
TThisType & operator=(const TThisType &ref)
Assignment operator for references.
void AddReference(void) const
Add reference to object.
void Reset(void)
Reset reference object.
const TObjectType & operator*(void) const
Dereference operator returning object – constant version.
bool operator==(const CRef< T, L > &r1, ENull)
Comparison operators for CRef<> and CConstRef<> with ENull.
void UnlockRelease(const CObject *object) const
TThisType & operator=(const TThisType &ref)
Assignment operator for references.
CRef(ENull) THROWS_NONE
Constructor for ENull pointer.
#define NCBI_OBJECT_LOCKER_EXPORT
CObjectCounterLocker – Default locker class for CRef/CConstRef templates, all other locker classes sh...
TRefType Lock(void) const
Lock the object and return reference to it.
void operator-(TObjectType *) const
CConstRef< Interface, Locker > TParent
virtual void DeleteThis(void)
Virtual method "deleting" this object.
TThisType & operator=(TThisType &&ref)
Move assignment operator for references.
void Reset(TObjectType *newPtr)
Reset reference object to new pointer.
CPtrToObjectProxy * GetPtrProxy(void) const
Get pointer to proxy object containing pointer to this object.
bool NotEmpty(void) const THROWS_NONE
Check if CRef is not empty – pointing to an object and has a non-null value.
CIRef< Interface, TThisType > GetLockedObject(TPtrProxyType *proxy) const
Lock the object and return pointer to it stored in the proxy.
TThisType & operator=(const TThisType &ref)
Assignment operator for const references.
CWeakIRef< Interface, Locker > TThisType
void RemoveReference(void) const
Remove reference to object.
bool operator!=(const CRef< T, L > &r1, ENull)
Template operator != function for CRef objects – rhs is null.
const locker_type & GetLocker(void) const
Get reference to locker object.
static bool ObjectStateValid(TCount count)
Check if object state is valid.
static bool ObjectStateReferenced(TCount count)
Check if object can be referenced.
NCBI_XNCBI_EXPORT void CheckReferenceOverflow(TCount count) const
Report that counter has overflowed.
CConstRef< C, Locker > TThisType
Alias for this template type.
CConstIRef< Interface, Locker > TThisType
void Lock(const Interface *object) const
void Swap(TThisType &ref)
Swaps the pointer with another reference.
const TObjectType * GetPointerOrNull(void) const THROWS_NONE
Get pointer value – constant version.
CRef(const CRef< TDerived, Locker > &ref)
Copy constructor from an existing CRef object of derived type.
void AtomicResetFrom(const CConstRef &ref)
Reset reference object to new pointer.
CWeakRef< C, Locker > TThisType
Alias for this type.
static bool ObjectStateIsAllocatedInPool(TCount count)
Check if object is allocated in memory pool.
CRef(TObjectType *ptr, const locker_type &locker_value)
Constructor for explicit type conversion from pointer to object.
void Swap(TThisType &ref)
Swap values of this reference with another.
TThisType & operator=(ENull null)
Assignment from ENull pointer.
T & operator=(const T &data)
Assignment operator.
CConstIRef(TObjectType *ptr)
Constructor for explicit type conversion from pointer to object.
T TObjectType
Define alias for template parameter.
Locker locker_type
Define alias for locking type.
TObjectType * operator->(void)
Reference operator.
void operator+(int) const
bool Referenced(void) const THROWS_NONE
Check if object is referenced.
void operator+(int) const
void UnlockRelease(const Interface *object) const
CConstRef(ENull) THROWS_NONE
Constructor for ENull pointer.
const locker_type & GetLocker(void) const
Get reference to locker object.
TThisType & operator=(TObjectType *ptr)
Assignment operator for references with right hand side set to a pointer.
CObject * x_UpdateCObjectPtr(void)
TRefType Lock(void) const
Lock the object and return reference to it.
bool NotNull(void) const THROWS_NONE
Check if pointer is not null – same effect as NotEmpty().
void Swap(TThisType &ref)
Swaps the pointer with another reference.
void Swap(TThisType &ref)
Swaps the pointer with another reference.
NCBI_EXCEPTION_DEFAULT(CObjectException, CCoreException)
CRef< C, TThisType > GetLockedObject(TPtrProxyType *proxy) const
Lock the object and return pointer to it stored in the proxy.
static void ReportIncompatibleType(const type_info &type)
element_type TObjectType
Define alias TObjectType.
element_type TObjectType
Define alias TObjectType.
bool ReferencedOnlyOnce(void) const THROWS_NONE
Check if object is referenced only once.
TThisType & operator=(ENull)
Assignment operator with right hand side set to ENull.
bool CanBeDeleted(void) const THROWS_NONE
Check if object can be deleted.
TParent::TObjectType TObjectType
TObjectType * GetPointerOrNull(void) const THROWS_NONE
Get pointer value.
const TObjectType * operator->(void) const
Reference operator – constant version.
const TObjectType & GetObject(void) const
Get object – constant version.
CObject & operator=(const CObject &src) THROWS_NONE
Assignment operator.
void x_AssignFromRef(TObjectType *newPtr)
TThisType & operator=(TThisType &&ref)
Move assignment operator for references.
CWeakIRef(TObjectType *ptr)
Constructor for pointer to the interface.
static const TCount eCounterValid
Minimal value for valid objects (reference counter is zero) Must be a single bit value.
CWeakRef(ENull)
Constructor for ENull pointer.
CConstIRef(ENull) THROWS_NONE
Constructor for ENull pointer.
CConstRef(const CConstRef< TDerived, Locker > &ref)
Constructor from an existing CConstRef object of derived type.
void Reset(void)
Reset the containing pointer to null.
CWeakObjectLocker< C > TLockerType
CPtrToObjectProxy TPtrProxyType
Type working as proxy storage for pointer to object.
TObjectType * Release(void)
Release a reference to the object and return a pointer to the object.
CConstRef(CConstRef< TDerived, Locker > &&ref)
Move constructor from an existing CConstRef object of derived type.
static void MonitorObjectType(const type_info &type)
Set monitored object type, e.g.
CPtrToObjectProxy TPtrProxyType
Type working as proxy storage for pointer to object.
bool IsNull(void) const THROWS_NONE
Check if pointer is null – same effect as Empty().
CRef< CPtrToObjectProxy > m_SelfPtrProxy
Proxy object with pointer to this instance.
CIRef(const CIRef< TDerived > &ref)
Constructor from existing ref of derived type.
CWeakIRef(ENull)
Constructor for ENull pointer.
TObjectType & GetObject(void)
Get object.
typename std::enable_if< std::is_convertible< T *, TObjectType * >::value > enable_if_derived
Helper template to template enable methods only for derived types.
CObject * GetLockedObject(void)
Lock the object and return pointer to it.
CIRef(const TThisType &ref)
Constructor from existing ref.
CIRef(TThisType &&ref)
Move constructor from existing ref.
TObjectType * Release(void)
Release a reference to the object and return a pointer to the object.
TThisType & operator=(CIRef< TDerived > &&ref)
Move assignment operator for references of derived types.
CIRef(TObjectType *ptr, const locker_type &locker_value)
Constructor for explicit type conversion from pointer to object.
CWeakRef(TObjectType *ptr)
Constructor for pointer to a particular object.
TParent::TObjectType TObjectType
bool operator!(void) const THROWS_NONE
Check if CConstRef is empty – not pointing to any object, which means having a null value.
bool NotEmpty(void) const THROWS_NONE
Check if CConstRef is not empty – pointing to an object and has a non-null value.
TThisType & operator=(CIRef< TDerived > &&ref)
Move assignment operator for assigning a reference to a const reference.
TThisType & operator=(ENull)
Assignment from ENull pointer.
Locker locker_type
Define alias for locking type.
static void ThrowNullPointerException(void)
TThisType & operator=(const CConstRef< TDerived, Locker > &ref)
Assignment operator for const references of derived types.
void Unlock(const CObject *object) const
C element_type
Define alias element_type.
void x_MoveAssign(const Locker &src_locker, TObjectType *newPtr)
atomic< Uint8 > TCounter
Counter type is CAtomiCounter.
CIRef(ENull) THROWS_NONE
Constructor for ENull pointer.
void AtomicReleaseTo(CConstRef &ref)
Release referenced object to another CConstRef<> object.
CRef(TThisType &&ref)
Move constructor from an existing CRef object.
CWeakInterfaceLocker< Interface > TThisType
Alias for this type.
TThisType & operator=(CConstRef< TDerived, Locker > &&ref)
Move assignment operator for const references of derived types.
static bool ObjectStateCanBeDeleted(TCount count)
Check if object can be deleted.
TThisType & operator=(CRef< TDerived, Locker > &&ref)
Move assignment operator for references of derived types.
const locker_type & GetLocker(void) const
Get reference to locker object.
CRef< C, Locker > TThisType
Alias for this template type.
void Reset(ENull)
Reset the containing pointer to null.
void Lock(const CObject *object) const
CRef(CRef< TDerived, Locker > &&ref)
Move constructor from an existing CRef object of derived type.
CIRef(TObjectType *ptr)
Constructor for explicit type conversion from pointer to object.
CObjectCounterLocker TLockerType
CObject(void)
Constructor.
TObjectType * GetPointerOrNull(void) THROWS_NONE
Get pointer value.
bool operator==(const TThisType &right)
operator== to compare with another CWeakRef
static NCBI_XNCBI_EXPORT void ReportIncompatibleType(const type_info &type)
Report about trying to convert incompatible interface fo CObject.
CWeakIRef(void)
Constructor for null pointer.
CIRef(void) THROWS_NONE
Constructor for null pointer.
static const TCount eCounterBitsInPlainHeap
Heap signature was found.
TObjectType & GetNCObject(void) const
Get object.
pair_base_member< locker_type, TObjectType * > m_Data
Pointer to object.
TThisType & operator=(const CRef< TDerived, Locker > &ref)
Assignment operator for assigning a reference of derived type.
const element_type TObjectType
Define alias TObjectType.
CConstIRef(const CConstIRef< TDerived > &ref)
Constructor from an existing CConstRef object of derived type.
TCounter m_Counter
The actual reference counter.
~CConstRef(void)
Destructor.
static bool ObjectStateUnreferenced(TCount count)
Check if object can be referenced.
CConstRef(const CRef< TDerived, Locker > &ref)
Constructor from an existing CRef object of derived type.
bool IsAllocatedInPool(void) const THROWS_NONE
Check if object is allocated in memory pool (not system heap)
TObjectType & GetObject(void) const
Get object.
void AtomicReleaseTo(TThisType &ref)
Release referenced object to another CRef<> object.
void Relock(const Interface *object) const
void Swap(TThisType &ref)
Swap values of this reference with another.
T m_Data
Data member of template parameter type.
TObjectType * GetNonNullPointer(void) const
Get pointer value and throw a null pointer exception if pointer is null.
CIRef(CIRef< TDerived > &&ref)
Move constructor from existing ref of derived type.
TThisType & operator=(CConstIRef< TDerived > &&ref)
Move assignment operator for references of derived types.
static const TCount eCounterStateMask
Valid object, and object in heap.
bool Empty(void) const THROWS_NONE
Check if CRef is empty – not pointing to any object, which means having a null value.
@ eDeleted
Attempt to delete a deleted object.
@ eRefDelete
Attempt to delete valid reference.
@ eCorrupted
Object corrupted error.
@ eRefOverflow
Reference overflow error.
@ eNoRef
Attempt to access an object that is unreferenced.
uint64_t Uint8
8-byte (64-bit) unsigned integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_STD_SCOPE
Place it for adding new funtionality to STD scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
#define END_STD_SCOPE
End previously defined STD scope.
#define NCBI_XNCBI_EXPORT
const struct ncbi::grid::netcache::search::fields::SIZE size
Defines MS Windows specifics for our "C++" code.
Multi-threading – atomic pointer exchange function.
void * SwapPointers(void *volatile *location, void *new_value)
bool operator>(const typename tree< T, tree_node_allocator >::iterator_base &one, const typename tree< T, tree_node_allocator >::iterator_base &two)