TECA
The Toolkit for Extreme Climate Analysis
teca_variant_array_impl< T > Class Template Reference

The concrete implementation of our type agnostic container for contiguous arrays. More...

#include <teca_variant_array_impl.h>

Inheritance diagram for teca_variant_array_impl< T >:
[legend]
Collaboration diagram for teca_variant_array_impl< T >:
[legend]

Public Types

using element_type = T
 
using pointer_type = std::shared_ptr< T >
 
- Public Types inherited from teca_variant_array
using allocator = hamr::buffer_allocator
 allocator types More...
 

Public Member Functions

int set_allocator (allocator alloc) override
 
std::string get_class_name () const override
 Returns the name of the class in a human readable form. More...
 
void initialize () override
 Initialize all elements with T() More...
 
void synchronize () const override
 Sycnhronize the stream used for data movement. More...
 
const T * data () const
 
T * data ()
 
const std::shared_ptr< T > & pointer () const
 
std::shared_ptr< T > & pointer ()
 
int cuda_accessible () const noexcept override
 returns true if the data is accessible from CUDA codes More...
 
int host_accessible () const noexcept override
 returns true if the data is accessible from codes running on the CPU More...
 
unsigned long size () const noexcept override
 Get the current size of the data. More...
 
void resize (unsigned long n) override
 Resize the data. More...
 
void resize (unsigned long n, const T &val)
 
void reserve (unsigned long n) override
 Reserve space. More...
 
void clear () noexcept override
 Clear the data. More...
 
void swap (const p_teca_variant_array &other) override
 virtual swap More...
 
bool equal (const const_p_teca_variant_array &other) const override
 virtual equivalence test More...
 
int to_stream (teca_binary_stream &s) const override
 Serialize to the stream. More...
 
int from_stream (teca_binary_stream &s) override
 Deserialize from the stream. More...
 
int to_stream (std::ostream &s) const override
 Serialize to the stream. More...
 
int from_stream (std::ostream &s) override
 Deserialize from the stream. More...
 
template<typename U = T>
void debug_print (typename std::enable_if< std::is_arithmetic< U >::value >::type *=0) const
 Print the contents of the buffer for debugging. More...
 
template<typename U = T>
void debug_print (typename std::enable_if<!std::is_arithmetic< U >::value >::type *=0) const
 Print the contents of the buffer for debugging. More...
 
teca_variant_array::allocator get_allocator () const
 
 teca_variant_array_impl ()
 default construct (the object is unusable) More...
 
 teca_variant_array_impl (allocator alloc)
 construct with a specific allocator More...
 
 teca_variant_array_impl (allocator alloc, size_t n_elem)
 construct with preallocated size More...
 
 teca_variant_array_impl (allocator alloc, size_t n_elem, const T &val)
 construct with preallocated size and initialized to a specific value More...
 
template<typename U >
 teca_variant_array_impl (allocator alloc, size_t n_elem, const U *vals)
 construct with preallocated size and initialized to a specific value More...
 
template<typename U >
 teca_variant_array_impl (allocator alloc, const const_p_teca_variant_array_impl< U > &other)
 copy construct from an instance of different type More...
 
template<typename delete_func_t >
 teca_variant_array_impl (allocator alloc, size_t size, int owner, T *ptr, delete_func_t df)
 zero-copy construct by setting buffer contents directly More...
 
template<typename U >
p_teca_variant_array_impl< T > New (size_t n, const U &v, allocator alloc)
 
template<typename U >
p_teca_variant_array_impl< T > New (size_t n, const U *v, allocator alloc)
 
template<typename delete_func_t >
p_teca_variant_array_impl< T > New (size_t n, T *ptr, allocator alloc, int owner, delete_func_t df)
 
virtual void append (const const_p_teca_variant_array &src)=0
 
virtual void append (const p_teca_variant_array &src)
 append the passed array. More...
 
virtual void append (const const_p_teca_variant_array &src, size_t src_start, size_t n_elem)=0
 append a subset of the passed array More...
 
virtual void append (const p_teca_variant_array &src, size_t src_start, size_t n_elem)
 append a subset of the passed array More...
 
template<typename T >
void append (const T &val)
 append a single value. this array is extended as needed. More...
 
template<typename T >
void append (const std::vector< T > &src)
 
template<typename T >
void append (const T *src, size_t src_start, size_t n_elem)
 
virtual void assign (const const_p_teca_variant_array &src)=0
 
virtual void assign (const p_teca_variant_array &src)
 assign the contents from the other array. More...
 
virtual void assign (const const_p_teca_variant_array &src, size_t src_start, size_t n_elem)=0
 assign a subset of the other array More...
 
virtual void assign (const p_teca_variant_array &src, size_t src_start, size_t n_elem)
 assign a subset of the other array More...
 
