11#include <util/containers/Array.h>
12#include <util/misc/ReferenceCounter.h>
13#include <util/misc/CountedReference.h>
72 template <
typename Data>
237 template <
typename Data>
inline
239 {
return (
bool)
data_; }
244 template <
typename Data>
inline
246 {
return ((
bool)
data_ && !
ref_.isAssociated()); }
251 template <
typename Data>
inline
253 {
return ((
bool)
data_ &&
ref_.isAssociated()); }
260 template <
typename Data>
268 template <
typename Data>
276 template <
typename Data>
281 UTIL_THROW(
"Other DRArray must be allocated.");
292 template <
typename Data>
296 if (
ref_.isAssociated()) {
303 <<
"Error: Destroying a DRArray that is referenced by "
304 << nRef <<
" other(s)" << std::endl;
316 template <
typename Data>
320 if (
this == &other)
return *
this;
342 template <
typename Data>
346 if (
dynamic_cast< Array<Data>*
>(
this) == &other)
return *
this;
368 template <
typename Data>
372 UTIL_THROW(
"Attempt to allocate with capacity <= 0");
375 UTIL_THROW(
"Attempt to allocate a DRArray that already has data.");
384 template <
typename Data>
397 template <
typename Data>
425 template <
typename Data>
Data * cArray()
Return a pointer to the underlying C array.
Reference to a shared resource.
void allocate(int capacity)
Allocate an underlying C array, which this container then owns.
void associate(DRArray< Data > &arr, int beginId, int capacity)
Associate this object with a slice of a different DRArray.
DRArray()
Default constructor.
bool isOwner() const
Does this container own a dynamically allocated C array?
DRArray< Data > & operator=(DRArray< Data > const &other)
Assignment from another DRArray<Data> container.
bool isAssociated() const
Is this container associated with a C array it does not own?
DRArray(DRArray< Data > const &other)
Copy constructor.
ReferenceCounter refCounter_
void deallocate()
Dellocate an underlying C array that is owned by this container.
DRArray(int capacity)
Allocating constructor.
void dissociate()
Dissociate this object from an externally owned array slice.
bool isAllocated() const
Return true if this container has data, false otherwise.
static void deallocate(Data *&ptr, size_t size)
Deallocate a C++ array.
static void allocate(Data *&ptr, size_t size)
Allocate a C++ array.
File containing preprocessor macros for error handling.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
Utility classes for scientific computation.