NGen
Loading...
Searching...
No Matches
ngen::detail::variable< SupportedTypes > Struct Template Reference

Variable Key. More...

#include <variable.hpp>

+ Collaboration diagram for ngen::detail::variable< SupportedTypes >:

Classes

struct  hash
 

Public Types

using size_type = std::size_t
 
using types = traits::type_list<SupportedTypes...>
 The variable value types this frame can support.
 
using mdarray_variant = typename types::template variant_container<ngen::mdarray>
 A boost::variant type consisting of mdarrays of the support types, i.e.
 
using element_type = typename types::variant_scalar
 

Public Member Functions

 variable () noexcept
 Constructs an empty variable.
 
template<typename T , typename types::template enable_if_supports< T, bool > = true>
variableset_data (const mdarray< T > &data)
 Assign an mdarray to this variable.
 
template<typename T , typename types::template enable_if_supports< T, bool > = true>
variableset_data (mdarray< T > &&data)
 Assign an mdarray to this variable.
 
const mdarray_variantvalues () const noexcept
 Get the values of this variable.
 
template<typename T , typename types::template enable_if_supports< T, bool > = true>
const mdarray< T > & values () const noexcept
 
bool operator== (const variable &rhs) const
 Equality operator to check equality between two variables.
 
const std::string & name () const noexcept
 Get the name of this variable.
 
std::vector< std::string > dimensions () const noexcept
 Get the names of all dimensions associated with this variable.
 
size_type size () const noexcept
 Get the size of this variable.
 
size_type rank () const noexcept
 Get the rank of this variable.
 
template<typename T , typename types::template enable_if_supports< T, bool > = true>
void insert (boost::span< const size_type > index, T value)
 Construct and insert a mdvalue into the backing mdarray.
 
element_type at (const boost::span< const size_type > index)
 Access value at a given index.
 
template<typename T , typename types::template enable_if_supports< T, bool > = true>
at (boost::span< const size_type > index)
 
boost::span< const size_typeshape () const noexcept
 

Static Public Member Functions

template<typename T , typename types::template enable_if_supports< T, bool > = true>
static variable make (const std::string &name, const std::vector< dimension > &dimensions)
 Constructs a named variable spanned over the given dimensions.
 

Private Attributes

std::string m_name
 
mdarray_variant m_data
 
std::vector< dimensionm_dimensions
 

Detailed Description

template<typename... SupportedTypes>
struct ngen::detail::variable< SupportedTypes >

Variable Key.

Provides a tagged variable structure.

Template Parameters
SupportedTypestypes that this variable is able to hold.

Member Typedef Documentation

◆ element_type

template<typename... SupportedTypes>
using ngen::detail::variable< SupportedTypes >::element_type = typename types::variant_scalar

◆ mdarray_variant

template<typename... SupportedTypes>
using ngen::detail::variable< SupportedTypes >::mdarray_variant = typename types::template variant_container<ngen::mdarray>

A boost::variant type consisting of mdarrays of the support types, i.e.

for types int and double, this is equivalent to: boost::variant<io::mdarray<int>, io::mdarray<double>>

◆ size_type

template<typename... SupportedTypes>
using ngen::detail::variable< SupportedTypes >::size_type = std::size_t

◆ types

template<typename... SupportedTypes>
using ngen::detail::variable< SupportedTypes >::types = traits::type_list<SupportedTypes...>

The variable value types this frame can support.

These are stored as a compile-time type list to derive further type aliases.

Constructor & Destructor Documentation

◆ variable()

template<typename... SupportedTypes>
ngen::detail::variable< SupportedTypes >::variable ( )
inlinenoexcept

Constructs an empty variable.

Member Function Documentation

◆ at() [1/2]

template<typename... SupportedTypes>
template<typename T , typename types::template enable_if_supports< T, bool > = true>
T ngen::detail::variable< SupportedTypes >::at ( boost::span< const size_type > index)
inline

◆ at() [2/2]

template<typename... SupportedTypes>
element_type ngen::detail::variable< SupportedTypes >::at ( const boost::span< const size_type > index)
inline

Access value at a given index.

Parameters
indexMulti-dimensional index. Size of this index list must match the dimensions of this variable.
Returns
A variant corresponding to the value within this variable at the given index.

References ngen::detail::variable< SupportedTypes >::m_data.

◆ dimensions()

