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

Provides functions to help define how individual Container and Field variables in an input file are expected to behave. It also holds the Sidre Group to the individual Container. More...

#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/latest/src/axom/inlet/Container.hpp>

Inheritance diagram for axom::inlet::Container:

Public Types

using Verifier = std::function< bool(const Container &, std::vector< VerificationError > *errors)>
 

Public Member Functions

 Container (const std::string &name, const std::string &description, Reader &reader, axom::sidre::Group *sidreRootGroup, std::vector< std::string > &unexpectedNames, bool docEnabled=true, bool reconstruct=false)
 Constructor for the Container class. More...
 
 Container (const Container &)=delete
 
 Container (Container &&)=default
 
virtual ~Container ()=default
 
axom::sidre::GroupsidreGroup ()
 Returns pointer to the Sidre Group class for this Container. More...
 
const axom::sidre::GroupsidreGroup () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
ContaineraddStruct (const std::string &name, const std::string &description="")
 Add a structure to the input file schema. More...
 
Verifiable< Container > & addBoolArray (const std::string &name, const std::string &description="")
 Add an array of Boolean Fields to the input file schema. More...
 
Verifiable< Container > & addIntArray (const std::string &name, const std::string &description="")
 Add an array of Integer Fields to the input file schema. More...
 
Verifiable< Container > & addDoubleArray (const std::string &name, const std::string &description="")
 Add an array of Double Fields to the input file schema. More...
 
Verifiable< Container > & addStringArray (const std::string &name, const std::string &description="")
 Add an array of String Fields to the input file schema. More...
 
ContaineraddStructArray (const std::string &name, const std::string &description="")
 Add an array of Fields to the input file schema. More...
 
Verifiable< Container > & addBoolDictionary (const std::string &name, const std::string &description="")
 Add a dictionary of Boolean Fields to the input file schema. More...
 
Verifiable< Container > & addIntDictionary (const std::string &name, const std::string &description="")
 Add a dictionary of Integer Fields to the input file schema. More...
 
Verifiable< Container > & addDoubleDictionary (const std::string &name, const std::string &description="")
 Add a dictionary of Double Fields to the input file schema. More...
 
Verifiable< Container > & addStringDictionary (const std::string &name, const std::string &description="")
 Add a dictionary of String Fields to the input file schema. More...
 
ContaineraddStructDictionary (const std::string &name, const std::string &description="")
 Add a dictionary of user-defined types to the input file schema. More...
 
VerifiableScalaraddBool (const std::string &name, const std::string &description="")
 Add a Boolean Field to the input file schema. More...
 
VerifiableScalaraddDouble (const std::string &name, const std::string &description="")
 Add a Double Field to the input file schema. More...
 
VerifiableScalaraddInt (const std::string &name, const std::string &description="")
 Add a Integer Field to the input file schema. More...
 
VerifiableScalaraddString (const std::string &name, const std::string &description="")
 Add a String Field to the input file schema. More...
 
Verifiable< Function > & addFunction (const std::string &name, const FunctionTag ret_type, const std::vector< FunctionTag > &arg_types, const std::string &description="", const std::string &pathOverride="")
 Get a function from the input deck. More...
 
template<typename T >
std::enable_if< detail::is_inlet_primitive< T >::value, T >::type get (const std::string &name) const
 Returns a stored value of primitive type. More...
 
template<typename T >
std::enable_if< !detail::is_inlet_primitive< T >::value &&!detail::is_inlet_array< T >::value &&!detail::is_inlet_dict< T >::value &&!detail::is_std_vector< T >::value, T >::type get (const std::string &name="") const
 Returns a stored value of user-defined type. More...
 
template<typename T >
std::enable_if< detail::is_inlet_array< T >::value||detail::is_inlet_dict< T >::value, T >::type get () const
 Returns a stored collection. More...
 
template<typename T >
std::enable_if< detail::is_std_vector< T >::value, T >::type get () const
 Returns a stored collection as a contiguous array. More...
 
Proxy operator[] (const std::string &name) const
 Obtains a proxy view into the container for either a Field/Container subobject. More...
 
Containerrequired (bool isRequired=true) override
 Set the required status of this object. More...
 
bool isRequired () const override
 Return the required status. More...
 
ContainerregisterVerifier (Verifier lambda) override
 Registers the function object that will verify this object's contents during the verification stage. More...
 
