.TH "sc::RefCount" 3 "Sun Oct 4 2020" "Version 2.3.1" "MPQC" \" -*- nroff -*- .ad l .nh .SH NAME sc::RefCount \- The base class for all reference counted objects\&. .SH SYNOPSIS .br .PP .PP \fC#include \fP .PP Inherits \fBsc::Identity\fP\&. .PP Inherited by \fBsc::CorrelationTable\fP, \fBsc::DescribedClass\fP, \fBsc::DipoleData\fP, \fBsc::Edge\fP, \fBsc::EfieldDotVectorData\fP, \fBsc::FJT\fP, \fBsc::GenPetite4\fP, \fBsc::Int1eCCA\fP, \fBsc::Int1eCints\fP, \fBsc::Int1eV3\fP, \fBsc::Int2eCCA\fP, \fBsc::Int2eCints\fP, \fBsc::Int2eV3\fP, \fBsc::KeyVal\fP, \fBsc::KeyValValue\fP, \fBsc::MOPairIter\fP, \fBsc::NonlinearTransform\fP, \fBsc::OneBodyDerivInt\fP, \fBsc::OneBodyInt\fP, \fBsc::OneBodyIntIter\fP, \fBsc::OneBodyOneCenterDerivInt\fP, \fBsc::OneBodyOneCenterInt\fP, \fBsc::OneBodySOInt\fP, \fBsc::PetiteList\fP, \fBsc::PointChargeData\fP, \fBsc::PrimPairsCints\fP, \fBsc::PsiFile11\fP, \fBsc::PsiInput\fP, \fBsc::R12Amplitudes\fP, \fBsc::SCMatrixSubblockIter\fP, \fBsc::ShellExtent\fP, \fBsc::SOBasis\fP, \fBsc::ThreadLock\fP, \fBsc::Triangle\fP, \fBsc::TriInterpCoef\fP, \fBsc::TwoBodyDerivInt\fP, \fBsc::TwoBodyInt\fP, \fBsc::TwoBodySOInt\fP, \fBsc::TwoBodyThreeCenterDerivInt\fP, \fBsc::TwoBodyThreeCenterInt\fP, \fBsc::TwoBodyTwoCenterDerivInt\fP, \fBsc::TwoBodyTwoCenterInt\fP, \fBsc::Vertex\fP, and \fBsc::X\fP\&. .SS "Public Member Functions" .in +1c .ti -1c .RI "int \fBlock_ptr\fP () const" .br .RI "Lock this object\&. " .ti -1c .RI "int \fBunlock_ptr\fP () const" .br .RI "Unlock this object\&. " .ti -1c .RI "void \fBuse_locks\fP (bool inVal)" .br .RI "start and stop using locks on this object " .ti -1c .RI "refcount_t \fBnreference\fP () const" .br .RI "Return the reference count\&. " .ti -1c .RI "refcount_t \fBreference\fP ()" .br .RI "Increment the reference count and return the new count\&. " .ti -1c .RI "refcount_t \fBdereference\fP ()" .br .RI "Decrement the reference count and return the new count\&. " .ti -1c .RI "int \fBmanaged\fP () const" .br .ti -1c .RI "void \fBunmanage\fP ()" .br .RI "Turn off the reference counting mechanism for this object\&. " .ti -1c .RI "int \fBmanaged\fP () const" .br .RI "Return 1 if the object is managed\&. Otherwise return 0\&. " .in -1c .SS "Protected Member Functions" .in +1c .ti -1c .RI "\fBRefCount\fP (const \fBRefCount\fP &)" .br .ti -1c .RI "\fBRefCount\fP & \fBoperator=\fP (const \fBRefCount\fP &)" .br .in -1c .SH "Detailed Description" .PP The base class for all reference counted objects\&. If multiple inheritance is used, \fBRefCount\fP must be virtually inherited from, otherwise references to invalid memory will likely result\&. .PP Reference counting information is usually maintained by smart pointer classes \fBRef\fP, however this mechanism can be supplemented or replaced by directly using the public interface to \fBRefCount\fP\&. .PP The \fBunmanage()\fP member is only needed for special cases where memory management must be turned off\&. For example, if a reference counted object is created on the stack, memory management mechanisms based on reference counting must be prohibited from deleting it\&. The \fBunmanage()\fP member accomplishes this, but a better solution would be to allocate the object on the heap with new and let a smart pointer manage the memory for the object\&. .PP When using a debugger to look at reference counted objects the count is maintained in the \fIreference_count\fP member\&. However, this member is encoded so that memory overwrites can be sometimes detected\&. Thus, interpretation of \fIreference_count\fP is not always straightforward\&. .SH "Member Function Documentation" .PP .SS "void sc::RefCount::unmanage ()\fC [inline]\fP" .PP Turn off the reference counting mechanism for this object\&. The value returned by \fBnreference()\fP will always be 1 after this is called\&. The ability to \fBunmanage()\fP objects must be turned on at compile time by defining REF_MANAGE\&. There is a slight performance penalty\&. .SH "Author" .PP Generated automatically by Doxygen for MPQC from the source code\&.