template<typename T >
void assign (const std::vector< T > &src)
 assign the contents from a vector of values. this array is resized as needed. More...
 
template<typename T >
void assign (const T *src, size_t src_start, size_t n_elem)
 assign the contents from a passed array. this array is resized as needed. More...
 
virtual void copy (const const_p_teca_variant_array &src)
 copy the contents from the other array. More...
 
virtual void copy (const p_teca_variant_array &src)
 copy the contents from the other array. More...
 
void copy (const const_p_teca_variant_array &src, size_t src_start, size_t n_elem)
 copy a subset of the other array More...
 
virtual void set (const const_p_teca_variant_array &src)=0
 
virtual void set (const p_teca_variant_array &src)
 Set from the other array. More...
 
virtual void set (size_t dest_start, const const_p_teca_variant_array &src, size_t src_start, size_t n_elem)=0
 
virtual void set (size_t dest_start, const p_teca_variant_array &src, size_t src_start, size_t n_elem)
 
template<typename T >
void set (unsigned long i, const T &val)
 set a single value More...
 
template<typename T >
void set (const std::vector< T > &src)
 set the contents from a vector of values. this array is not resized. More...
 
template<typename T >
void set (size_t dest_start, const T *src, size_t src_start, size_t n_elem)
 set a subset of the array from a passed array. this array is not resized. More...
 
virtual void get (const p_teca_variant_array &dest) const=0
 
virtual void get (size_t src_start, const p_teca_variant_array &dest, size_t dest_start, size_t n_elem) const=0
 
template<typename T >
void get (unsigned long i, T &val) const
 get a single value More...
 
template<typename T >
get (unsigned long i) const
 get a single value More...
 
template<typename T >
void get (std::vector< T > &vals) const
 get the contents into the passed vector. The vector is resized as needed. More...
 
template<typename T >
void get (size_t src_start, T *dest, size_t dest_start, size_t n_elem) const
 get a subset of the contents into the passed in array. More...
 
get

Copy the content of this array. The desitination must be large enough to hold the results. These calls could throw teca_bad_cast if the passed in type is not castable to the internal type.

template<typename U >
void get (size_t i, U &val) const
 
get (size_t i) const
 get a single value More...
 
template<typename U >
void get (std::vector< U > &dest) const
 get a vector of values More...
 
template<typename U >
void get (size_t src_start, U *dest, size_t dest_start, size_t n_elem) const
 get a range of values More...
 
void get (const p_teca_variant_array &dest) const override
 get the contents into the other array. More...
 
void get (size_t src_start, const p_teca_variant_array &dest, size_t dest_start, size_t n_elem) const override
 
template<typename U >
void get (const p_teca_variant_array_impl< U > &dest) const
 get the contents into the other array. More...
 
template<typename U >
void get (size_t src_start, const p_teca_variant_array_impl< U > &dest, size_t dest_start, size_t n_elem) const
 
set

Assign values to this array. This array must already be large enough to hold the result. If automatic resizing is desired use copy instead. These calls could throw teca_bad_cast if the passed in type is not castable to the internal type.

template<typename U >
void set (size_t i, const U &val)
 
template<typename U >
void set (const std::vector< U > &src)
 set from a vector of values More...
 
template<typename U >
void set (size_t dest_start, const U *src, size_t src_start, size_t n_elem)
 
void set (const const_p_teca_variant_array &src) override
 Set from the other array. More...
 
void set (size_t dest_start, const const_p_teca_variant_array &src, size_t src_start, size_t n_elem) override
 
template<typename U >
void set (const const_p_teca_variant_array_impl< U > &src)
 Set from the other array. More...
 
template<typename U >
void set (size_t dest_start, const const_p_teca_variant_array_impl< U > &src, size_t src_start, size_t n_elem)
 
assign

assign the contents of the passed array to this array. This array will be resized to hold the results. These calls could throw teca_bad_cast if the passed in type is not castable to the internal type.

template<typename U >
void assign (const std::vector< U > &src)
 
template<typename U >
void assign (const U *src, size_t src_start, size_t n_elem)
 assign a subset from the other array More...
 
void assign (const const_p_teca_variant_array &src) override
 assign the contents from the other array. More...
 
void assign (const const_p_teca_variant_array &src, size_t src_start, size_t n_elem) override
 assign a subset of the other array More...
 
template<typename U >
void assign (const const_p_teca_variant_array_impl< U > &src)
 assign the contents from the other array. More...
 
template<typename U >
void assign (const p_teca_variant_array_impl< U > &src)
 assign the contents from the other array. More...
 
template<typename U >
void assign (const const_p_teca_variant_array_impl< U > &src, size_t src_start, size_t n_elem)
 assign a subset of the other array More...
 
template<typename U >
void copy (const const_p_teca_variant_array_impl< U > &src)
 copy the contents from the other array. More...
 