bool verify (std::vector< VerificationError > *errors=nullptr) const override
 Verifies the object to make sure it satisfies the imposed requirements. More...
 
Containerstrict (bool isStrict=true)
 Set the strictness of this Container. More...
 
bool contains (const std::string &name) const
 Return whether a Container or Field with the given name is present in this Container's subtree. More...
 
bool exists () const
 Returns whether this container or any of its subcontainers exist, i.e., if they contain a Field or Function that exists. More...
 
bool isUserProvided () const
 Returns whether this container or any of its subcontainers were provided in the input file, i.e., if they contain a Field or Function that was provided in the input file. More...
 
bool isUserProvided (const std::string &name) const
 Return whether a Container or Field with the given name were provided in the input file. More...
 
const std::unordered_map< std::string, std::unique_ptr< Field > > & getChildFields () const
 
const std::unordered_map< std::string, std::unique_ptr< Container > > & getChildContainers () const
 
const std::unordered_map< std::string, std::unique_ptr< Function > > & getChildFunctions () const
 
std::string name () const
 
std::vector< std::string > unexpectedNames () const
 Returns the list of unexpected names "below" the calling container, i.e., entries in the input file structure (e.g., a Lua table or YAML dictionary) corresponding to the calling container that were not requested/retrieved via an add* call. More...
 
template<typename T , typename SFINAE = typename std::enable_if<detail::is_inlet_primitive<T>::value>::type>
VerifiableScalaraddPrimitive (const std::string &name, const std::string &description="", bool forArray=false, T val=T {}, const std::string &pathOverride="")
 Add a Field to the input file schema. More...
 
Verifiable< Container > & registerVerifier (std::function< bool(const Container &)> verifier)
 Registers the function object that will verify this object's contents during the verification stage. More...
 

Detailed Description

Provides functions to help define how individual Container and Field variables in an input file are expected to behave. It also holds the Sidre Group to the individual Container.

See also
Inlet Field

Member Typedef Documentation

◆ Verifier

using axom::inlet::Verifiable< Container >::Verifier = std::function<bool(const Container &, std::vector<VerificationError>* errors)>
inherited

A function which can verify the contents of the item being verifier. It should report any errors via INLET_VERIFICATION_WARNING, passing in the given array of errors.

Constructor & Destructor Documentation

◆ Container() [1/3]

axom::inlet::Container::Container ( const std::string &  name,
const std::string &  description,
Reader reader,
axom::sidre::Group sidreRootGroup,
std::vector< std::string > &  unexpectedNames,
bool  docEnabled = true,
bool  reconstruct = false 
)

Constructor for the Container class.

This class provides functions to define the behavior of the Container data already read and stored in the given Sidre Group. This creates the necessary Sidre Group's and views to store the given name and description.

Parameters
[in]nameName of the Container expected in the input file
[in]descriptionDescription of the Container
[in]readerReference to the input file Reader class.
[in]sidreRootGroupPointer to the already created Sidre Group.
[in]unexpectedNamesReference to the global (relative to the Inlet hierarchy) list of unexpected names
[in]docEnabledBoolean indicating whether or not documentation generation is enabled for input feck this Container instance belongs to.
[in]reconstructWhether or not to attempt to reconstruct child Containers and Fields from the data in the sidre Group

◆ Container() [2/3]

axom::inlet::Container::Container ( const Container )
delete

◆ Container() [3/3]

axom::inlet::Container::Container ( Container &&  )
default

◆ ~Container()

virtual axom::inlet::Container::~Container ( )
virtualdefault

Member Function Documentation

◆ sidreGroup() [1/2]

axom::sidre::Group* axom::inlet::Container::sidreGroup ( )
inline

Returns pointer to the Sidre Group class for this Container.

Provides access to the Sidre Group class that holds all the stored information for this Container class.

Returns
Pointer to the Sidre Group for this Container

◆ sidreGroup() [2/2]

const axom::sidre::Group* axom::inlet::Container::sidreGroup ( ) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ addStruct()

Container& axom::inlet::Container::addStruct ( const std::string &  name,
const std::string &  description = "" 
)

Add a structure to the input file schema.

Adds a structure/record to the input file schema. Structures can contain fields and/or substructures. By default, it is not required unless marked with Container::isRequired(). This creates the Sidre Group class with the given name and stores the given description.

Parameters
[in]nameName of the struct expected in the input file
[in]descriptionDescription of the struct
Returns
Reference to the created struct, as a Container

