StrongCOWRefHandler Class Reference

#include <baseref.h>

Inheritance diagram for StrongCOWRefHandler:

Detailed Description

StrongCOWRefHandler has to be used as template argument for BaseRef to obtain a reference to objects which support reference counting, and which shall have copy-on-write semantics. It shares the basic behavior of StrongRefHandler, but if a modification of the object is to be made through the reference, or if BaseRef::MakeWritable() is invoked, it is checked by invocation of GetReferenceCount() on the object if the reference is exclusive or not. If so, the object can be modified directly, otherwise a copy is made and set as new pointee of the reference. This way the other references to the original object aren't affected by the modification. If the allocation of a copy fails the reference will be set to null.

Classes

struct  MakeWritableHelper
 
struct  MakeWritableHelper< FlexibleArray< T, COUNT > >
 
struct  MakeWritableHelper< T, typename T::GenericContainerInterfaceMarker >
 

Static Public Member Functions

template<typename R >
static MAXON_ATTRIBUTE_NO_INLINE ResultRef< typename std::remove_const< typename R::ReferencedType >::typeMakeWritable (R &ref, Bool resetOnError)
 
template<typename R >
static MAXON_ATTRIBUTE_NO_INLINE ResultRef< typename std::remove_const< typename R::ReferencedType >::typeMakeWritableDontCopy (R &ref)
 
- Static Public Member Functions inherited from StrongRefHandler
template<typename T >
static void InitialReference (const T *o)
 
template<typename T >
static void AddReference (const T *o)
 
template<typename T >
static MAXON_ATTRIBUTE_NO_INLINE void RemoveReference (const T *o)
 
template<typename T >
static void AddWeakReference (const T *o, WeakRefBase &weakRef)
 
template<typename T >
static Bool CreateStrongReference (const T *o)
 
template<typename T >
static StrongReferenceCounterGetReferenceCounter (const T *o)
 
template<typename R >
static ResultRef< typename R::ReferencedType > MakeWritable (R &ref, Bool resetOnError)
 
template<typename T >
static void ChangeTarget (T *&o, T *newTarget)
 
template<typename T >
static void ChangeTarget (T *&o, ResultMemT< T * > newTarget)
 
template<typename T >
static void MoveTarget (T *&srcReference, T *&dstReference)
 

Static Public Attributes

static constexpr VALUEKIND KIND
 
- Static Public Attributes inherited from StrongRefHandler
static constexpr VALUEKIND KIND
 

Member Function Documentation

◆ MakeWritable()

static MAXON_ATTRIBUTE_NO_INLINE ResultRef<typename std::remove_const<typename R::ReferencedType>::type> MakeWritable ( R &  ref,
Bool  resetOnError 
)
static
Parameters
[in]resetOnErrorIf true (the default), the reference will be reset when the copy fails. If false, the reference will stay the same, but the function returns nullptr.

◆ MakeWritableDontCopy()

static MAXON_ATTRIBUTE_NO_INLINE ResultRef<typename std::remove_const<typename R::ReferencedType>::type> MakeWritableDontCopy ( R &  ref)
static

Member Data Documentation

◆ KIND

constexpr VALUEKIND KIND
staticconstexpr