template<typename U >
void copy (const const_p_teca_variant_array_impl< U > &src, size_t src_start, size_t n_elem)
 copy a subset of the other array More...
 
append

Append data at the back of the array. These calls could throw teca_bad_cast if the passed in type is not castable to the internal type.

template<typename U >
void append (const U &val)
 
template<typename U >
void append (const std::vector< U > &vals)
 append a vector of values More...
 
template<typename U >
void append (const U *src, size_t src_start, size_t n_elem)
 append a range of values More...
 
void append (const const_p_teca_variant_array &src) override
 
void append (const const_p_teca_variant_array &src, size_t src_start, size_t n_elem) override
 append a subset of the passed array More...
 
template<typename U >
void append (const const_p_teca_variant_array_impl< U > &src)
 
template<typename U >
void append (const p_teca_variant_array_impl< U > &src)
 
template<typename U >
void append (const const_p_teca_variant_array_impl< U > &src, size_t src_start, size_t n_elem)
 
get_accessible

get's a pointer to the raw data that is accessible on the named accelerator device or technology.

const std::shared_ptr< const T > get_host_accessible () const
 
const std::shared_ptr< const T > get_cuda_accessible () const
 Get a pointer to the data accessible within CUDA. More...
 
- Public Member Functions inherited from teca_variant_array
 teca_variant_array (const teca_variant_array &other)=delete
 
 teca_variant_array (teca_variant_array &&other)=delete
 
teca_variant_arrayoperator= (teca_variant_array &other)=delete
 
teca_variant_arrayoperator= (teca_variant_array &&other)=delete
 
p_teca_variant_array new_instance () const
 
p_teca_variant_array new_instance (size_t n) const
 
p_teca_variant_array new_copy () const
 
p_teca_variant_array new_copy (size_t src_start, size_t n_elem) const
 
template<typename T >
void get (unsigned long i, T &val) const
 get a single value More...
 
template<typename T >
get (unsigned long i) const
 get a single value More...
 
template<typename T >
void get (std::vector< T > &vals) const
 get the contents into the passed vector. The vector is resized as needed. More...
 
template<typename T >
void get (size_t src_start, T *dest, size_t dest_start, size_t n_elem) const
 get a subset of the contents into the passed in array. More...
 
virtual void set (const p_teca_variant_array &src)
 Set from the other array. More...
 
virtual void set (size_t dest_start, const p_teca_variant_array &src, size_t src_start, size_t n_elem)
 
template<typename T >
void set (unsigned long i, const T &val)
 set a single value More...
 
template<typename T >
void set (const std::vector< T > &src)
 set the contents from a vector of values. this array is not resized. More...
 
template<typename T >
void set (size_t dest_start, const T *src, size_t src_start, size_t n_elem)
 set a subset of the array from a passed array. this array is not resized. More...
 
virtual void assign (const p_teca_variant_array &src)
 assign the contents from the other array. More...
 
virtual void assign (const p_teca_variant_array &src, size_t src_start, size_t n_elem)
 assign a subset of the other array More...
 
template<typename T >
void assign (const std::vector< T > &src)
 assign the contents from a vector of values. this array is resized as needed. More...
 
template<typename T >
void assign (const T *src, size_t src_start, size_t n_elem)
 assign the contents from a passed array. this array is resized as needed. More...
 
virtual void copy (const const_p_teca_variant_array &src)
 copy the contents from the other array. More...
 
virtual void copy (const p_teca_variant_array &src)
 copy the contents from the other array. More...
 
void copy (const const_p_teca_variant_array &src, size_t src_start, size_t n_elem)
 copy a subset of the other array More...
 
virtual void append (const p_teca_variant_array &src)
 append the passed array. More...
 
virtual void append (const p_teca_variant_array &src, size_t src_start, size_t n_elem)
 append a subset of the passed array More...
 
template<typename T >
void append (const T &val)
 append a single value. this array is extended as needed. More...
 
template<typename T >
void append (const std::vector< T > &src)
 
template<typename T >
void append (const T *src, size_t src_start, size_t n_elem)
 

Friends

class teca_variant_array
 

Array constructors

Constructs a new instance containing the templated type.

static std::shared_ptr< teca_variant_array_impl< T > > New ()
 
static std::shared_ptr< teca_variant_array_impl< T > > New (allocator alloc)
 
static std::shared_ptr< teca_variant_array_impl< T > > New (size_t n)
 
static std::shared_ptr< teca_variant_array_impl< T > > New (size_t n, allocator alloc)
 
template<typename U >
static std::shared_ptr< teca_variant_array_impl< T > > New (size_t n, const U &v)
 
template<typename U >
static std::shared_ptr< teca_variant_array_impl< T > > New (size_t n, const U &v, allocator alloc)
 
template<typename U >
static std::shared_ptr< teca_variant_array_impl< T > > New (size_t n, const U *v)
 