◆ addBoolArray()

Verifiable<Container>& axom::inlet::Container::addBoolArray ( const std::string &  name,
const std::string &  description = "" 
)

Add an array of Boolean Fields to the input file schema.

Parameters
[in]nameName of the array
[in]descriptionDescription of the Field
Returns
Reference to the created array

◆ addIntArray()

Verifiable<Container>& axom::inlet::Container::addIntArray ( const std::string &  name,
const std::string &  description = "" 
)

Add an array of Integer Fields to the input file schema.

Parameters
[in]nameName of the array
[in]descriptionDescription of the Field
Returns
Reference to the created array

◆ addDoubleArray()

Verifiable<Container>& axom::inlet::Container::addDoubleArray ( const std::string &  name,
const std::string &  description = "" 
)

Add an array of Double Fields to the input file schema.

Parameters
[in]nameName of the array
[in]descriptionDescription of the Field
Returns
Reference to the created array

◆ addStringArray()

Verifiable<Container>& axom::inlet::Container::addStringArray ( const std::string &  name,
const std::string &  description = "" 
)

Add an array of String Fields to the input file schema.

Parameters
[in]nameName of the array
[in]descriptionDescription of the Field
Returns
Reference to the created array

◆ addStructArray()

Container& axom::inlet::Container::addStructArray ( const std::string &  name,
const std::string &  description = "" 
)

Add an array of Fields to the input file schema.

Parameters
[in]nameName of the array
[in]descriptionDescription of the Field
Returns
Reference to the created array

◆ addBoolDictionary()

Verifiable<Container>& axom::inlet::Container::addBoolDictionary ( const std::string &  name,
const std::string &  description = "" 
)

Add a dictionary of Boolean Fields to the input file schema.

Parameters
[in]nameName of the dict
[in]descriptionDescription of the Field
Returns
Reference to the created dictionary

◆ addIntDictionary()

Verifiable<Container>& axom::inlet::Container::addIntDictionary ( const std::string &  name,
const std::string &  description = "" 
)

Add a dictionary of Integer Fields to the input file schema.

Parameters
[in]nameName of the dict
[in]descriptionDescription of the dictionary
Returns
Reference to the created dictionary

◆ addDoubleDictionary()

Verifiable<Container>& axom::inlet::Container::addDoubleDictionary ( const std::string &  name,
const std::string &  description = "" 
)

Add a dictionary of Double Fields to the input file schema.

Parameters
[in]nameName of the dict
[in]descriptionDescription of the dictionary
Returns
Reference to the created dictionary

◆ addStringDictionary()

Verifiable<Container>& axom::inlet::Container::addStringDictionary ( const std::string &  name,
const std::string &  description = "" 
)

Add a dictionary of String Fields to the input file schema.

Parameters
[in]nameName of the dict
[in]descriptionDescription of the dictionary
Returns
Reference to the created dictionary

◆ addStructDictionary()

Container& axom::inlet::Container::addStructDictionary ( const std::string &  name,
const std::string &  description = "" 
)

Add a dictionary of user-defined types to the input file schema.

Parameters
[in]nameName of the dict
[in]descriptionDescription of the dictionary
Returns
Reference to the created dictionary

◆ addBool()

VerifiableScalar& axom::inlet::Container::addBool ( const std::string &  name,
const std::string &  description = "" 
)

Add a Boolean Field to the input file schema.

Adds a Boolean Field to the input file schema. It may or may not be required to be present in the input file. This creates the Sidre Group class with the given name and stores the given description. If present in the input file the value is read and stored in the datastore.

Parameters
[in]nameName of the Field expected in the input file
[in]descriptionDescription of the Field
Returns
Reference to the created Field

◆ addDouble()

VerifiableScalar& axom::inlet::Container::addDouble ( const std::string &  name,
const std::string &  description = "" 
)

Add a Double Field to the input file schema.

Adds a Double Field to the input file schema. It may or may not be required to be present in the input file. This creates the Sidre Group class with the given name and stores the given description. If present in the input file the value is read and stored in the datastore.

Parameters
[in]nameName of the Field expected in the input file
[in]descriptionDescription of the Field
Returns
Reference to the created Field

◆ addInt()

VerifiableScalar& axom::inlet::Container::addInt ( const std::string &  name,
const std::string &  description = "" 
)

