41#ifndef __BASE_REFCNT_HH__
42#define __BASE_REFCNT_HH__
135 static constexpr auto TisConst = std::is_const_v<T>;
212 template <
bool B = TisConst>
231 template <
bool B = TisConst>
264 operator bool()
const {
return data != 0; }
272 return l.get() ==
r.get();
298 return l.get() !=
r.get();
RefCounted(const RefCounted &)
virtual ~RefCounted()
We make the destructor virtual because we're likely to have virtual functions on reference counted ob...
RefCounted()
We initialize the reference count to zero and the first object to take ownership of it must increment...
bool decref() const
Decrement the reference count and return true if all references are gone.
RefCounted & operator=(const RefCounted &)
void incref() const
Increment the reference count.
If you want a reference counting pointer to a mutable object, create it like this:
RefCountingPtr()
Create an empty reference counting pointer.
T & operator*() const
Dereference the pointer.
GEM5_NO_INLINE void del()
Delete the reference to any existing object if it is non NULL.
const RefCountingPtr & operator=(RefCountingPtr &&r)
Move-assign the pointer from another RefCountingPtr.
typename std::conditional_t< TisConst, RefCountingPtr< T >, RefCountingPtr< typename std::add_const< T >::type > > ConstT
bool operator!() const
Check if the pointer is empty.
const RefCountingPtr & operator=(T *p)
Assign a new value to the pointer.
void set(T *d)
Drop the old reference and change it to something new.
static constexpr auto TisConst
~RefCountingPtr()
Destroy the pointer and any reference it may hold.
RefCountingPtr(T *data)
Create a new reference counting pointer to some object (probably something newly created).
RefCountingPtr(const RefCountingPtr &r)
Create a new reference counting pointer by copying another one.
RefCountingPtr(const NonConstT &r)
void copy(T *d)
Copy a new pointer value and increment the reference count if it is a valid pointer.
T * operator->() const
Access a member variable.
const RefCountingPtr & operator=(const RefCountingPtr &r)
Copy the pointer from another RefCountingPtr.
RefCountingPtr(RefCountingPtr &&r)
Move-constructor.
typename std::conditional_t< TisConst, RefCountingPtr< typename std::remove_const< T >::type >, RefCountingPtr< T > > NonConstT
T * get() const
Directly access the pointer itself without taking a reference.
Copyright (c) 2024 Arm Limited All rights reserved.
static bool operator==(const PCStateBase &a, const PCStateBase &b)
static bool operator!=(const PCStateBase &a, const PCStateBase &b)