template<typename U >
static std::shared_ptr< teca_variant_array_impl< T > > New (size_t n, const U *v, allocator alloc)
 
template<typename delete_func_t >
static std::shared_ptr< teca_variant_array_impl< T > > New (size_t n, T *ptr, allocator alloc, int owner, delete_func_t df)
 
p_teca_variant_array new_copy (allocator alloc=allocator::malloc) const override
 Returns a new instance initialized with a deep copy of this one. More...
 
p_teca_variant_array new_copy (size_t src_start, size_t n_elem, allocator alloc) const override
 
p_teca_variant_array new_instance (allocator alloc) const override
 Returns a new instance of the same type. More...
 
p_teca_variant_array new_instance (size_t n, allocator alloc) const override
 Returns a new instance of the same type sized to hold n elements. More...
 

Detailed Description

template<typename T>
class teca_variant_array_impl< T >

The concrete implementation of our type agnostic container for contiguous arrays.

Constructor & Destructor Documentation

◆ teca_variant_array_impl() [1/7]

template<typename T >
teca_variant_array_impl< T >::teca_variant_array_impl ( )
inline

default construct (the object is unusable)

◆ teca_variant_array_impl() [2/7]

template<typename T >
teca_variant_array_impl< T >::teca_variant_array_impl ( allocator  alloc)
inline

construct with a specific allocator

◆ teca_variant_array_impl() [3/7]

template<typename T >
teca_variant_array_impl< T >::teca_variant_array_impl ( allocator  alloc,
size_t  n_elem 
)
inline

construct with preallocated size

◆ teca_variant_array_impl() [4/7]

template<typename T >
teca_variant_array_impl< T >::teca_variant_array_impl ( allocator  alloc,
size_t  n_elem,
const T &  val 
)
inline

construct with preallocated size and initialized to a specific value

◆ teca_variant_array_impl() [5/7]

template<typename T >
template<typename U >
teca_variant_array_impl< T >::teca_variant_array_impl ( allocator  alloc,
size_t  n_elem,
const U *  vals 
)
inline

construct with preallocated size and initialized to a specific value

◆ teca_variant_array_impl() [6/7]

template<typename T >
template<typename U >
teca_variant_array_impl< T >::teca_variant_array_impl ( allocator  alloc,
const const_p_teca_variant_array_impl< U > &  other 
)
inline

copy construct from an instance of different type

◆ teca_variant_array_impl() [7/7]

template<typename T >
template<typename delete_func_t >
teca_variant_array_impl< T >::teca_variant_array_impl ( allocator  alloc,
size_t  size,
int  owner,
T *  ptr,
delete_func_t  df 
)
inline

zero-copy construct by setting buffer contents directly

Member Function Documentation

◆ append() [1/12]

template<typename T >
void teca_variant_array_impl< T >::append ( const const_p_teca_variant_array src)
inlineoverridevirtual

append the passed array.

Implements teca_variant_array.

◆ append() [2/12]

template<typename T >
virtual void teca_variant_array::append

append the passed array.

◆ append() [3/12]

template<typename T >
void teca_variant_array_impl< T >::append ( const const_p_teca_variant_array src,
size_t  src_start,
size_t  n_elem 
)
inlineoverridevirtual

append a subset of the passed array

Implements teca_variant_array.

◆ append() [4/12]

template<typename T >
virtual void teca_variant_array::append

append a subset of the passed array

◆ append() [5/12]

template<typename T >
virtual void teca_variant_array::append
inline

append the passed array.

◆ append() [6/12]

template<typename T >
virtual void teca_variant_array::append
inline

append a subset of the passed array

◆ append() [7/12]

template<typename T >
template<typename T >
void teca_variant_array::append ( typename T  )

Append the contents from a vector of values. this array is extended as needed.

◆ append() [8/12]

template<typename T >
template<typename U >
void teca_variant_array_impl< T >::append ( const std::vector< U > &  vals)
inline

append a vector of values

◆ append() [9/12]

template<typename T >
template<typename T >
void teca_variant_array::append ( typename T  )

append a single value. this array is extended as needed.

◆ append() [10/12]

template<typename T >
template<typename T >
void teca_variant_array::append ( typename T  )

Append the contents from a passed array. this array is extended as needed.

◆ append() [11/12]

template<typename T >
template<typename U >
void teca_variant_array_impl< T >::append ( const U &  val)
inline

append a single value

◆ append() [12/12]

template<typename T >
template<typename U >
void teca_variant_array_impl< T >::append ( const U *  src,
size_t  src_start,
size_t  n_elem 
)
inline

append a range of values

◆ assign() [1/13]

template<typename T >
void teca_variant_array_impl< T >::assign ( const const_p_teca_variant_array src)
inlineoverridevirtual

assign the contents from the other array.

Implements teca_variant_array.