Add a Integer Field to the input file schema.

Adds a Integer Field to the input file schema. It may or may not be required to be present in the input file. This creates the Sidre Group class with the given name and stores the given description. If present in the input file the value is read and stored in the datastore.

Parameters
[in]nameName of the Field expected in the input file
[in]descriptionDescription of the Field
Returns
Reference to the created Field

◆ addString()

VerifiableScalar& axom::inlet::Container::addString ( const std::string &  name,
const std::string &  description = "" 
)

Add a String Field to the input file schema.

Adds a String Field to the input file schema. It may or may not be required to be present in the input file. This creates the Sidre Group class with the given name and stores the given description. If present in the input file the value is read and stored in the datastore.

Parameters
[in]nameName of the Container expected in the input file
[in]descriptionDescription of the Container
Returns
Reference to the created Field

◆ addFunction()

Verifiable<Function>& axom::inlet::Container::addFunction ( const std::string &  name,
const FunctionTag  ret_type,
const std::vector< FunctionTag > &  arg_types,
const std::string &  description = "",
const std::string &  pathOverride = "" 
)

Get a function from the input deck.

Parameters
[in]nameName of the function
[in]ret_typeThe return type of the function
[in]arg_typesThe argument types of the function
[in]descriptionDescription of the function
[in]pathOverrideThe path within the input file to read from, if different than the structure of the Sidre datastore
Returns
Reference to the created Function

◆ get() [1/4]

template<typename T >
std::enable_if<detail::is_inlet_primitive<T>::value, T>::type axom::inlet::Container::get ( const std::string &  name) const
inline

Returns a stored value of primitive type.

Retrieves a value of primitive type.

Parameters
[in]nameName of the Field value to be gotten
Returns
The retrieved value
Template Parameters
TThe primitive type

References axom::inlet::Field::get(), name(), and SLIC_ERROR.

◆ get() [2/4]

template<typename T >
std::enable_if< !detail::is_inlet_primitive<T>::value && !detail::is_inlet_array<T>::value && !detail::is_inlet_dict<T>::value && !detail::is_std_vector<T>::value, T>::type axom::inlet::Container::get ( const std::string &  name = "") const
inline

Returns a stored value of user-defined type.

Retrieves a value of user-defined type.

Parameters
[in]nameThe name of the subcontainer representing the root of the object If nothing is passed, the calling container is interpreted as the roof of the object
Returns
The retrieved value
Precondition
Requires a specialization of FromInlet for T
Template Parameters
TThe user-defined type

References name(), and SLIC_ERROR.

◆ get() [3/4]

template<typename T >
std::enable_if<detail::is_inlet_array<T>::value || detail::is_inlet_dict<T>::value, T>::type axom::inlet::Container::get ( ) const
inline

Returns a stored collection.

Retrieves a collection of user-defined type.

Returns
The retrieved collection
Template Parameters
TThe collection type, i.e., T = std::unordered_map<K, V>

References axom::inlet::detail::COLLECTION_GROUP_NAME, and axom::inlet::isCollectionGroup().

◆ get() [4/4]

template<typename T >
std::enable_if<detail::is_std_vector<T>::value, T>::type axom::inlet::Container::get ( ) const
inline

Returns a stored collection as a contiguous array.

Retrieves a collection of user-defined type.

Returns
The values in the retrieved collection
Template Parameters
TThe collection type, i.e., T = std::vector<V>
Note
Elements in the returned array will be in ascending order by index, regardless of index contiguity or base index

◆ operator[]()

Proxy axom::inlet::Container::operator[] ( const std::string &  name) const

Obtains a proxy view into the container for either a Field/Container subobject.

Returns a reference via a lightweight proxy object to the element in the datastore at the index specified by the name. This can be a field or a container.

Parameters
[in]nameThe name of the subobject
Returns
The retrieved array

◆ required()

Container& axom::inlet::Container::required ( bool  isRequired = true)
overridevirtual

Set the required status of this object.

Set whether this object is required, or not, to be in the input file. The default behavior is to not be required.

Parameters
[in]isRequiredBoolean value of whether object is required
Returns
Reference to calling object, for chaining

Implements axom::inlet::Verifiable< Container >.

◆ isRequired()

bool axom::inlet::Container::isRequired ( ) const
overridevirtual

Return the required status.

Return that this object is required, or not, to be in the input file. The default behavior is to not be required.

