TECA
The Toolkit for Extreme Climate Analysis
teca_variant_array_impl.h File Reference
#include "teca_config.h"
#include "teca_variant_array.h"
#include "teca_common.h"
#include "teca_binary_stream.h"
#include "teca_bad_cast.h"
#include "teca_shared_object.h"
#include <hamr_buffer.h>
#include <vector>
#include <string>
#include <sstream>
#include <exception>
#include <typeinfo>
#include <iterator>
#include <algorithm>
#include <type_traits>
#include <utility>
#include <limits>
Include dependency graph for teca_variant_array_impl.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  teca_variant_array_impl< T >
 The concrete implementation of our type agnostic container for contiguous arrays. More...
 
class  teca_variant_array_impl< T >
 The concrete implementation of our type agnostic container for contiguous arrays. More...
 
struct  teca_variant_array_factory
 Creates an instance of teca_variant_array_impl<T> where T is determined from the type code. More...
 

Macros

#define TEMPLATE_DISPATCH_CASE(tt, nt, p, body)
 
#define NESTED_TEMPLATE_DISPATCH_CASE(tt, nt, p, i, body)
 
#define TEMPLATE_DISPATCH_FP(t, p, body)
 Executes the code in body if p is a t<nt> where nt is a floating point type. More...
 
#define TEMPLATE_DISPATCH_SI(t, p, body)
 Executes the code in body if p is a t<nt> where nt is a signed inetegral type. More...
 
#define TEMPLATE_DISPATCH_FP_SI(t, p, body)
 Executes the code in body if p is a t<nt> where nt is either a signed integral or floating point type. More...
 
#define TEMPLATE_DISPATCH_I(t, p, body)
 Executes the code in body if p is a t<nt> where nt is an integral type. More...
 
#define TEMPLATE_DISPATCH(t, p, body)
 
#define TEMPLATE_DISPATCH_OBJ(t, p, body)
 
#define TEMPLATE_DISPATCH_PTR(t, p, body)
 
#define NESTED_TEMPLATE_DISPATCH_FP(t, p, i, body)
 
#define NESTED_TEMPLATE_DISPATCH_I(t, p, i, body)
 
#define NESTED_TEMPLATE_DISPATCH(t, p, i, body)
 
#define STR_DELIM(_a, _b)   (std::is_same<T, std::string>::value ? _a : _b)
 

Typedefs

template<typename T >
using p_teca_variant_array_impl = std::shared_ptr< teca_variant_array_impl< T > >
 
template<typename T >
using const_p_teca_variant_array_impl = std::shared_ptr< const teca_variant_array_impl< T > >
 
using teca_string_array = teca_variant_array_impl< std::string >
 
using p_teca_string_array = std::shared_ptr< teca_variant_array_impl< std::string > >
 
using const_p_teca_string_array = std::shared_ptr< const teca_variant_array_impl< std::string > >
 
using teca_float_array = teca_variant_array_impl< float >
 
using p_teca_float_array = std::shared_ptr< teca_variant_array_impl< float > >
 
using const_p_teca_float_array = std::shared_ptr< const teca_variant_array_impl< float > >
 
using teca_double_array = teca_variant_array_impl< double >
 
using p_teca_double_array = std::shared_ptr< teca_variant_array_impl< double > >
 
using const_p_teca_double_array = std::shared_ptr< const teca_variant_array_impl< double > >
 
using teca_char_array = teca_variant_array_impl< char >
 
using p_teca_char_array = std::shared_ptr< teca_variant_array_impl< char > >
 
using const_p_teca_char_array = std::shared_ptr< const teca_variant_array_impl< char > >
 
using teca_unsigned_char_array = teca_variant_array_impl< unsigned char >
 
using p_teca_unsigned_char_array = std::shared_ptr< teca_variant_array_impl< unsigned char > >
 
using const_p_teca_unsigned_char_array = std::shared_ptr< const teca_variant_array_impl< unsigned char > >
 
using teca_short_array = teca_variant_array_impl< short >
 
using p_teca_short_array = std::shared_ptr< teca_variant_array_impl< short > >
 
using const_p_teca_short_array = std::shared_ptr< const teca_variant_array_impl< short > >
 
using teca_unsigned_short_array = teca_variant_array_impl< unsigned short >
 