◆ assign() [2/13]

template<typename T >
virtual void teca_variant_array::assign

assign the contents from the other array.

◆ assign() [3/13]

template<typename T >
void teca_variant_array_impl< T >::assign ( const const_p_teca_variant_array src,
size_t  src_start,
size_t  n_elem 
)
inlineoverridevirtual

assign a subset of the other array

Implements teca_variant_array.

◆ assign() [4/13]

template<typename T >
virtual void teca_variant_array::assign

assign a subset of the other array

◆ assign() [5/13]

template<typename T >
template<typename U >
void teca_variant_array_impl< T >::assign ( const const_p_teca_variant_array_impl< U > &  src)
inline

assign the contents from the other array.

◆ assign() [6/13]

template<typename T >
template<typename U >
void teca_variant_array_impl< T >::assign ( const const_p_teca_variant_array_impl< U > &  src,
size_t  src_start,
size_t  n_elem 
)
inline

assign a subset of the other array

◆ assign() [7/13]

template<typename T >
virtual void teca_variant_array::assign
inline

assign the contents from the other array.

◆ assign() [8/13]

template<typename T >
virtual void teca_variant_array::assign
inline

assign a subset of the other array

◆ assign() [9/13]

template<typename T >
template<typename U >
void teca_variant_array_impl< T >::assign ( const p_teca_variant_array_impl< U > &  src)
inline

assign the contents from the other array.

◆ assign() [10/13]

template<typename T >
template<typename T >
void teca_variant_array::assign ( typename T  )

assign the contents from a vector of values. this array is resized as needed.

◆ assign() [11/13]

template<typename T >
template<typename U >
void teca_variant_array_impl< T >::assign ( const std::vector< U > &  src)
inline

assign the contents from a vector of values

◆ assign() [12/13]

template<typename T >
template<typename T >
void teca_variant_array::assign ( typename T  )

assign the contents from a passed array. this array is resized as needed.

◆ assign() [13/13]

template<typename T >
template<typename U >
void teca_variant_array_impl< T >::assign ( const U *  src,
size_t  src_start,
size_t  n_elem 
)
inline

assign a subset from the other array

◆ clear()

template<typename T >
void teca_variant_array_impl< T >::clear
overridevirtualnoexcept

Clear the data.

Implements teca_variant_array.

◆ copy() [1/5]

template<typename T >
virtual void teca_variant_array::copy
inline

copy the contents from the other array.

◆ copy() [2/5]

template<typename T >
void teca_variant_array::copy
inline

copy a subset of the other array

◆ copy() [3/5]

template<typename T >
template<typename U >
void teca_variant_array_impl< T >::copy ( const const_p_teca_variant_array_impl< U > &  src)
inline

copy the contents from the other array.

◆ copy() [4/5]

template<typename T >
template<typename U >
void teca_variant_array_impl< T >::copy ( const const_p_teca_variant_array_impl< U > &  src,
size_t  src_start,
size_t  n_elem 
)
inline

copy a subset of the other array

◆ copy() [5/5]

template<typename T >
virtual void teca_variant_array::copy
inline

copy the contents from the other array.

◆ cuda_accessible()

template<typename T >
int teca_variant_array_impl< T >::cuda_accessible ( ) const
inlineoverridevirtualnoexcept

returns true if the data is accessible from CUDA codes

Implements teca_variant_array.

◆ data() [1/2]

template<typename T >
T* teca_variant_array_impl< T >::data ( )
inline

direct access to the internal memory. Use this when you are certain that the data is already accessible in the location where you will access it to save the cost of the std::shared_ptr copy constructor.

◆ data() [2/2]

template<typename T >
const T* teca_variant_array_impl< T >::data ( ) const
inline

direct access to the internal memory. Use this when you are certain that the data is already accessible in the location where you will access it to save the cost of the std::shared_ptr copy constructor.

◆ debug_print() [1/2]

template<typename T >
template<typename U = T>
void teca_variant_array_impl< T >::debug_print ( typename std::enable_if< std::is_arithmetic< U >::value >::type *  = 0) const
inline

Print the contents of the buffer for debugging.

◆ debug_print() [2/2]

template<typename T >
template<typename U = T>
void teca_variant_array_impl< T >::debug_print ( typename std::enable_if<!std::is_arithmetic< U >::value >::type *  = 0) const
inline

Print the contents of the buffer for debugging.

◆ equal()

template<typename T >
bool teca_variant_array_impl< T >::equal ( const const_p_teca_variant_array other) const
overridevirtual

virtual equivalence test

Implements teca_variant_array.

◆ from_stream() [1/2]

template<typename T >
int teca_variant_array_impl< T >::from_stream ( std::ostream &  s)
inlineoverridevirtual

Deserialize from the stream.

Implements teca_variant_array.

◆ from_stream() [2/2]

