|
TECA
The Toolkit for Extreme Climate Analysis
|
A type erasure for array based data. More...
#include <teca_variant_array.h>
Public Types | |
| using | allocator = hamr::buffer_allocator |
| allocator types More... | |
Public Member Functions | |
| teca_variant_array (const teca_variant_array &other)=delete | |
| teca_variant_array (teca_variant_array &&other)=delete | |
| teca_variant_array & | operator= (teca_variant_array &other)=delete |
| teca_variant_array & | operator= (teca_variant_array &&other)=delete |
| p_teca_variant_array | new_instance () const |
| p_teca_variant_array | new_instance (size_t n) const |
| virtual p_teca_variant_array | new_instance (allocator alloc) const =0 |
| virtual p_teca_variant_array | new_instance (size_t n, allocator alloc) const =0 |
| virtual p_teca_variant_array | new_copy (allocator alloc) const =0 |
| p_teca_variant_array | new_copy () const |
| virtual p_teca_variant_array | new_copy (size_t src_start, size_t n_elem, allocator alloc) const =0 |
| p_teca_variant_array | new_copy (size_t src_start, size_t n_elem) const |
| virtual int | set_allocator (allocator alloc)=0 |
| virtual std::string | get_class_name () const =0 |
| return the name of the class in a human readable form More... | |
| virtual void | initialize ()=0 |
| initialize the elements using the default constructor More... | |
| virtual unsigned long | size () const noexcept=0 |
| get the number of elements in the array More... | |
| virtual void | resize (unsigned long i)=0 |
| resize. allocates new storage and copies in existing values More... | |
| virtual void | reserve (unsigned long i)=0 |
| virtual void | clear () noexcept=0 |
| free all the internal data More... | |
| virtual void | swap (const p_teca_variant_array &other)=0 |
| virtual bool | equal (const const_p_teca_variant_array &other) const =0 |
| compare the two arrays element wize for equality More... | |
| virtual int | to_stream (teca_binary_stream &s) const =0 |
| serrialize to the binary stream in the internal format More... | |
| virtual int | from_stream (teca_binary_stream &s)=0 |
| derrialize from the binary stream More... | |
| virtual int | to_stream (std::ostream &s) const =0 |
| serrialize to the stream in a human readable format More... | |
| virtual int | from_stream (std::ostream &s)=0 |
| derrialize from the human readable stream More... | |
| virtual unsigned int | type_code () const noexcept=0 |
| a code for the contained data type used for serialization More... | |
| virtual int | host_accessible () const noexcept=0 |
| virtual int | cuda_accessible () const noexcept=0 |
| virtual void | synchronize () const =0 |
| synchronize on the associated stream More... | |
get | |
Copy the contest of this array to the passed instance. The desitination must be large enough to hold the results. These calls could throw std::bad_cast if the passed in type is not castable to the internal type. | |
| 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 > | |
| 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... | |
set | |
Assign values to this array form another. This array must already be large enough to hold the result. If automatic resizing is desired use copy instead. These calls could throw std::bad_cast if the passed in type is not castable to the internal type. | |
| 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... | |
assign | |
assign the contents of the passed array to this array. This array will be resized to hold the results. These calls could throw std::bad_cast if the passed in type is not castable to the internal type. | |
| 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... | |
append | |
Append data at the back of the array. These calls could throw std::bad_cast if the passed in type is not castable to the internal type. | |
| 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) |
A type erasure for array based data.
The variant array supports: set, get, assign, and append. The elements of the array can be stored on different accelerator devices using different technologies and accessed seamless from other accelerator devices and technologies.
Use the type erasure (this class) to implement collections of arrays and public API. Use the concrete implementation (teca_variant_array_impl) for direct access to the typed data.
See VARIANT_ARRAY_DISPATCH and NESTED_VARIANT_ARRAY_DISPATCH for details on how to apply type specific code to an instance of teca_variant_array.
| using teca_variant_array::allocator = hamr::buffer_allocator |
allocator types
|
pure virtual |
append the passed array.
Implemented in teca_variant_array_impl< T >.
|
pure virtual |
append a subset of the passed array
Implemented in teca_variant_array_impl< T >.
|
inlinevirtual |
append the passed array.
|
inlinevirtual |
append a subset of the passed array
| void teca_variant_array::append | ( | const std::vector< T > & | src | ) |
Append the contents from a vector of values. this array is extended as needed.
| void teca_variant_array::append | ( | const T & | val | ) |
append a single value. this array is extended as needed.
| void teca_variant_array::append | ( | const T * | src, |
| size_t | src_start, | ||
| size_t | n_elem | ||
| ) |
Append the contents from a passed array. this array is extended as needed.
|
pure virtual |
assign the contents from the other array.
Implemented in teca_variant_array_impl< T >.
|
pure virtual |
assign a subset of the other array
Implemented in teca_variant_array_impl< T >.
|
inlinevirtual |
assign the contents from the other array.
|
inlinevirtual |
assign a subset of the other array
| void teca_variant_array::assign | ( | const std::vector< T > & | src | ) |
assign the contents from a vector of values. this array is resized as needed.
| void teca_variant_array::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.
|
pure virtualnoexcept |
free all the internal data
Implemented in teca_variant_array_impl< T >.
|
inlinevirtual |
copy the contents from the other array.
|
inline |
copy a subset of the other array
|
inlinevirtual |
copy the contents from the other array.
|
pure virtualnoexcept |
Implemented in teca_variant_array_impl< T >.
|
pure virtual |
compare the two arrays element wize for equality
Implemented in teca_variant_array_impl< T >.
|
pure virtual |
derrialize from the human readable stream
Implemented in teca_variant_array_impl< T >.
|
pure virtual |
derrialize from the binary stream
Implemented in teca_variant_array_impl< T >.
|
pure virtual |
get the contents into the other array.
Implemented in teca_variant_array_impl< T >.
|
pure virtual |
get a subset of the contents into a subset of the other array
| [in] | dest_start | the first location to assign to |
| [in] | src | the array to copy values from |
| [in] | src_start | the first location to copy from |
| [in] | n_elem | the number of elements to copy |
Implemented in teca_variant_array_impl< T >.
| void teca_variant_array::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.
| void teca_variant_array::get | ( | std::vector< T > & | vals | ) | const |
get the contents into the passed vector. The vector is resized as needed.
| T teca_variant_array::get | ( | unsigned long | i | ) | const |
get a single value
| void teca_variant_array::get | ( | unsigned long | i, |
| T & | val | ||
| ) | const |
get a single value
|
pure virtual |
return the name of the class in a human readable form
Implemented in teca_variant_array_impl< T >.
|
pure virtualnoexcept |
Implemented in teca_variant_array_impl< T >.
|
pure virtual |
initialize the elements using the default constructor
Implemented in teca_variant_array_impl< T >.
|
inline |
return a newly allocated object, initialized copy from this. The default allocator will be used.
|
pure virtual |
return a newly allocated object, initialized copy from this.
| [in] | alloc | selects the allocator to use (See ::allocator) |
Implemented in teca_variant_array_impl< T >.
|
inline |
return a newly allocated object, initialized copy from a subset of this. The default allocator will be used.
| [in[ | src_start the first element to copy | |
| [in] | n_elem | the number of elements to copy |
|
pure virtual |
return a newly allocated object, initialized copy from a subset of this.
| [in[ | src_start the first element to copy | |
| [in] | n_elem | the number of elements to copy |
| [in] | alloc | selects the allocator to use (See ::allocator) |
Implemented in teca_variant_array_impl< T >.
|
inline |
return a newly allocated empty object of the same type. The default allocator will be used.
|
pure virtual |
| [in] | alloc | selects the allocator to use (See ::allocator) |
Implemented in teca_variant_array_impl< T >.
|
inline |
returns a newly allocated object of the same type will n_elem elements allocated. The default allocator will be used.
| [in] | n_elem | the number of elements to allocate. |
|
pure virtual |
returns a newly allocated object of the same type will n_elem elements allocated.
| [in] | n_elem | the number of elements to allocate. |
| [in[ | alloc selects the allocator to use (See ::allocator) |
Implemented in teca_variant_array_impl< T >.
|
pure virtual |
reserve. reserves the requested amount of space with out constructing elements
Implemented in teca_variant_array_impl< T >.
|
pure virtual |
resize. allocates new storage and copies in existing values
Implemented in teca_variant_array_impl< T >.
|
pure virtual |
Set from the other array
Implemented in teca_variant_array_impl< T >.
|
inlinevirtual |
Set from the other array.
| void teca_variant_array::set | ( | const std::vector< T > & | src | ) |
set the contents from a vector of values. this array is not resized.
|
pure virtual |
Set a subset of this array from a subset opf the contents of the other array.
| [in] | dest_start | the first location to assign to |
| [in] | src | the array to copy values from |
| [in] | src_start | the first location to copy from |
| [in] | n_elem | the number of elements to copy |
Implemented in teca_variant_array_impl< T >.
|
inlinevirtual |
Set a subset of this array from a subset opf the contents of the other array.
| [in] | dest_start | the first location to assign to |
| [in] | src | the array to copy values from |
| [in] | src_start | the first location to copy from |
| [in] | n_elem | the number of elements to copy |
| void teca_variant_array::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.
| void teca_variant_array::set | ( | unsigned long | i, |
| const T & | val | ||
| ) |
set a single value
|
pure virtual |
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.
| [in] | alloc | the new ::allocator to use |
Implemented in teca_variant_array_impl< T >.
|
pure virtualnoexcept |
get the number of elements in the array
Implemented in teca_variant_array_impl< T >.
|
pure virtual |
swap the contents of this and the other object. an exception is thrown when no conversion between the two types exists.
Implemented in teca_variant_array_impl< T >.
|
pure virtual |
synchronize on the associated stream
Implemented in teca_variant_array_impl< T >.
|
pure virtual |
serrialize to the stream in a human readable format
Implemented in teca_variant_array_impl< T >.
|
pure virtual |
serrialize to the binary stream in the internal format
Implemented in teca_variant_array_impl< T >.
|
pure virtualnoexcept |
a code for the contained data type used for serialization