using p_teca_unsigned_short_array = std::shared_ptr< teca_variant_array_impl< unsigned short > >
 
using const_p_teca_unsigned_short_array = std::shared_ptr< const teca_variant_array_impl< unsigned short > >
 
using teca_int_array = teca_variant_array_impl< int >
 
using p_teca_int_array = std::shared_ptr< teca_variant_array_impl< int > >
 
using const_p_teca_int_array = std::shared_ptr< const teca_variant_array_impl< int > >
 
using teca_unsigned_int_array = teca_variant_array_impl< unsigned int >
 
using p_teca_unsigned_int_array = std::shared_ptr< teca_variant_array_impl< unsigned int > >
 
using const_p_teca_unsigned_int_array = std::shared_ptr< const teca_variant_array_impl< unsigned int > >
 
using teca_long_array = teca_variant_array_impl< long >
 
using p_teca_long_array = std::shared_ptr< teca_variant_array_impl< long > >
 
using const_p_teca_long_array = std::shared_ptr< const teca_variant_array_impl< long > >
 
using teca_unsigned_long_array = teca_variant_array_impl< unsigned long >
 
using p_teca_unsigned_long_array = std::shared_ptr< teca_variant_array_impl< unsigned long > >
 
using const_p_teca_unsigned_long_array = std::shared_ptr< const teca_variant_array_impl< unsigned long > >
 
using teca_long_long_array = teca_variant_array_impl< long long >
 
using p_teca_long_long_array = std::shared_ptr< teca_variant_array_impl< long long > >
 
using const_p_teca_long_long_array = std::shared_ptr< const teca_variant_array_impl< long long > >
 
using teca_unsigned_long_long_array = teca_variant_array_impl< unsigned long long >
 
using p_teca_unsigned_long_long_array = std::shared_ptr< teca_variant_array_impl< unsigned long long > >
 
using const_p_teca_unsigned_long_long_array = std::shared_ptr< const teca_variant_array_impl< unsigned long long > >
 
using teca_size_t_array = teca_variant_array_impl< size_t >
 
using p_teca_size_t_array = std::shared_ptr< teca_variant_array_impl< size_t > >
 
using const_p_teca_size_t_array = std::shared_ptr< const teca_variant_array_impl< size_t > >
 

Functions

template<typename T >
const_p_teca_variant_array_impl< T > const_ptr (const p_teca_variant_array_impl< T > &v)
 
template<typename T >
TECA_EXPORT T min (const const_p_teca_variant_array_impl< T > &a)
 
template<typename T >
TECA_EXPORT T min (const p_teca_variant_array_impl< T > &a)
 
template<typename T >
TECA_EXPORT T max (const const_p_teca_variant_array_impl< T > &a)
 
template<typename T >
TECA_EXPORT T max (const p_teca_variant_array_impl< T > &a)
 

Macro Definition Documentation

◆ NESTED_TEMPLATE_DISPATCH

#define NESTED_TEMPLATE_DISPATCH (   t,
  p,
  i,
  body 
)
Value:
NESTED_TEMPLATE_DISPATCH_FP(t, p, i, body) \
else NESTED_TEMPLATE_DISPATCH_I(t, p, i, body)

A macro for accessing the typed contents of a teca_variant_array

Parameters
tcontainer type
ppointer to an instance to match on
ian indentifier to use with type aliases
bodycode to execute on match

See NESTED_TEMPLATE_DISPATCH_CASE for details.

◆ NESTED_TEMPLATE_DISPATCH_CASE

#define NESTED_TEMPLATE_DISPATCH_CASE (   tt,
  nt,
  p,
  i,
  body 
)
Value:
if (dynamic_cast<tt<nt>*>(p)) \
{ \
using TT##i = tt<nt>; \
using NT##i = nt; \
body \
}

Executes the code in body if p is a tt<nt> an idnetifier disambiguates type aliases when nested

Parameters
ttderived container
ntcontained type
pbase class pointer
iidentifier
bodythe code to execute if the type matches

The following aliases are provided to know the type within the code to execute.

using TT##i = tt<nt>;
using NT##i = nt;

◆ NESTED_TEMPLATE_DISPATCH_FP

#define NESTED_TEMPLATE_DISPATCH_FP (   t,
  p,
  i,
  body 
)
Value:
NESTED_TEMPLATE_DISPATCH_CASE(t, float, p, i, body) \
else NESTED_TEMPLATE_DISPATCH_CASE(t, double, p, i, body)

A macro for accessing the floating point typed contents of a teca_variant_array

Parameters
tcontainer type
ppointer to an instance to match on
ian indentifier to use with type aliases
bodycode to execute on match

See NESTED_TEMPLATE_DISPATCH_CASE for details.

◆ NESTED_TEMPLATE_DISPATCH_I

#define NESTED_TEMPLATE_DISPATCH_I (   t,
  p,
  i,
  body 
)
Value:
NESTED_TEMPLATE_DISPATCH_CASE(t, long long, p, i, body) \
else NESTED_TEMPLATE_DISPATCH_CASE(t, unsigned long long, p, i, body) \
else NESTED_TEMPLATE_DISPATCH_CASE(t, long, p, i, body) \
else NESTED_TEMPLATE_DISPATCH_CASE(t, int, p, i, body) \
else NESTED_TEMPLATE_DISPATCH_CASE(t, unsigned int, p, i, body) \
else NESTED_TEMPLATE_DISPATCH_CASE(t, unsigned long, p, i, body) \
else NESTED_TEMPLATE_DISPATCH_CASE(t, short int, p, i, body) \
else NESTED_TEMPLATE_DISPATCH_CASE(t, short unsigned int, p, i, body) \
else NESTED_TEMPLATE_DISPATCH_CASE(t, char, p, i, body) \
else NESTED_TEMPLATE_DISPATCH_CASE(t, unsigned char, p, i, body)

A macro for accessing the inetgral typed contents of a teca_variant_array

Parameters
tcontainer type
ppointer to an instance to match on
ian indentifier to use with type aliases
bodycode to execute on match

See NESTED_TEMPLATE_DISPATCH_CASE for details.

◆ TEMPLATE_DISPATCH

#define TEMPLATE_DISPATCH (   t,
  p,
  body 
)
Value:
TEMPLATE_DISPATCH_FP(t, p, body) \
else TEMPLATE_DISPATCH_I(t, p, body)

A macro for accessing the typed contents of a teca_variant_array

Parameters
tcontainer type
ppointer to an instance to match on
bodycode to execute on match

See TEMPLATE_DISPATCH_CASE for details.

◆ TEMPLATE_DISPATCH_CASE

#define TEMPLATE_DISPATCH_CASE (   tt,
  nt,
  p,
  body 
)
Value:
if (dynamic_cast<tt<nt>*>(p)) \
{ \
using TT = tt<nt>; \
using NT = nt; \
body \
}

Executes the code in body if p is a tt<nt>

Parameters
ttderived container
ntcontained type
pbase class pointer
bodythe code to execute if the type matches

The following aliases are provided to know the type within the code to execute.

using TT = tt<nt>;
using NT = nt;

◆ TEMPLATE_DISPATCH_FP

#define TEMPLATE_DISPATCH_FP (   t,
  p,
  body 
)
Value:
TEMPLATE_DISPATCH_CASE(t, float, p, body) \
else TEMPLATE_DISPATCH_CASE(t, double, p, body)

Executes the code in body if p is a t<nt> where nt is a floating point type.

◆ TEMPLATE_DISPATCH_FP_SI

#define TEMPLATE_DISPATCH_FP_SI (   t,
  p,
  body 
)
Value:
TEMPLATE_DISPATCH_CASE(t, float, p, body) \
else TEMPLATE_DISPATCH_CASE(t, double, p, body) \
else TEMPLATE_DISPATCH_SI(t, p, body)

Executes the code in body if p is a t<nt> where nt is either a signed integral or floating point type.

◆ TEMPLATE_DISPATCH_I

#define TEMPLATE_DISPATCH_I (   t,
  p,
  body 
)
Value:
TEMPLATE_DISPATCH_CASE(t, long long, p, body) \
else TEMPLATE_DISPATCH_CASE(t, unsigned long long, p, body) \
else TEMPLATE_DISPATCH_CASE(t, long, p, body) \
else TEMPLATE_DISPATCH_CASE(t, int, p, body) \
else TEMPLATE_DISPATCH_CASE(t, unsigned int, p, body) \
else TEMPLATE_DISPATCH_CASE(t, unsigned long, p, body) \
else TEMPLATE_DISPATCH_CASE(t, short int, p, body) \
else TEMPLATE_DISPATCH_CASE(t, short unsigned int, p, body) \
else TEMPLATE_DISPATCH_CASE(t, char, p, body) \
else TEMPLATE_DISPATCH_CASE(t, unsigned char, p, body)