template<typename T >
int teca_variant_array_impl< T >::from_stream ( teca_binary_stream s)
inlineoverridevirtual

Deserialize from the stream.

Implements teca_variant_array.

◆ get() [1/14]

template<typename T >
void teca_variant_array_impl< T >::get ( const p_teca_variant_array dest) const
inlineoverridevirtual

get the contents into the other array.

Implements teca_variant_array.

◆ get() [2/14]

template<typename T >
virtual void teca_variant_array::get

get the contents into the other array.

◆ get() [3/14]

template<typename T >
template<typename U >
void teca_variant_array_impl< T >::get ( const p_teca_variant_array_impl< U > &  dest) const
inline

get the contents into the other array.

◆ get() [4/14]

template<typename T >
T teca_variant_array_impl< T >::get ( size_t  i) const
inline

get a single value

◆ get() [5/14]

template<typename T >
template<typename U >
void teca_variant_array_impl< T >::get ( size_t  i,
U &  val 
) const
inline

get a single value

◆ get() [6/14]

template<typename T >
void teca_variant_array_impl< T >::get ( size_t  src_start,
const p_teca_variant_array dest,
size_t  dest_start,
size_t  n_elem 
) const
inlineoverridevirtual

get a subset of the contents into a subset of the other array

Parameters
[in]dest_startthe first location to assign to
[in]srcthe array to copy values from
[in]src_startthe first location to copy from
[in]n_elemthe number of elements to copy

Implements teca_variant_array.

◆ get() [7/14]

template<typename T >
virtual void teca_variant_array::get

get a subset of the contents into a subset of the other array

Parameters
[in]dest_startthe first location to assign to
[in]srcthe array to copy values from
[in]src_startthe first location to copy from
[in]n_elemthe number of elements to copy

◆ get() [8/14]

template<typename T >
template<typename U >
void teca_variant_array_impl< T >::get ( size_t  src_start,
const p_teca_variant_array_impl< U > &  dest,
size_t  dest_start,
size_t  n_elem 
) const
inline

get a subset of the contents into a subset of the other array

Parameters
[in]dest_startthe first location to assign to
[in]srcthe array to copy values from
[in]src_startthe first location to copy from
[in]n_elemthe number of elements to copy

◆ get() [9/14]

template<typename T >
template<typename T >
void teca_variant_array::get ( typename T  )

get a subset of the contents into the passed in array.

◆ get() [10/14]

template<typename T >
template<typename U >
void teca_variant_array_impl< T >::get ( size_t  src_start,
U *  dest,
size_t  dest_start,
size_t  n_elem 
) const
inline

get a range of values

◆ get() [11/14]

template<typename T >
template<typename T >
void teca_variant_array::get ( typename T  )

get the contents into the passed vector. The vector is resized as needed.

◆ get() [12/14]

template<typename T >
template<typename U >
void teca_variant_array_impl< T >::get ( std::vector< U > &  dest) const
inline

get a vector of values

◆ get() [13/14]

template<typename T >
template<typename T >
T teca_variant_array::get ( typename T  )

get a single value

◆ get() [14/14]

template<typename T >
template<typename T >
void teca_variant_array::get ( typename T  )

get a single value

◆ get_class_name()

template<typename T >
std::string teca_variant_array_impl< T >::get_class_name
overridevirtual

Returns the name of the class in a human readable form.

Implements teca_variant_array.

◆ get_cuda_accessible()

template<typename T >
const std::shared_ptr<const T> teca_variant_array_impl< T >::get_cuda_accessible ( ) const
inline

Get a pointer to the data accessible within CUDA.

◆ get_host_accessible()

template<typename T >
const std::shared_ptr<const T> teca_variant_array_impl< T >::get_host_accessible ( ) const
inline

Get a pointer to the data accessible on the CPU

◆ host_accessible()

template<typename T >
int teca_variant_array_impl< T >::host_accessible ( ) const
inlineoverridevirtualnoexcept

returns true if the data is accessible from codes running on the CPU

Implements teca_variant_array.

◆ initialize()

template<typename T >
void teca_variant_array_impl< T >::initialize ( )
inlineoverridevirtual

Initialize all elements with T()

Implements teca_variant_array.

◆ New() [1/9]

template<typename T >
static std::shared_ptr<teca_variant_array_impl<T> > teca_variant_array_impl< T >::New ( )
inlinestatic

Allocate an array. The default value of alloc sets the array up for use on the CPU using C++ new to allocate memory to hold the contents.

◆ New() [2/9]

template<typename T >
p_teca_variant_array_impl< T > teca_variant_array_impl< T >::New ( allocator  alloc)
static

Allocate an array. The default value of alloc sets the array up for use on the CPU using C++ new to allocate memory to hold the contents.

◆ New() [3/9]