Returns
Boolean value of whether this object is required

Implements axom::inlet::Verifiable< Container >.

◆ registerVerifier() [1/2]

Container& axom::inlet::Container::registerVerifier ( Verifier  verifier)
overridevirtual

Registers the function object that will verify this object's contents during the verification stage.

Parameters
[in]verifierThe function which will verify the contents of the container.

Implements axom::inlet::Verifiable< Container >.

◆ verify()

bool axom::inlet::Container::verify ( std::vector< VerificationError > *  errors = nullptr) const
overridevirtual

Verifies the object to make sure it satisfies the imposed requirements.

Parameters
[in]errorsAn optional vector of errors to append to in the case of verification failure

Ownership is not taken of errors, the raw pointer is only used for its optional reference semantics, as opposed to something like std::optional<std::reference_wrapper<T>>

Implements axom::inlet::Verifiable< Container >.

◆ strict()

Container& axom::inlet::Container::strict ( bool  isStrict = true)

Set the strictness of this Container.

Set whether this Container is strict, or not - i.e., whether entries other than those added to the schema should be allowed. The default behavior is to not be strict.

Parameters
[in]isStrictBoolean value of whether Container is strict
Returns
Reference to this instance of Container

◆ contains()

bool axom::inlet::Container::contains ( const std::string &  name) const

Return whether a Container or Field with the given name is present in this Container's subtree.

Returns
Boolean value indicating whether this Container's subtree contains a Field or Container with the given name.

◆ exists()

bool axom::inlet::Container::exists ( ) const

Returns whether this container or any of its subcontainers exist, i.e., if they contain a Field or Function that exists.

◆ isUserProvided() [1/2]

bool axom::inlet::Container::isUserProvided ( ) const

Returns whether this container or any of its subcontainers were provided in the input file, i.e., if they contain a Field or Function that was provided in the input file.

◆ isUserProvided() [2/2]

bool axom::inlet::Container::isUserProvided ( const std::string &  name) const

Return whether a Container or Field with the given name were provided in the input file.

Parameters
[in]nameThe path relative to the calling Container to search

◆ getChildFields()

const std::unordered_map<std::string, std::unique_ptr<Field> >& axom::inlet::Container::getChildFields ( ) const
Returns
An unordered map from Field names to the child Field pointers for this Container.

◆ getChildContainers()

const std::unordered_map<std::string, std::unique_ptr<Container> >& axom::inlet::Container::getChildContainers ( ) const
Returns
An unordered map from Container names to the child Container pointers for this Container.

◆ getChildFunctions()

const std::unordered_map<std::string, std::unique_ptr<Function> >& axom::inlet::Container::getChildFunctions ( ) const
Returns
An unordered map from Function names to the child Function pointers for this Container.

◆ name()

std::string axom::inlet::Container::name ( ) const
Returns
The full name of this Container.

◆ unexpectedNames()

std::vector<std::string> axom::inlet::Container::unexpectedNames ( ) const

Returns the list of unexpected names "below" the calling container, i.e., entries in the input file structure (e.g., a Lua table or YAML dictionary) corresponding to the calling container that were not requested/retrieved via an add* call.

◆ addPrimitive()

template<typename T , typename SFINAE = typename std::enable_if<detail::is_inlet_primitive<T>::value>::type>
VerifiableScalar& axom::inlet::Container::addPrimitive ( const std::string &  name,
const std::string &  description = "",
bool  forArray = false,
val = T {},
const std::string &  pathOverride = "" 
)

Add a Field to the input file schema.

Adds a primitive Field to the input file schema. It may or may not be required to be present in the input file. This creates the Sidre Group class with the given name and stores the given description. If present in the input file the value is read and stored in the datastore.

Parameters
[in]nameName of the Container expected in the input file
[in]descriptionDescription of the Container
[in]forArrayWhether the primitive is in an array, in which case the provided value should be inserted instead of the one read from the input file
[in]valA provided value, will be overwritten if found at specified path in input file
[in]pathOverrideThe path within the input file to read from, if different than the structure of the Sidre datastore
Returns
Reference to the created Field

◆ registerVerifier() [2/2]

Verifiable<Container >& axom::inlet::Verifiable< Container >::registerVerifier ( std::function< bool(const Container &)>  verifier)
inlineinherited

Registers the function object that will verify this object's contents during the verification stage.

Parameters
[in]verifierThe function object.

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