AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
axom::sina::Datum Class Reference

An object to track a value associated with a Record. More...

#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/develop/src/axom/sina/core/Datum.hpp>

Public Member Functions

 Datum (const std::string &value)
 Construct a new Datum. More...
 
 Datum (const double &value)
 Construct a new Datum. More...
 
 Datum (const std::vector< std::string > &value)
 Construct a new Datum. More...
 
 Datum (const std::vector< double > &value)
 Construct a new Datum. More...
 
 Datum (conduit::Node const &asNode)
 Construct a Datum from its Node representation. More...
 
std::string const & getValue () const noexcept
 Get the string value of the Datum. More...
 
double const & getScalar () const noexcept
 Get the scalar value of the Datum. More...
 
std::vector< std::string > const & getStringArray () const noexcept
 Get the string array value of the Datum. More...
 
std::vector< double > const & getScalarArray () const noexcept
 Get the scalar array value of the Datum. More...
 
std::vector< std::string > const & getTags () const noexcept
 Get the tags of the Datum. More...
 
void setTags (const std::vector< std::string > &tags)
 Set the tags of the Datum. More...
 
std::string const & getUnits () const noexcept
 Get the units of the Datum. More...
 
void setUnits (const std::string &units)
 Set the units of the Datum. More...
 
ValueType getType () const noexcept
 Get the type of the Datum. More...
 
conduit::Node toNode () const
 Convert this Datum to its conduit Node representation. More...
 

Detailed Description

An object to track a value associated with a Record.

A Datum tracks the value and (optionally) tags and/or units of a value associated with a Record, e.g. a scalar, a piece of metadata, or an input parameter. In the Sina schema, a Datum always belongs to a Record or one of Record's inheriting types.

Every Datum must have a value; units and tags are optional.

The value of a Datum may be a string, a double, an array of strings, or an array of doubles.

axom::sina::Datum myDatum{12.34};
std::string value = "foobar";
axom::sina::Datum myOtherDatum{value};
std::vector<double> scalars = {1, 2, 20.0};
axom::sina::Datum myArrayDatum{scalars};
//prints 1, corresponding to Scalar
std::cout << static_cast<std::underlying_type<sina::ValueType>::type>(myDatum.getType()) << std::endl;
//prints 0, corresponding to String
std::cout << static_cast<std::underlying_type<sina::ValueType>::type>(myOtherDatum.getType()) << std::endl;
//prints 3, corresponding to ScalarArray
std::cout << static_cast<std::underlying_type<sina::ValueType>::type>(myArrayDatum.getType()) << std::endl;
myRecord->add(myDatum);
myOtherDatum.setUnits("km/s");
myRecord->add(myOtherDatum);
std::vector<std:string> tags = {"input", "core"};
myArrayDatum.setTags(tags);
myRecord->add(myArrayDatum);
An object to track a value associated with a Record.
Definition: Datum.hpp:81
void setUnits(const std::string &units)
Set the units of the Datum.

Constructor & Destructor Documentation

◆ Datum() [1/5]

axom::sina::Datum::Datum ( const std::string &  value)

Construct a new Datum.

Parameters
valuethe string value of the datum

◆ Datum() [2/5]

axom::sina::Datum::Datum ( const double &  value)

Construct a new Datum.

Parameters
valuethe double value of the datum

◆ Datum() [3/5]

axom::sina::Datum::Datum ( const std::vector< std::string > &  value)

Construct a new Datum.

Parameters
valuethe string array value of the datum

◆ Datum() [4/5]

axom::sina::Datum::Datum ( const std::vector< double > &  value)

Construct a new Datum.

Parameters
valuethe scalar array value of the datum

◆ Datum() [5/5]

axom::sina::Datum::Datum ( conduit::Node const &  asNode)
explicit

Construct a Datum from its Node representation.

Parameters
asNodethe Datum as conduit Node

Member Function Documentation

◆ getValue()

std::string const& axom::sina::Datum::getValue ( ) const
inlinenoexcept

Get the string value of the Datum.

Returns
the string value

◆ getScalar()

double const& axom::sina::Datum::getScalar ( ) const
inlinenoexcept

Get the scalar value of the Datum.

Returns
the scalar value

◆ getStringArray()

std::vector<std::string> const& axom::sina::Datum::getStringArray ( ) const
inlinenoexcept

Get the string array value of the Datum.

Returns
the string vector value

◆ getScalarArray()

std::vector<double> const& axom::sina::Datum::getScalarArray ( ) const
inlinenoexcept

Get the scalar array value of the Datum.

Returns
the scalar vector value

◆ getTags()

std::vector<std::string> const& axom::sina::Datum::getTags ( ) const
inlinenoexcept

Get the tags of the Datum.

Returns
the tags of the value

◆ setTags()

void axom::sina::Datum::setTags ( const std::vector< std::string > &  tags)

Set the tags of the Datum.

Parameters
tagsthe tags of the value

◆ getUnits()

std::string const& axom::sina::Datum::getUnits ( ) const
inlinenoexcept

Get the units of the Datum.

Returns
the units of the value

◆ setUnits()

void axom::sina::Datum::setUnits ( const std::string &  units)

Set the units of the Datum.

Parameters
unitsthe units of the value

◆ getType()

ValueType axom::sina::Datum::getType ( ) const
inlinenoexcept

Get the type of the Datum.

Returns
the type of the value

◆ toNode()

conduit::Node axom::sina::Datum::toNode ( ) const

Convert this Datum to its conduit Node representation.

Returns
the Node representation of this Datum.

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