1#ifndef PSCF_FFTW_DR_ARRAY_TPP
2#define PSCF_FFTW_DR_ARRAY_TPP
11#include <util/misc/Memory.h>
23 template <
typename Data>
30 template <
typename Data>
37 template <
typename Data>
41 UTIL_THROW(
"Other FftwDRArray must be allocated.");
50 template <
typename Data>
54 if (ref_.isAssociated()) {
63 <<
"Error: Destroying FftwDRArray that is referenced by "
64 << nr <<
" other(s), thus creating dangling references."
76 template <
typename Data>
81 if (
this == &other)
return *
this;
101 template <
typename Data>
106 if (
dynamic_cast< Array<Data>*
>(
this) == &other)
return *
this;
126 template <
typename Data>
130 UTIL_THROW(
"Attempt to allocate with capacity <= 0");
133 UTIL_THROW(
"Attempt to allocate a FftwDRArray that has data.");
143 template <
typename Data>
158 template <
typename Data>
176 ref_.associate(owner);
186 template <
typename Data>
193 template <
typename Data>
Dynamic reference counted array for use with FFTW library.
virtual void deallocate()
Dellocate an underlying C array that is owned by this container.
FftwDRArray< Data > & operator=(FftwDRArray< Data > const &other)
Assignment from another FftwDRArray<Data> container.
void dissociate()
Dissociate this object from an externally owned array slice.
FftwDRArray()
Default constructor.
void associate(FftwDRArray< Data > &other, int beginId, int capacity)
Associate this object with a slice of a different FftwDRArray.
virtual ~FftwDRArray()
Destructor.
void allocate(int capacity)
Allocate an underlying C array, which this container then owns.
bool isOwner() const
Does this container own a dynamically allocated C array?
Data * cArray()
Return a pointer to the underlying C array (non-const data).
Data * data_
Pointer to an array of Data elements.
int capacity() const
Return allocated size.
bool isAllocated() const
Does this array have associated data?
int capacity_
Allocated size of the data_ array.
static void sub(size_t size)
Subtract size of a newly deleted array in bytes from total.
static void add(size_t size)
Add size of a newly allocated array in bytes to total.
bool hasRefs() const
Does this counter have references (is nRef > 0)?
int nRef() const
Get the number of references to a shareable resource.
#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.
PSCF package top-level namespace.