template<typename T >
static std::shared_ptr<teca_variant_array_impl<T> > teca_variant_array_impl< T >::New ( size_t  n)
inlinestatic

Allocates an array with space for n elements. The default value of alloc sets the array up for use on the CPU using C++ new to allocate memory to hold the contents.

◆ New() [4/9]

template<typename T >
p_teca_variant_array_impl< T > teca_variant_array_impl< T >::New ( size_t  n,
allocator  alloc 
)
static

Allocates an array with space for n elements. The default value of alloc sets the array up for use on the CPU using C++ new to allocate memory to hold the contents.

◆ New() [5/9]

template<typename T >
template<typename U >
static std::shared_ptr<teca_variant_array_impl<T> > teca_variant_array_impl< T >::New ( size_t  n,
const U &  v 
)
inlinestatic

Allocate an array with space for n elements initialized with v. The default value of alloc sets the array up for use on the CPU using C++ new to allocate memory to hold the contents.

◆ New() [6/9]

template<typename T >
template<typename U >
static std::shared_ptr<teca_variant_array_impl<T> > teca_variant_array_impl< T >::New ( size_t  n,
const U &  v,
allocator  alloc 
)
static

Allocate an array with space for n elements initialized with v. The default value of alloc sets the array up for use on the CPU using C++ new to allocate memory to hold the contents.

◆ New() [7/9]

template<typename T >
template<typename U >
static std::shared_ptr<teca_variant_array_impl<T> > teca_variant_array_impl< T >::New ( size_t  n,
const U *  v 
)
inlinestatic

Allocate an array with space for n elements initialized with v. The default value of alloc sets the array up for use on the CPU using C++ new to allocate memory to hold the contents.

◆ New() [8/9]

template<typename T >
template<typename U >
static std::shared_ptr<teca_variant_array_impl<T> > teca_variant_array_impl< T >::New ( size_t  n,
const U *  v,
allocator  alloc 
)
static

Allocate an array with space for n elements initialized with v. The default value of alloc sets the array up for use on the CPU using C++ new to allocate memory to hold the contents.

◆ New() [9/9]

template<typename T >
template<typename delete_func_t >
static std::shared_ptr<teca_variant_array_impl<T> > teca_variant_array_impl< T >::New ( size_t  n,
T *  ptr,
allocator  alloc,
int  owner,
delete_func_t  df 
)
static

construct by directly providing the buffer contents. This can be used for zero-copy transfer of data. One must also name the allocator type and device owning the data. In addition for new allocations the allocator type and owner are used internally to know how to automatically move data during inter technology transfers.

Parameters
[in]allocan ::allocator indicating the technology backing the pointer
[in]sizethe number of elements in the array pointed to by ptr
[in]ownerthe device owning the memory, -1 for CPU. if the allocator is a GPU allocator and -1 is passed the driver API is used to determine the device that allocated the memory.
[in]ptra pointer to the data
[in]dfa function void df(void*ptr) used to delete the data when this instance is finished using it.

◆ new_copy() [1/2]

template<typename T >
p_teca_variant_array teca_variant_array_impl< T >::new_copy ( allocator  alloc = allocator::malloc) const
overridevirtual

Returns a new instance initialized with a deep copy of this one.

Implements teca_variant_array.

◆ new_copy() [2/2]

template<typename T >
p_teca_variant_array teca_variant_array_impl< T >::new_copy ( size_t  src_start,
size_t  n_elem,
allocator  alloc 
) const
overridevirtual

virtual copy construct. return a newly allocated object, initialized copy from a subset of this.

Implements teca_variant_array.

◆ new_instance() [1/2]

template<typename T >
p_teca_variant_array teca_variant_array_impl< T >::new_instance ( allocator  alloc) const
overridevirtual

Returns a new instance of the same type.

Implements teca_variant_array.

◆ new_instance() [2/2]

template<typename T >
p_teca_variant_array teca_variant_array_impl< T >::new_instance ( size_t  n,
allocator  alloc 
) const
overridevirtual

Returns a new instance of the same type sized to hold n elements.

Implements teca_variant_array.

◆ pointer() [1/2]

template<typename T >
std::shared_ptr<T>& teca_variant_array_impl< T >::pointer ( )
inline

direct access to the internal memory. Use this when you are certain that the data is already accessible in the location where you will access it.

◆ pointer() [2/2]

template<typename T >
const std::shared_ptr<T>& teca_variant_array_impl< T >::pointer ( ) const
inline

direct access to the internal memory. Use this when you are certain that the data is already accessible in the location where you will access it.

◆ reserve()

template<typename T >
void teca_variant_array_impl< T >::reserve ( unsigned long  n)
overridevirtual

Reserve space.

Implements teca_variant_array.

◆ resize()

template<typename T >
void teca_variant_array_impl< T >::resize ( unsigned long  n)
overridevirtual

Resize the data.

Implements teca_variant_array.

