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 "teca_variant_array_util.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...
 
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, ...)
 
#define NESTED_TEMPLATE_DISPATCH_CASE(tt, nt, p, i, ...)
 
#define TEMPLATE_DISPATCH_FP(t, p, ...)
 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, ...)
 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, ...)
 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, ...)
 Executes the code in body if p is a t<nt> where nt is an integral type. More...
 
#define TEMPLATE_DISPATCH(t, p, ...)
 
#define TEMPLATE_DISPATCH_OBJ(t, p, ...)
 
#define TEMPLATE_DISPATCH_PTR(t, p, ...)
 
#define NESTED_TEMPLATE_DISPATCH_FP(t, p, i, ...)
 
#define NESTED_TEMPLATE_DISPATCH_I(t, p, i, ...)
 
#define NESTED_TEMPLATE_DISPATCH(t, p, i, ...)
 
#define NESTED_VARIANT_ARRAY_DISPATCH(p, i, ...)    NESTED_TEMPLATE_DISPATCH(teca_variant_array_impl, p, i, __VA_ARGS__)
 
#define NESTED_VARIANT_ARRAY_DISPATCH_FP(p, i, ...)    NESTED_TEMPLATE_DISPATCH_FP(teca_variant_array_impl, p, i, __VA_ARGS__)
 
#define NESTED_VARIANT_ARRAY_DISPATCH_I(p, i, ...)    NESTED_TEMPLATE_DISPATCH_I(teca_variant_array_impl, p, i, __VA_ARGS__)
 
#define NESTED_VARIANT_ARRAY_DISPATCH_CASE(nt, p, i, ...)    TEMPLATE_DISPATCH_CASE(teca_variant_array_impl, nt, p, i, __VA_ARGS__)
 
#define VARIANT_ARRAY_DISPATCH(p, ...)    TEMPLATE_DISPATCH(teca_variant_array_impl, p, __VA_ARGS__)
 
#define VARIANT_ARRAY_DISPATCH_FP(p, ...)    TEMPLATE_DISPATCH_FP(teca_variant_array_impl, p, __VA_ARGS__)
 
#define VARIANT_ARRAY_DISPATCH_I(p, ...)    TEMPLATE_DISPATCH_I(teca_variant_array_impl, p, __VA_ARGS__)
 
#define VARIANT_ARRAY_DISPATCH_FP_SI(p, ...)    TEMPLATE_DISPATCH_FP_SI(teca_variant_array_impl, p, __VA_ARGS__)
 
#define VARIANT_ARRAY_DISPATCH_CASE(nt, p, ...)    TEMPLATE_DISPATCH_CASE(teca_variant_array_impl, nt, p, __VA_ARGS__)
 
#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,
  ... 
)
Value:
NESTED_TEMPLATE_DISPATCH_FP(t, p, i, __VA_ARGS__) \
else NESTED_TEMPLATE_DISPATCH_I(t, p, i, __VA_ARGS__)
#define NESTED_TEMPLATE_DISPATCH_I(t, p, i,...)
Definition: teca_variant_array_impl.h:290
#define NESTED_TEMPLATE_DISPATCH_FP(t, p, i,...)
Definition: teca_variant_array_impl.h:278

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,
  ... 
)
Value:
if (dynamic_cast<const tt<nt>*>(p)) \
{ \
using NT##i = nt; \
using CNT##i = const nt; \
using TT##i = tt<nt>; \
using CTT##i = const tt<nt>; \
using PT##i = std::shared_ptr<tt<nt>>; \
using CPT##i = std::shared_ptr<const tt<nt>>; \
using SP##i = std::shared_ptr<nt>; \
using CSP##i = std::shared_ptr<const nt>; \
__VA_ARGS__ \
}

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 NT##i = nt;
 using CNT##i = const nt;
 using TT##i = tt<nt>;
 using CTT##i = const tt<nt>;
 using PT##i = std::shared_ptr<tt<nt>>;
 using CPT##i = std::shared_ptr<const tt<nt>>;
 using SP##i = std::shared_ptr<nt>;
 using CSP##i = std::shared_ptr<const nt>;

◆ NESTED_TEMPLATE_DISPATCH_FP

#define NESTED_TEMPLATE_DISPATCH_FP (   t,
  p,
  i,
  ... 
)
Value:
NESTED_TEMPLATE_DISPATCH_CASE(t, float, p, i, __VA_ARGS__) \
else NESTED_TEMPLATE_DISPATCH_CASE(t, double, p, i, __VA_ARGS__)
#define NESTED_TEMPLATE_DISPATCH_CASE(tt, nt, p, i,...)
Definition: teca_variant_array_impl.h:191

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,
  ... 
)
Value:
NESTED_TEMPLATE_DISPATCH_CASE(t, long long, p, i, __VA_ARGS__) \
else NESTED_TEMPLATE_DISPATCH_CASE(t, unsigned long long, p, i, __VA_ARGS__) \
else NESTED_TEMPLATE_DISPATCH_CASE(t, long, p, i, __VA_ARGS__) \
else NESTED_TEMPLATE_DISPATCH_CASE(t, int, p, i, __VA_ARGS__) \
else NESTED_TEMPLATE_DISPATCH_CASE(t, unsigned int, p, i, __VA_ARGS__) \
else NESTED_TEMPLATE_DISPATCH_CASE(t, unsigned long, p, i, __VA_ARGS__) \
else NESTED_TEMPLATE_DISPATCH_CASE(t, short int, p, i, __VA_ARGS__) \
else NESTED_TEMPLATE_DISPATCH_CASE(t, short unsigned int, p, i, __VA_ARGS__) \
else NESTED_TEMPLATE_DISPATCH_CASE(t, char, p, i, __VA_ARGS__) \
else NESTED_TEMPLATE_DISPATCH_CASE(t, unsigned char, p, i, __VA_ARGS__)

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.

◆ NESTED_VARIANT_ARRAY_DISPATCH

#define NESTED_VARIANT_ARRAY_DISPATCH (   p,
  i,
  ... 
)     NESTED_TEMPLATE_DISPATCH(teca_variant_array_impl, p, i, __VA_ARGS__)

shortcuts for NESTED_TEMPLATE_DISPATCH macros

◆ TEMPLATE_DISPATCH

#define TEMPLATE_DISPATCH (   t,
  p,
  ... 
)
Value:
TEMPLATE_DISPATCH_FP(t, p, __VA_ARGS__) \
else TEMPLATE_DISPATCH_I(t, p, __VA_ARGS__)
#define TEMPLATE_DISPATCH_FP(t, p,...)
Executes the code in body if p is a t<nt> where nt is a floating point type.
Definition: teca_variant_array_impl.h:206
#define TEMPLATE_DISPATCH_I(t, p,...)
Executes the code in body if p is a t<nt> where nt is an integral type.
Definition: teca_variant_array_impl.h:225

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,
  ... 
)
Value:
if (dynamic_cast<const tt<nt>*>(p)) \
{ \
using NT = nt; \
using CNT = const nt; \
using TT = tt<nt>; \
using CTT = const tt<nt>; \
using PT = std::shared_ptr<tt<nt>>; \
using CPT = std::shared_ptr<const tt<nt>>; \
using SP = std::shared_ptr<nt>; \
using CSP = std::shared_ptr<const nt>; \
__VA_ARGS__ \
}

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 NT = nt;
 using CNT = const nt;
 using TT = tt<nt>;
 using CTT = const tt<nt>;
 using PT = std::shared_ptr<tt<nt>>;
 using CPT = std::shared_ptr<const tt<nt>>;
 using SP = std::shared_ptr<nt>;
 using CSP = std::shared_ptr<const nt>;

◆ TEMPLATE_DISPATCH_FP

#define TEMPLATE_DISPATCH_FP (   t,
  p,
  ... 
)
Value:
TEMPLATE_DISPATCH_CASE(t, float, p, __VA_ARGS__) \
else TEMPLATE_DISPATCH_CASE(t, double, p, __VA_ARGS__)
#define TEMPLATE_DISPATCH_CASE(tt, nt, p,...)
Definition: teca_variant_array_impl.h:156

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,
  ... 
)
Value:
TEMPLATE_DISPATCH_CASE(t, float, p, __VA_ARGS__) \
else TEMPLATE_DISPATCH_CASE(t, double, p, __VA_ARGS__) \
else TEMPLATE_DISPATCH_SI(t, p, __VA_ARGS__)
#define TEMPLATE_DISPATCH_SI(t, p,...)
Executes the code in body if p is a t<nt> where nt is a signed inetegral type.
Definition: teca_variant_array_impl.h:211

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,
  ... 
)
Value:
TEMPLATE_DISPATCH_CASE(t, long long, p, __VA_ARGS__) \
else TEMPLATE_DISPATCH_CASE(t, unsigned long long, p, __VA_ARGS__) \
else TEMPLATE_DISPATCH_CASE(t, long, p, __VA_ARGS__) \
else TEMPLATE_DISPATCH_CASE(t, int, p, __VA_ARGS__) \
else TEMPLATE_DISPATCH_CASE(t, unsigned int, p, __VA_ARGS__) \
else TEMPLATE_DISPATCH_CASE(t, unsigned long, p, __VA_ARGS__) \
else TEMPLATE_DISPATCH_CASE(t, short int, p, __VA_ARGS__) \
else TEMPLATE_DISPATCH_CASE(t, short unsigned int, p, __VA_ARGS__) \
else TEMPLATE_DISPATCH_CASE(t, char, p, __VA_ARGS__) \
else TEMPLATE_DISPATCH_CASE(t, unsigned char, p, __VA_ARGS__)

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,
  ... 
)
Value:
TEMPLATE_DISPATCH_CASE(t, std::string, p, __VA_ARGS__) \
else TEMPLATE_DISPATCH_CASE(t, teca_metadata, p, __VA_ARGS__)
A generic container for meta data in the form of name=value pairs.
Definition: teca_metadata.h:22

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,
  ... 
)
Value:
std::shared_ptr< teca_variant_array > p_teca_variant_array
Definition: teca_variant_array.h:27
std::shared_ptr< const teca_variant_array > const_p_teca_variant_array
Definition: teca_variant_array.h:27

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,
  ... 
)
Value:
TEMPLATE_DISPATCH_CASE(t, long long, p, __VA_ARGS__) \
else TEMPLATE_DISPATCH_CASE(t, long, p, __VA_ARGS__) \
else TEMPLATE_DISPATCH_CASE(t, int, p, __VA_ARGS__) \
else TEMPLATE_DISPATCH_CASE(t, short int, p, __VA_ARGS__) \
else TEMPLATE_DISPATCH_CASE(t, char, p, __VA_ARGS__)

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

◆ VARIANT_ARRAY_DISPATCH

#define VARIANT_ARRAY_DISPATCH (   p,
  ... 
)     TEMPLATE_DISPATCH(teca_variant_array_impl, p, __VA_ARGS__)

shortcuts for TEMPLATE_DISPATCH macros

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.