Mantid
|
Implements a copy on write data template. More...
#include <cow_ptr.h>
Public Types | |
using | ptr_type = std::shared_ptr< DataType > |
typedef for the storage More... | |
using | value_type = DataType |
typedef for the data type More... | |
Public Member Functions | |
DataType & | access () |
Access function. More... | |
cow_ptr () | |
Constructor : creates new data() object. More... | |
cow_ptr (const cow_ptr< DataType > &) noexcept | |
Copy constructor : double references the data object. More... | |
cow_ptr (const ptr_type &resourceSptr) noexcept | |
cow_ptr (cow_ptr< DataType > &&other) noexcept | |
cow_ptr (DataType *resourcePtr) | |
Constructor : creates a new cow_ptr around the resource resource is a sink. More... | |
cow_ptr (ptr_type &&resourceSptr) noexcept | |
constexpr | cow_ptr (std::nullptr_t) noexcept |
Constructs a cow_ptr with no managed object, i.e. empty cow_ptr. More... | |
const DataType * | get () const noexcept |
Returns the stored pointer. More... | |
operator bool () const noexcept | |
Checks if *this stores a non-null pointer, i.e. whether get() != nullptr. More... | |
bool | operator!= (const cow_ptr< DataType > &A) const noexcept |
Based on ptr inequality. More... | |
const DataType & | operator* () const |
Pointer dereference access. More... | |
const DataType * | operator-> () const |
indirectrion dereference access More... | |
cow_ptr< DataType > & | operator= (const cow_ptr< DataType > &) noexcept |
Assignment operator : double references the data object maybe drops the old reference. More... | |
cow_ptr< DataType > & | operator= (const ptr_type &) noexcept |
Assignment operator : double references the data object maybe drops the old reference. More... | |
cow_ptr< DataType > & | operator= (cow_ptr< DataType > &&rhs) noexcept |
bool | operator== (const cow_ptr< DataType > &A) const noexcept |
Based on ptr equality. More... | |
bool | unique () const noexcept |
Checks if *this is the only shared_ptr instance managing the current object, i.e. More... | |
long | use_count () const noexcept |
Returns the number of different shared_ptr instances (this included) managing the current object. More... | |
Private Attributes | |
std::mutex | copyMutex |
ptr_type | Data |
Real object Ptr. More... | |
Implements a copy on write data template.
This version works only on data that is created via new(). It is thread safe and works in the Standard template libraries (but appropriate functionals are needed for sorting etc.).
Renamed from RefControl on the 11/12/2007, as it was agreed that copy on write pointer better described the functionality of this class.
The underlying data can be accessed via the normal pointer semantics but call the access function if the data is required to be modified.
using Mantid::Kernel::cow_ptr< DataType >::ptr_type = std::shared_ptr<DataType> |
using Mantid::Kernel::cow_ptr< DataType >::value_type = DataType |
|
noexcept |
|
noexcept |
|
explicit |
Mantid::Kernel::cow_ptr< DataType >::cow_ptr |
|
inlineconstexprnoexcept |
|
noexcept |
|
inlinenoexcept |
DataType & Mantid::Kernel::cow_ptr< DataType >::access |
Access function.
If data is shared, creates a copy of Data so that it can be modified.
In certain situations this function is not thread safe. Specifically it is not thread safe in the presence of a simultaneous cow_ptr copy. Copies of the underlying data are only made when the reference count > 1.
Definition at line 147 of file cow_ptr.h.
Referenced by Mantid::Algorithms::RebinByTimeBase::exec(), Mantid::Algorithms::Transpose::exec(), and Mantid::Algorithms::XDataConverter::exec().
|
inlinenoexcept |
Returns the stored pointer.
Definition at line 69 of file cow_ptr.h.
References Mantid::Kernel::cow_ptr< DataType >::Data.
|
inlineexplicitnoexcept |
Checks if *this stores a non-null pointer, i.e. whether get() != nullptr.
Definition at line 72 of file cow_ptr.h.
References Mantid::Kernel::cow_ptr< DataType >::Data.
|
inlinenoexcept |
Based on ptr inequality.
Definition at line 85 of file cow_ptr.h.
References Mantid::Kernel::cow_ptr< DataType >::Data.
|
inline |
Pointer dereference access.
Definition at line 82 of file cow_ptr.h.
References Mantid::Kernel::cow_ptr< DataType >::Data.
|
inline |
indirectrion dereference access
Definition at line 83 of file cow_ptr.h.
References Mantid::Kernel::cow_ptr< DataType >::Data.
|
noexcept |
|
noexcept |
|
inlinenoexcept |
Definition at line 62 of file cow_ptr.h.
References Mantid::Kernel::cow_ptr< DataType >::Data, and rhs.
|
inlinenoexcept |
Based on ptr equality.
Definition at line 84 of file cow_ptr.h.
References Mantid::Kernel::cow_ptr< DataType >::Data.
|
inlinenoexcept |
Checks if *this is the only shared_ptr instance managing the current object, i.e.
whether use_count() == 1.
Definition at line 80 of file cow_ptr.h.
References Mantid::Kernel::cow_ptr< DataType >::Data.
|
inlinenoexcept |
Returns the number of different shared_ptr instances (this included) managing the current object.
If there is no managed object, 0 is returned.
Definition at line 76 of file cow_ptr.h.
References Mantid::Kernel::cow_ptr< DataType >::Data.
|
private |
|
private |
Real object Ptr.
Definition at line 47 of file cow_ptr.h.
Referenced by Mantid::Kernel::cow_ptr< DataType >::get(), Mantid::Kernel::cow_ptr< DataType >::operator bool(), Mantid::Kernel::cow_ptr< DataType >::operator!=(), Mantid::Kernel::cow_ptr< DataType >::operator*(), Mantid::Kernel::cow_ptr< DataType >::operator->(), Mantid::Kernel::cow_ptr< DataType >::operator=(), Mantid::Kernel::cow_ptr< DataType >::operator==(), Mantid::Kernel::cow_ptr< DataType >::unique(), and Mantid::Kernel::cow_ptr< DataType >::use_count().