Executes the code in body if p is a t<nt> where nt is an integral type.

◆ TEMPLATE_DISPATCH_OBJ

#define TEMPLATE_DISPATCH_OBJ (   t,
  p,
  body 
)
Value:
TEMPLATE_DISPATCH_CASE(t, std::string, p, body) \

A macro for accessing the typed contents of a teca_variant_array

Parameters
tcontainer type
ppointer to an instance to match on
bodycode to execute on match

See TEMPLATE_DISPATCH_CASE for details.

◆ TEMPLATE_DISPATCH_PTR

#define TEMPLATE_DISPATCH_PTR (   t,
  p,
  body 
)
Value:

A macro for accessing the typed contents of a teca_variant_array

Parameters
tcontainer type
ppointer to an instance to match on
bodycode to execute on match

See TEMPLATE_DISPATCH_CASE for details.

◆ TEMPLATE_DISPATCH_SI

#define TEMPLATE_DISPATCH_SI (   t,
  p,
  body 
)
Value:
TEMPLATE_DISPATCH_CASE(t, long long, p, body) \
else TEMPLATE_DISPATCH_CASE(t, long, p, body) \
else TEMPLATE_DISPATCH_CASE(t, int, p, body) \
else TEMPLATE_DISPATCH_CASE(t, short int, p, body) \
else TEMPLATE_DISPATCH_CASE(t, char, p, body)

Executes the code in body if p is a t<nt> where nt is a signed inetegral type.

Typedef Documentation

◆ const_p_teca_variant_array_impl

template<typename T >
using const_p_teca_variant_array_impl = std::shared_ptr<const teca_variant_array_impl <T> >

A shared pointer to a const instance of teca_variant_array_impl

◆ p_teca_variant_array_impl

template<typename T >
using p_teca_variant_array_impl = std::shared_ptr< teca_variant_array_impl <T> >

a shared pointer to an instance of teca_variant_array_impl

Function Documentation

◆ const_ptr()

template<typename T >
const_p_teca_variant_array_impl<T> const_ptr ( const p_teca_variant_array_impl< T > &  v)

convert from a pointer to a non-const type to a pointer to a const type. this is used to help with template deduction, which occurs before implicit conversions are considered.

teca_metadata
A generic container for meta data in the form of name=value pairs.
Definition: teca_metadata.h:21
NESTED_TEMPLATE_DISPATCH_FP
#define NESTED_TEMPLATE_DISPATCH_FP(t, p, i, body)
Definition: teca_variant_array_impl.h:243
NESTED_TEMPLATE_DISPATCH_I
#define NESTED_TEMPLATE_DISPATCH_I(t, p, i, body)
Definition: teca_variant_array_impl.h:255
const_p_teca_variant_array
std::shared_ptr< const teca_variant_array > const_p_teca_variant_array
Definition: teca_variant_array.h:27
TEMPLATE_DISPATCH_CASE
#define TEMPLATE_DISPATCH_CASE(tt, nt, p, body)
Definition: teca_variant_array_impl.h:139
NESTED_TEMPLATE_DISPATCH_CASE
#define NESTED_TEMPLATE_DISPATCH_CASE(tt, nt, p, i, body)
Definition: teca_variant_array_impl.h:162
TEMPLATE_DISPATCH_FP
#define TEMPLATE_DISPATCH_FP(t, p, body)
Executes the code in body if p is a t<nt> where nt is a floating point type.
Definition: teca_variant_array_impl.h:171
p_teca_variant_array
std::shared_ptr< teca_variant_array > p_teca_variant_array
Definition: teca_variant_array.h:27
TEMPLATE_DISPATCH_SI
#define TEMPLATE_DISPATCH_SI(t, p, body)
Executes the code in body if p is a t<nt> where nt is a signed inetegral type.
Definition: teca_variant_array_impl.h:176
TEMPLATE_DISPATCH_I
#define TEMPLATE_DISPATCH_I(t, p, body)
Executes the code in body if p is a t<nt> where nt is an integral type.
Definition: teca_variant_array_impl.h:190