AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
|
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>
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::Group * | sidreGroup () |
Returns pointer to the Sidre Group class for this Container. More... | |
const axom::sidre::Group * | sidreGroup () const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
Container & | addStruct (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... | |
Container & | addStructArray (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... | |
Container & | addStructDictionary (const std::string &name, const std::string &description="") |
Add a dictionary of user-defined types to the input file schema. More... | |
VerifiableScalar & | addBool (const std::string &name, const std::string &description="") |
Add a Boolean Field to the input file schema. More... | |
VerifiableScalar & | addDouble (const std::string &name, const std::string &description="") |
Add a Double Field to the input file schema. More... | |
VerifiableScalar & | addInt (const std::string &name, const std::string &description="") |
Add a Integer Field to the input file schema. More... | |
VerifiableScalar & | addString (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... | |
Container & | required (bool isRequired=true) override |
Set the required status of this object. More... | |
bool | isRequired () const override |
Return the required status. More... | |
Container & | registerVerifier (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... | |
Container & | strict (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> | |
VerifiableScalar & | addPrimitive (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... | |
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.
|
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.
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.
[in] | name | Name of the Container expected in the input file |
[in] | description | Description of the Container |
[in] | reader | Reference to the input file Reader class. |
[in] | sidreRootGroup | Pointer to the already created Sidre Group. |
[in] | unexpectedNames | Reference to the global (relative to the Inlet hierarchy) list of unexpected names |
[in] | docEnabled | Boolean indicating whether or not documentation generation is enabled for input feck this Container instance belongs to. |
[in] | reconstruct | Whether or not to attempt to reconstruct child Containers and Fields from the data in the sidre Group |
|
delete |
|
default |
|
virtualdefault |
|
inline |
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
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.
[in] | name | Name of the struct expected in the input file |
[in] | description | Description of the struct |
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.
[in] | name | Name of the array |
[in] | description | Description of the Field |
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.
[in] | name | Name of the array |
[in] | description | Description of the Field |
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.
[in] | name | Name of the array |
[in] | description | Description of the Field |
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.
[in] | name | Name of the array |
[in] | description | Description of the Field |
Container& axom::inlet::Container::addStructArray | ( | const std::string & | name, |
const std::string & | description = "" |
||
) |
Add an array of Fields to the input file schema.
[in] | name | Name of the array |
[in] | description | Description of the Field |
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.
[in] | name | Name of the dict |
[in] | description | Description of the Field |
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.
[in] | name | Name of the dict |
[in] | description | Description of the dictionary |
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.
[in] | name | Name of the dict |
[in] | description | Description of the dictionary |
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.
[in] | name | Name of the dict |
[in] | description | Description of the dictionary |
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.
[in] | name | Name of the dict |
[in] | description | Description of the dictionary |
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.
[in] | name | Name of the Field expected in the input file |
[in] | description | Description of the Field |
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.
[in] | name | Name of the Field expected in the input file |
[in] | description | Description of the Field |
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.
[in] | name | Name of the Field expected in the input file |
[in] | description | Description of the Field |
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.
[in] | name | Name of the Container expected in the input file |
[in] | description | Description of the Container |
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.
[in] | name | Name of the function |
[in] | ret_type | The return type of the function |
[in] | arg_types | The argument types of the function |
[in] | description | Description of the function |
[in] | pathOverride | The path within the input file to read from, if different than the structure of the Sidre datastore |
|
inline |
Returns a stored value of primitive type.
Retrieves a value of primitive type.
[in] | name | Name of the Field value to be gotten |
T | The primitive type |
References axom::inlet::Field::get(), name(), and SLIC_ERROR.
|
inline |
Returns a stored value of user-defined type.
Retrieves a value of user-defined type.
[in] | name | The 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 |
T | The user-defined type |
References name(), and SLIC_ERROR.
|
inline |
Returns a stored collection.
Retrieves a collection of user-defined type.
T | The collection type, i.e., T = std::unordered_map<K, V> |
References axom::inlet::detail::COLLECTION_GROUP_NAME, and axom::inlet::isCollectionGroup().
|
inline |
Returns a stored collection as a contiguous array.
Retrieves a collection of user-defined type.
T | The collection type, i.e., T = std::vector<V> |
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.
[in] | name | The name of the subobject |
|
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.
[in] | isRequired | Boolean value of whether object is required |
Implements axom::inlet::Verifiable< Container >.
|
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.
Implements axom::inlet::Verifiable< Container >.
Registers the function object that will verify this object's contents during the verification stage.
[in] | verifier | The function which will verify the contents of the container. |
Implements axom::inlet::Verifiable< Container >.
|
overridevirtual |
Verifies the object to make sure it satisfies the imposed requirements.
[in] | errors | An 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 >.
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.
[in] | isStrict | Boolean value of whether Container is strict |
bool axom::inlet::Container::contains | ( | const std::string & | name | ) | const |
bool axom::inlet::Container::exists | ( | ) | const |
bool axom::inlet::Container::isUserProvided | ( | ) | const |
bool axom::inlet::Container::isUserProvided | ( | const std::string & | name | ) | const |
const std::unordered_map<std::string, std::unique_ptr<Field> >& axom::inlet::Container::getChildFields | ( | ) | const |
const std::unordered_map<std::string, std::unique_ptr<Container> >& axom::inlet::Container::getChildContainers | ( | ) | const |
const std::unordered_map<std::string, std::unique_ptr<Function> >& axom::inlet::Container::getChildFunctions | ( | ) | const |
std::string axom::inlet::Container::name | ( | ) | const |
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.
VerifiableScalar& axom::inlet::Container::addPrimitive | ( | 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.
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.
[in] | name | Name of the Container expected in the input file |
[in] | description | Description of the Container |
[in] | forArray | Whether 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] | val | A provided value, will be overwritten if found at specified path in input file |
[in] | pathOverride | The path within the input file to read from, if different than the structure of the Sidre datastore |
|
inlineinherited |
Registers the function object that will verify this object's contents during the verification stage.
[in] | verifier | The function object. |