◆ set() [1/14]

template<typename T >
void teca_variant_array_impl< T >::set ( const const_p_teca_variant_array src)
inlineoverridevirtual

Set from the other array.

Implements teca_variant_array.

◆ set() [2/14]

template<typename T >
virtual void teca_variant_array::set

Set from the other array

◆ set() [3/14]

template<typename T >
template<typename U >
void teca_variant_array_impl< T >::set ( const const_p_teca_variant_array_impl< U > &  src)
inline

Set from the other array.

◆ set() [4/14]

template<typename T >
virtual void teca_variant_array::set
inline

Set from the other array.

◆ set() [5/14]

template<typename T >
template<typename T >
void teca_variant_array::set ( typename T  )

set the contents from a vector of values. this array is not resized.

◆ set() [6/14]

template<typename T >
template<typename U >
void teca_variant_array_impl< T >::set ( const std::vector< U > &  src)
inline

set from a vector of values

◆ set() [7/14]

template<typename T >
void teca_variant_array_impl< T >::set ( size_t  dest_start,
const const_p_teca_variant_array src,
size_t  src_start,
size_t  n_elem 
)
inlineoverridevirtual

Set a subset of this array from a subset of the other array.

Parameters
[in]dest_startthe first location to assign to
[in]srcthe array to copy values from
[in]src_startthe first location to copy from
[in]n_elemthe number of elements to copy

Implements teca_variant_array.

◆ set() [8/14]

template<typename T >
virtual void teca_variant_array::set

Set a subset of this array from a subset opf the contents of the other array.

Parameters
[in]dest_startthe first location to assign to
[in]srcthe array to copy values from
[in]src_startthe first location to copy from
[in]n_elemthe number of elements to copy

◆ set() [9/14]

template<typename T >
template<typename U >
void teca_variant_array_impl< T >::set ( size_t  dest_start,
const const_p_teca_variant_array_impl< U > &  src,
size_t  src_start,
size_t  n_elem 
)
inline

Set a subset of this array from a subset of the other array.

Parameters
[in]dest_startthe first location to assign to
[in]srcthe array to copy values from
[in]src_startthe first location to copy from
[in]n_elemthe number of elements to copy

◆ set() [10/14]

template<typename T >
virtual void teca_variant_array::set
inline

Set a subset of this array from a subset opf the contents of the other array.

Parameters
[in]dest_startthe first location to assign to
[in]srcthe array to copy values from
[in]src_startthe first location to copy from
[in]n_elemthe number of elements to copy

◆ set() [11/14]

template<typename T >
template<typename T >
void teca_variant_array::set ( typename T  )

set a subset of the array from a passed array. this array is not resized.

◆ set() [12/14]

template<typename T >
template<typename U >
void teca_variant_array_impl< T >::set ( size_t  dest_start,
const U *  src,
size_t  src_start,
size_t  n_elem 
)
inline

set from a subset of the other array

Parameters
[in]dest_startthe first location to assign to
[in]srcthe array to copy values from
[in]src_startthe first location to copy from
[in]n_elemthe number of elements to copy

◆ set() [13/14]

template<typename T >
template<typename U >
void teca_variant_array_impl< T >::set ( size_t  i,
const U &  val 
)
inline

set a single value

◆ set() [14/14]

template<typename T >
template<typename T >
void teca_variant_array::set ( typename T  )

set a single value

◆ set_allocator()

template<typename T >
int teca_variant_array_impl< T >::set_allocator ( allocator  alloc)
overridevirtual

Set the allocator. If the passed allocator is already in use this is a NOOP. Otherwise the contents of the variant array are reallocated and moved using a buffer allocated with the passed allocator. This can be used to explicitly move the data.

Parameters
[in]allocthe new ::allocator to use
Returns
0 if successful

Implements teca_variant_array.

◆ size()

template<typename T >
unsigned long teca_variant_array_impl< T >::size
overridevirtualnoexcept

Get the current size of the data.

Implements teca_variant_array.

◆ swap()

template<typename T >
void teca_variant_array_impl< T >::swap ( const p_teca_variant_array other)
overridevirtual

virtual swap

Implements teca_variant_array.

◆ synchronize()

template<typename T >
void teca_variant_array_impl< T >::synchronize ( ) const
inlineoverridevirtual

Sycnhronize the stream used for data movement.

Implements teca_variant_array.

◆ to_stream() [1/2]

template<typename T >
int teca_variant_array_impl< T >::to_stream ( std::ostream &  s) const
inlineoverridevirtual

Serialize to the stream.

Implements teca_variant_array.

◆ to_stream() [2/2]

template<typename T >
int teca_variant_array_impl< T >::to_stream ( teca_binary_stream s) const
inlineoverridevirtual

Serialize to the stream.

Implements teca_variant_array.


The documentation for this class was generated from the following file: