TECA
The Toolkit for Extreme Climate Analysis
teca_array_collection Class Reference

A collection of named arrays. More...

#include <teca_array_collection.h>

Inheritance diagram for teca_array_collection:
[legend]
Collaboration diagram for teca_array_collection:
[legend]

Public Member Functions

std::shared_ptr< teca_array_collectionshared_from_this ()
 
std::shared_ptr< teca_array_collection const > shared_from_this () const
 
virtual p_teca_dataset new_instance () const override
 virtual constructor. return a new dataset of the same type. More...
 
virtual p_teca_dataset new_copy (allocator alloc=allocator::malloc) const override
 
virtual p_teca_dataset new_shallow_copy () override
 
void set_time (const std::vector< double > &vals)
 
int get_time (std::vector< double > &vals) const
 
void set_time (const p_teca_variant_array &vals)
 
int get_time (p_teca_variant_array vals) const
 
void set_time (const std::initializer_list< double > &l)
 
void set_time (const double *vals)
 
int get_time (double *vals) const
 
void set_time (const double &val_1)
 
int get_time (double &val_1) const
 
void set_calendar (const std::vector< std::string > &vals)
 
int get_calendar (std::vector< std::string > &vals) const
 
void set_calendar (const p_teca_variant_array &vals)
 
int get_calendar (p_teca_variant_array vals) const
 
void set_calendar (const std::initializer_list< std::string > &l)
 
void set_calendar (const std::string *vals)
 
int get_calendar (std::string *vals) const
 
void set_calendar (const std::string &val_1)
 
int get_calendar (std::string &val_1) const
 
void set_time_units (const std::vector< std::string > &vals)
 
int get_time_units (std::vector< std::string > &vals) const
 
void set_time_units (const p_teca_variant_array &vals)
 
int get_time_units (p_teca_variant_array vals) const
 
void set_time_units (const std::initializer_list< std::string > &l)
 
void set_time_units (const std::string *vals)
 
int get_time_units (std::string *vals) const
 
void set_time_units (const std::string &val_1)
 
int get_time_units (std::string &val_1) const
 
void set_time_step (const std::vector< unsigned long > &vals)
 
int get_time_step (std::vector< unsigned long > &vals) const
 
void set_time_step (const p_teca_variant_array &vals)
 
int get_time_step (p_teca_variant_array vals) const
 
void set_time_step (const std::initializer_list< unsigned long > &l)
 
void set_time_step (const unsigned long *vals)
 
int get_time_step (unsigned long *vals) const
 
void set_time_step (const unsigned long &val_1)
 
int get_time_step (unsigned long &val_1) const
 
void set_attributes (const std::vector< teca_metadata > &vals)
 
int get_attributes (std::vector< teca_metadata > &vals) const
 
void set_attributes (const p_teca_variant_array &vals)
 
int get_attributes (p_teca_variant_array vals) const
 
void set_attributes (const std::initializer_list< teca_metadata > &l)
 
void set_attributes (const teca_metadata *vals)
 
int get_attributes (teca_metadata *vals) const
 
void set_attributes (const teca_metadata &val_1)
 
int get_attributes (teca_metadata &val_1) const
 
void clear ()
 reset to empty state More...
 
template<typename nT , typename aT , typename... oT>
void declare_set (nT &&a_name, aT a_type, oT &&...args)
 
template<typename nT , typename aT >
void declare (nT &&a_name, aT a_type)
 declare a single array More...
 
void set_default_allocator (allocator alloc)
 set the allocator to use with ::declare More...
 
int append (p_teca_variant_array array)
 
int append (const std::string &name, p_teca_variant_array array)
 
int set (unsigned int i, p_teca_variant_array array)
 
int set (const std::string &name, p_teca_variant_array array)
 add or replace the named array, returns 0 on success. More...
 
int remove (unsigned int i)
 remove the ith array More...
 
int remove (const std::string &name)
 remove the named array More...
 
unsigned int size () const noexcept
 Return the number of arrays. More...
 
p_teca_variant_array get (unsigned int i)
 access an array by its id More...
 
const_p_teca_variant_array get (unsigned int i) const
 access an array by its id More...
 
template<typename array_t >
std::shared_ptr< array_t > get_as (unsigned int i)
 access a typed array by id More...
 
template<typename array_t >
std::shared_ptr< const array_t > get_as (unsigned int i) const
 access a typed array by id More...
 
bool has (const std::string &name) const
 test for array More...
 
template<typename array_t >
std::shared_ptr< array_t > get_as (const std::string &name)
 access a typed array by name More...
 
template<typename array_t >
std::shared_ptr< const array_t > get_as (const std::string &name) const
 access a typed array by name More...
 
p_teca_variant_array get (const std::string &name)
 access an array by name More...
 
const_p_teca_variant_array get (const std::string &name) const
 access an array by name More...
 
p_teca_variant_array operator[] (const std::string &name)
 access an array by name More...
 
const_p_teca_variant_array operator[] (const std::string &name) const
 access an array by name More...
 
std::string & get_name (unsigned int i)
 
const std::string & get_name (unsigned int i) const
 
std::vector< std::string > & get_names ()
 
const std::vector< std::string > & get_names () const
 
std::string get_class_name () const override
 Return the name of the class. More...
 
int get_type_code () const override
 return an integer identifier uniquely naming the dataset type More...
 
void copy (const const_p_teca_dataset &other, allocator alloc=allocator::malloc) override
 
void shallow_copy (const p_teca_dataset &other) override
 
int append (const const_p_teca_array_collection &other)
 append More...
 
int shallow_append (const p_teca_array_collection &other)
 shallow append More...
 
void swap (const p_teca_dataset &other) override
 swap More...
 
int to_stream (teca_binary_stream &s) const override
 serialize the data to the given stream for I/O or communication More...
 
int from_stream (teca_binary_stream &s) override
 serialize the data from the given stream for I/O or communication More...
 
int to_stream (std::ostream &) const override
 stream to a human readable representation More...
 
virtual int from_stream (teca_binary_stream &)
 deserialize the dataset from the given stream for I/O or communication More...
 
virtual int from_stream (std::istream &)
 read from stream in a human readable representation More...
 
- Public Member Functions inherited from teca_dataset
virtual int set_request_indices (const std::string &request_key, const unsigned long ids[2])
 
virtual int get_request_indices (unsigned long ids[2]) const
 
virtual int get_request_index (unsigned long &index) const
 
virtual int set_request_index (const std::string &request_key, unsigned long index)
 
 operator bool () const noexcept
 
virtual bool empty () const noexcept
 
virtual void copy_metadata (const const_p_teca_dataset &other)
 copy metadata. always a deep copy. More...
 
virtual teca_metadataget_metadata () noexcept
 get the dataset metadata More...
 
virtual const teca_metadataget_metadata () const noexcept
 get the dataset metadata More...
 
virtual void set_metadata (const teca_metadata &md)
 set the dataset metadata More...
 
virtual int from_stream (std::istream &)
 read from stream in a human readable representation More...
 
void set_index_request_key (const std::vector< std::string > &vals)
 
int get_index_request_key (std::vector< std::string > &vals) const
 
void set_index_request_key (const p_teca_variant_array &vals)
 
int get_index_request_key (p_teca_variant_array vals) const
 
void set_index_request_key (const std::initializer_list< std::string > &l)
 
void set_index_request_key (const std::string *vals)
 
int get_index_request_key (std::string *vals) const
 
void set_index_request_key (const std::string &val_1)
 
int get_index_request_key (std::string &val_1) const
 

Static Public Member Functions

static p_teca_array_collection New ()
 

Protected Member Functions

 teca_array_collection (const teca_array_collection &)=delete
 
 teca_array_collection (const teca_array_collection &&)=delete
 
void operator= (const teca_array_collection &)=delete
 
void operator= (const teca_array_collection &&)=delete
 
void declare_set ()
 
- Protected Member Functions inherited from teca_dataset
 teca_dataset (const teca_dataset &)=delete
 
 teca_dataset (const teca_dataset &&)=delete
 
void operator= (const p_teca_dataset &other)=delete
 
void operator= (p_teca_dataset &&other)=delete
 

Additional Inherited Members

- Public Types inherited from teca_dataset
using allocator = teca_variant_array::allocator
 
- Protected Attributes inherited from teca_dataset
teca_metadatametadata
 

Detailed Description

A collection of named arrays.

The array collection is used internally in other mesh based datasets. It can also be used to process more general data where the arrays have differing lengths or a non-geometric association.

Member Function Documentation

◆ append() [1/3]

int teca_array_collection::append ( const const_p_teca_array_collection &  other)

append

◆ append() [2/3]

int teca_array_collection::append ( const std::string &  name,
p_teca_variant_array  array 
)

add, return the index of the new entry, or -1 if the array name already exists.

◆ append() [3/3]

int teca_array_collection::append ( p_teca_variant_array  array)

add, return the index of the new entry, or -1 if the array name already exists.

◆ clear()

void teca_array_collection::clear ( )

reset to empty state

◆ copy()

void teca_array_collection::copy ( const const_p_teca_dataset &  other,
allocator  alloc = allocator::malloc 
)
overridevirtual

Deep copy data and metdata.

Parameters
[in]otherThe dataset to copy.
[in]allocThe allocator to use for alloctions of data structures to hold the copy. The default is a CPU based allocator.

Reimplemented from teca_dataset.

◆ declare()

template<typename nT , typename aT >
void teca_array_collection::declare ( nT &&  a_name,
aT  a_type 
)

declare a single array

◆ declare_set()

template<typename nT , typename aT , typename... oT>
void teca_array_collection::declare_set ( nT &&  a_name,
aT  a_type,
oT &&...  args 
)

declare a set of arrays. requires name,type pairs for ex. define("c1",int(),"c2",float()) creates 2 arrays in the collection the first storing int the second storing float.

◆ from_stream() [1/3]

virtual int teca_dataset::from_stream

read from stream in a human readable representation

◆ from_stream() [2/3]

virtual int teca_dataset::from_stream

deserialize the dataset from the given stream for I/O or communication

◆ from_stream() [3/3]

int teca_array_collection::from_stream ( teca_binary_stream s)
overridevirtual

serialize the data from the given stream for I/O or communication

Reimplemented from teca_dataset.

◆ get() [1/4]

p_teca_variant_array teca_array_collection::get ( const std::string &  name)

access an array by name

◆ get() [2/4]

const_p_teca_variant_array teca_array_collection::get ( const std::string &  name) const

access an array by name

◆ get() [3/4]

p_teca_variant_array teca_array_collection::get ( unsigned int  i)
inline

access an array by its id

◆ get() [4/4]

const_p_teca_variant_array teca_array_collection::get ( unsigned int  i) const
inline

access an array by its id

◆ get_as() [1/4]

template<typename array_t >
std::shared_ptr<array_t> teca_array_collection::get_as ( const std::string &  name)
inline

access a typed array by name

◆ get_as() [2/4]

template<typename array_t >
std::shared_ptr<const array_t> teca_array_collection::get_as ( const std::string &  name) const
inline

access a typed array by name

◆ get_as() [3/4]

template<typename array_t >
std::shared_ptr<array_t> teca_array_collection::get_as ( unsigned int  i)
inline

access a typed array by id

◆ get_as() [4/4]

template<typename array_t >
std::shared_ptr<const array_t> teca_array_collection::get_as ( unsigned int  i) const
inline

access a typed array by id

◆ get_class_name()

std::string teca_array_collection::get_class_name ( ) const
inlineoverridevirtual

Return the name of the class.

Implements teca_dataset.

◆ get_type_code()

int teca_array_collection::get_type_code ( ) const
overridevirtual

return an integer identifier uniquely naming the dataset type

Implements teca_dataset.

◆ has()

bool teca_array_collection::has ( const std::string &  name) const

test for array

◆ new_copy()

virtual p_teca_dataset teca_array_collection::new_copy ( allocator  alloc = allocator::malloc) const
inlineoverridevirtual

Implements teca_dataset.

◆ new_instance()

virtual p_teca_dataset teca_array_collection::new_instance ( ) const
inlineoverridevirtual

virtual constructor. return a new dataset of the same type.

Implements teca_dataset.

◆ new_shallow_copy()

virtual p_teca_dataset teca_array_collection::new_shallow_copy ( )
inlineoverridevirtual

Virtual shallow copy constructor. return a shallow copy of this dataset in a new instance. References to source data structures are taken, but metadata is always deep copied.

Implements teca_dataset.

◆ operator[]() [1/2]

p_teca_variant_array teca_array_collection::operator[] ( const std::string &  name)
inline

access an array by name

◆ operator[]() [2/2]

const_p_teca_variant_array teca_array_collection::operator[] ( const std::string &  name) const
inline

access an array by name

◆ remove() [1/2]

int teca_array_collection::remove ( const std::string &  name)

remove the named array

◆ remove() [2/2]

int teca_array_collection::remove ( unsigned int  i)

remove the ith array

◆ set() [1/2]

int teca_array_collection::set ( const std::string &  name,
p_teca_variant_array  array 
)

add or replace the named array, returns 0 on success.

◆ set() [2/2]

int teca_array_collection::set ( unsigned int  i,
p_teca_variant_array  array 
)

replace the ith array, return 0 on success. the name of the array is not changed.

◆ set_default_allocator()

void teca_array_collection::set_default_allocator ( allocator  alloc)
inline

set the allocator to use with ::declare

◆ shallow_append()

int teca_array_collection::shallow_append ( const p_teca_array_collection &  other)

shallow append

◆ shallow_copy()

void teca_array_collection::shallow_copy ( const p_teca_dataset &  other)
overridevirtual

Shallow copy data and metadata. The shallow copy takes references to the source data structures. Metadata is always deep copied.

Parameters
[in]otherThe dataset to copy.

Reimplemented from teca_dataset.

◆ size()

unsigned int teca_array_collection::size ( ) const
inlinenoexcept

Return the number of arrays.

◆ swap()

void teca_array_collection::swap ( const p_teca_dataset &  other)
overridevirtual

swap

Reimplemented from teca_dataset.

◆ to_stream() [1/2]

int teca_array_collection::to_stream ( std::ostream &  ) const
overridevirtual

stream to a human readable representation

Reimplemented from teca_dataset.

◆ to_stream() [2/2]

int teca_array_collection::to_stream ( teca_binary_stream s) const
overridevirtual

serialize the data to the given stream for I/O or communication

Reimplemented from teca_dataset.


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