template<typename... SupportedTypes>
std::vector< std::string > ngen::detail::variable< SupportedTypes >::dimensions ( ) const
inlinenoexcept

Get the names of all dimensions associated with this variable.

Returns
std::vector<std::string>

References ngen::detail::variable< SupportedTypes >::m_dimensions.

Referenced by ngen::detail::variable< SupportedTypes >::make().

◆ insert()

template<typename... SupportedTypes>
template<typename T , typename types::template enable_if_supports< T, bool > = true>
void ngen::detail::variable< SupportedTypes >::insert ( boost::span< const size_type > index,
T value )
inline

Construct and insert a mdvalue into the backing mdarray.

See also
mdarray::emplace
Template Parameters
TMust be the type stored within the mdarray
Parameters
indexMulti-dimensional index to insert to
valueValue to insert into mdarray

References ngen::detail::variable< SupportedTypes >::m_data.

◆ make()

template<typename... SupportedTypes>
template<typename T , typename types::template enable_if_supports< T, bool > = true>
static variable ngen::detail::variable< SupportedTypes >::make ( const std::string & name,
const std::vector< dimension > & dimensions )
inlinestatic

◆ name()

template<typename... SupportedTypes>
const std::string & ngen::detail::variable< SupportedTypes >::name ( ) const
inlinenoexcept

Get the name of this variable.

Returns
const std::string&

References ngen::detail::variable< SupportedTypes >::m_name.

Referenced by ngen::detail::variable< SupportedTypes >::make().

◆ operator==()

template<typename... SupportedTypes>
bool ngen::detail::variable< SupportedTypes >::operator== ( const variable< SupportedTypes > & rhs) const
inline

Equality operator to check equality between two variables.

Note
This operator compares the hashes of the variable names, not the backing mdarray.
Parameters
rhs
Returns
true if the variables have the same name
false if the variables have different names

References ngen::detail::variable< SupportedTypes >::m_name.

◆ rank()

template<typename... SupportedTypes>
size_type ngen::detail::variable< SupportedTypes >::rank ( ) const
inlinenoexcept

Get the rank of this variable.

See also
mdarray::rank
Returns
size_type

References ngen::detail::variable< SupportedTypes >::m_data.

◆ set_data() [1/2]

template<typename... SupportedTypes>
template<typename T , typename types::template enable_if_supports< T, bool > = true>
variable & ngen::detail::variable< SupportedTypes >::set_data ( const mdarray< T > & data)
inline

Assign an mdarray to this variable.

Template Parameters
TSupported mdframe types.
Parameters
dataThe mdarray to assign.
Returns
variable&

References ngen::detail::variable< SupportedTypes >::m_data.

◆ set_data() [2/2]

template<typename... SupportedTypes>
template<typename T , typename types::template enable_if_supports< T, bool > = true>
variable & ngen::detail::variable< SupportedTypes >::set_data ( mdarray< T > && data)
inline

Assign an mdarray to this variable.

Template Parameters
TSupported mdframe types.
Parameters
dataThe mdarray to assign.
Returns
variable&

References ngen::detail::variable< SupportedTypes >::m_data.

◆ shape()

template<typename... SupportedTypes>
boost::span< const size_type > ngen::detail::variable< SupportedTypes >::shape ( ) const
inlinenoexcept

◆ size()

template<typename... SupportedTypes>
size_type ngen::detail::variable< SupportedTypes >::size ( ) const
inlinenoexcept

Get the size of this variable.

See also
mdarray::size
Returns
size_type

References ngen::detail::variable< SupportedTypes >::m_data.

◆ values() [1/2]

template<typename... SupportedTypes>
const mdarray_variant & ngen::detail::variable< SupportedTypes >::values ( ) const
inlinenoexcept

Get the values of this variable.

Returns
const mdarray_variant&

References ngen::detail::variable< SupportedTypes >::m_data.

◆ values() [2/2]

template<typename... SupportedTypes>
template<typename T , typename types::template enable_if_supports< T, bool > = true>
const mdarray< T > & ngen::detail::variable< SupportedTypes >::values ( ) const
inlinenoexcept

Member Data Documentation

◆ m_data

◆ m_dimensions

template<typename... SupportedTypes>
std::vector<dimension> ngen::detail::variable< SupportedTypes >::m_dimensions
private

◆ m_name

template<typename... SupportedTypes>
std::string ngen::detail::variable< SupportedTypes >::m_name
mutableprivate

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