gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
RefCounted Class Reference

Derive from RefCounted if you want to enable reference counting of this class. More...

#include <refcnt.hh>

Inheritance diagram for RefCounted:
BaseDynInst< Impl > Minor::MinorDynInst StaticInst BaseO3DynInst< Impl > ArmISA::ArmStaticInst PowerISA::PowerStaticInst X86ISA::X86StaticInst ArmISA::BranchEret64 ArmISA::BranchImm64 ArmISA::BranchImmImmReg64 ArmISA::BranchImmReg64 ArmISA::BranchReg64 ArmISA::DataX1Reg2ImmOp ArmISA::DataX1RegImmOp ArmISA::DataX1RegOp ArmISA::DataX2RegImmOp ArmISA::DataX2RegOp ArmISA::DataX3RegOp ArmISA::DataXCondCompImmOp ArmISA::DataXCondCompRegOp ArmISA::DataXCondSelOp ArmISA::DataXERegOp ArmISA::DataXImmOnlyOp ArmISA::DataXImmOp ArmISA::DataXSRegOp ArmISA::MicroOpX ArmISA::MightBeMicro64 ArmISA::PredOp ArmISA::SysDC64 DecoderFaultInst FailUnimplemented McrMrcMiscInst RegRegImmImmOp64 RegRegRegImmOp64 UnknownOp64 WarnUnimplemented PowerISA::CondLogicOp PowerISA::CondMoveOp PowerISA::FloatOp PowerISA::IntOp PowerISA::MemOp PowerISA::MiscOp PowerISA::PCDependentDisassembly X86ISA::MacroopBase X86ISA::X86MicroopBase

Public Member Functions

 RefCounted ()
 We initialize the reference count to zero and the first object to take ownership of it must increment it to one. More...
 
virtual ~RefCounted ()
 We make the destructor virtual because we're likely to have virtual functions on reference counted objects. More...
 
void incref ()
 Increment the reference count. More...
 
void decref ()
 Decrement the reference count and destroy the object if all references are gone. More...
 

Private Member Functions

 RefCounted (const RefCounted &)
 
RefCountedoperator= (const RefCounted &)
 

Private Attributes

int count
 

Detailed Description

Derive from RefCounted if you want to enable reference counting of this class.

If you want to use automatic reference counting, you should use RefCountingPtr<T> instead of regular pointers.

Definition at line 45 of file refcnt.hh.

Constructor & Destructor Documentation

RefCounted::RefCounted ( const RefCounted )
private
RefCounted::RefCounted ( )
inline

We initialize the reference count to zero and the first object to take ownership of it must increment it to one.

Attention
A memory leak will occur if you never assign a newly constructed object to a reference counting pointer.

Definition at line 69 of file refcnt.hh.

virtual RefCounted::~RefCounted ( )
inlinevirtual

We make the destructor virtual because we're likely to have virtual functions on reference counted objects.

Todo:
Even if this were true, does it matter? Shouldn't the derived class indicate this? This only matters if we would ever choose to delete a "RefCounted *" which I doubt we'd ever do. We don't ever delete a "void *".

Definition at line 80 of file refcnt.hh.

Member Function Documentation

void RefCounted::decref ( )
inline

Decrement the reference count and destroy the object if all references are gone.

Definition at line 87 of file refcnt.hh.

References count.

void RefCounted::incref ( )
inline

Increment the reference count.

Definition at line 83 of file refcnt.hh.

References count.

RefCounted& RefCounted::operator= ( const RefCounted )
private

Member Data Documentation

int RefCounted::count
mutableprivate

The documentation for this class was generated from the following file:

Generated on Fri Jun 9 2017 13:04:17 for gem5 by doxygen 1.8.6