Advanced Multi-Physics (AMP)
On-Line Documentation
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
AMP::Database Class Referencefinal

Class to a database. More...

#include <Database.h>

Inheritance diagram for AMP::Database:
Inheritance graph
[legend]

Classes

struct  IdentityTypeStruct
 

Public Types

enum class  Check : uint8_t {
  Overwrite , Keep , WarnOverwrite , WarnKeep ,
  Error , GetDatabaseDefault
}
 enum to control behavior when trying to add existing keys More...
 
template<typename T >
using IdentityType = typename IdentityTypeStruct< const T & >::type
 
using source_location = StackTrace::source_location
 

Public Member Functions

void clear ()
 
std::unique_ptr< KeyDataclone () const override
 Copy the data.
 
std::unique_ptr< DatabasecloneDatabase () const
 Copy the data.
 
double convertUnits (const Units &, std::string_view="") const
 Return the conversion factor (if used)
 
void copy (const Database &rhs)
 Copy the data.
 
std::shared_ptr< DatabasecreateAddDatabase (std::string_view key)
 
 Database ()
 Empty constructor.
 
 Database (const Database &)
 Copy constructor.
 
 Database (Database &&rhs)
 Move constructor.
 
 Database (std::string name)
 Basic constructor.
 
void deleteData (std::string_view key)
 
size_t empty () const
 Return true if the database is empty.
 
void erase (std::string_view key, bool check=true)
 
std::vector< std::string > getAllKeys (bool sort=true) const
 Return all keys in the database.
 
template<class TYPE >
Array< TYPE > getArray (const Units &unit={}, std::string_view name="", source_location src=source_location::current()) const
 Convert the data to a scalar of the given type.
 
template<class TYPE >
Array< TYPE > getArray (std::string_view key, const Units &unit=Units(), source_location src=source_location::current()) const
 
typeID getClassType () const override
 Return class type.
 
KeyDatagetData (std::string_view key)
 
const KeyDatagetData (std::string_view key) const
 
std::shared_ptr< DatabasegetDatabase (std::string_view key, source_location src=source_location::current())
 
std::shared_ptr< const DatabasegetDatabase (std::string_view key, source_location src=source_location::current()) const
 
typeID getDataType () const override
 Print the type.
 
typeID getDataType (std::string_view key) const
 Get the fundamental type (e.g. double, int, float, ...)
 
Check getDefaultAddKeyBehavior () const
 Get the default behavior when adding keys.
 
std::unique_ptr< MathExprgetEquation (std::string_view key, const Units &unit=Units(), source_location src=source_location::current()) const
 
const std::string & getName () const
 Get the name of the database.
 
template<class TYPE >
TYPE getScalar (const Units &unit={}, std::string_view name="", source_location src=source_location::current()) const
 Convert the data to a scalar of the given type.
 
template<class TYPE >
TYPE getScalar (std::string_view key, const Units &unit=Units(), source_location src=source_location::current()) const
 
std::string getString (std::string_view key, source_location src=source_location::current()) const
 
std::vector< std::string > getUnused (bool recursive=true) const
 
template<class TYPE >
std::vector< TYPE > getVector (std::string_view key, const Units &unit=Units(), source_location src=source_location::current()) const
 
template<class TYPE >
TYPE getWithDefault (std::string_view key, IdentityType< const TYPE & > value, const Units &unit=Units(), source_location src=source_location::current()) const
 
bool isDatabase (std::string_view key, source_location src=source_location::current()) const
 Check if the key is a database object.
 
bool isEquation (std::string_view key, source_location src=source_location::current()) const
 
bool isString (std::string_view key, source_location src=source_location::current()) const
 Check if the named entry is a string.
 
template<class TYPE >
bool isType () const
 
template<class TYPE >
bool isType (std::string_view key, source_location src=source_location::current()) const
 Check if the entry can be stored as the given type.
 
bool keyExists (std::string_view key) const
 
bool operator!= (const Database &rhs) const
 Return the number of entries in the database.
 
bool operator!= (const KeyData &rhs) const
 Check if two sets of data are not equal.
 
const Databaseoperator() (std::string_view key, source_location src=source_location::current()) const
 
Databaseoperator= (const Database &)
 Assignment operator.
 
Databaseoperator= (Database &&rhs)
 Move assignment operator.
 
bool operator== (const Database &rhs) const
 Return true if the databases are equivalent.
 
bool operator== (const KeyData &rhs) const override
 Return true if the databases are equivalent.
 
size_t pack (std::byte *) const override
 Pack the data to a buffer.
 
size_t packSize () const override
 Return the number of bytes required to pack the data.
 
void print (std::ostream &os, std::string_view indent="", bool sort=true, bool printType=false) const override
 
std::string print (std::string_view indent="", bool sort=true, bool printType=false) const
 
template<class TYPE >
void putArray (std::string_view key, Array< TYPE > data, Units unit=Units(), Check check=Check::GetDatabaseDefault, source_location src=source_location::current())
 
void putData (std::string_view key, std::unique_ptr< KeyData > data, Check check=Check::GetDatabaseDefault, source_location src=source_location::current())
 
std::shared_ptr< DatabaseputDatabase (std::string_view key)
 
void putDatabase (std::string_view key, std::unique_ptr< Database > db)
 
template<class TYPE >
void putScalar (std::string_view key, TYPE value, Units unit=Units(), Check check=Check::GetDatabaseDefault, source_location src=source_location::current())
 
template<class TYPE >
void putVector (std::string_view key, const std::vector< TYPE > &data, Units unit=Units(), Check check=Check::GetDatabaseDefault, source_location src=source_location::current())
 
void readDatabase (const std::string &filename, source_location src=source_location::current())
 
void readHDF5 (int64_t fid, const std::string &name) override
 Read the data from HDF5.
 
void setDefaultAddKeyBehavior (Check check, bool setChildren)
 Set the default behavior when adding keys.
 
void setName (std::string name)
 Get the name of the database.
 
size_t size () const
 Return the number of entries in the database.
 
const Unitsunit () const
 Return the units.
 
size_t unpack (const std::byte *) override
 Unpack the data from a buffer.
 
void writeHDF5 (int64_t fid, const std::string &name) const override
 Write the data to HDF5.
 
virtual ~Database ()=default
 Destructor.
 

Static Public Member Functions

template<class... Args>
static std::unique_ptr< Databasecreate (Args... args)
 Create a database from key/value pairs.
 
static std::unique_ptr< DatabasecreateFromString (std::string_view data)
 
template<class... Args>
static std::unique_ptr< DatabasecreateWithUnits (Args... args)
 Create a database from key/value/unit triplets.
 
static std::shared_ptr< DatabaseparseInputFile (const std::string &filename)
 
static std::unique_ptr< KeyDatareadYAML (std::string_view filename, source_location src=source_location::current())
 

Protected Member Functions

template<class TYPE , class... Args>
void addArgs (std::string_view key, TYPE value, Args... args)
 
template<class TYPE , class... Args>
void addArgsWithUnits (std::string_view key, TYPE value, const Units &unit, Args... args)
 
ArraySize arraySize () const override
 Return the array size.
 
Array< double > convertToDouble () const override
 Return the data as a Array<double> (throw error if this is not valid)
 
Array< int64_t > convertToInt64 () const override
 Return the data as a Array<int64_t> (throw error if this is not valid)
 
int find (uint32_t hash, bool use) const
 
bool is_floating_point () const override
 Return true if the type is a floating point type.
 
bool is_integral () const override
 Return true if the type is a integer point type.
 

Static Protected Member Functions

static uint32_t hashString (std::string_view s)
 

Protected Attributes

Check d_check
 
std::vector< std::shared_ptr< KeyData > > d_data
 
std::vector< uint32_t > d_hash
 
std::vector< std::string > d_keys
 
std::string d_name
 
Units d_unit
 
std::vector< bool > d_used
 

Detailed Description

Class to a database.

Definition at line 110 of file Database.h.

Member Typedef Documentation

◆ IdentityType

template<typename T >
using AMP::Database::IdentityType = typename IdentityTypeStruct<const T &>::type

Definition at line 128 of file Database.h.

◆ source_location

using AMP::KeyData::source_location = StackTrace::source_location
inherited

Definition at line 39 of file Database.h.

Member Enumeration Documentation

◆ Check

enum class AMP::Database::Check : uint8_t
strong

enum to control behavior when trying to add existing keys

Enumerator
Overwrite 

Overwrite the data.

Keep 

Keep the existing data.

WarnOverwrite 

Overwrite the data but print a warning (default)

WarnKeep 

Keep the existing data but print a warning.

Error 

Throw an error.

GetDatabaseDefault 

Definition at line 114 of file Database.h.

Constructor & Destructor Documentation

◆ Database() [1/4]

AMP::Database::Database ( )

Empty constructor.

◆ Database() [2/4]

AMP::Database::Database ( std::string  name)
explicit

Basic constructor.

◆ Database() [3/4]

AMP::Database::Database ( const Database )

Copy constructor.

◆ Database() [4/4]

AMP::Database::Database ( Database &&  rhs)

Move constructor.

◆ ~Database()

virtual AMP::Database::~Database ( )
virtualdefault

Destructor.

Member Function Documentation

◆ addArgs()

template<class TYPE , class... Args>
void AMP::Database::addArgs ( std::string_view  key,
TYPE  value,
Args...  args 
)
inlineprotected

Definition at line 732 of file Database.h.

References addArgs(), putArray(), putScalar(), and putVector().

Referenced by addArgs().

◆ addArgsWithUnits()

template<class TYPE , class... Args>
void AMP::Database::addArgsWithUnits ( std::string_view  key,
TYPE  value,
const Units unit,
Args...  args 
)
inlineprotected

Definition at line 754 of file Database.h.

References addArgsWithUnits(), putArray(), putScalar(), putVector(), and AMP::KeyData::unit().

Referenced by addArgsWithUnits().

◆ arraySize()

ArraySize AMP::Database::arraySize ( ) const
inlineoverrideprotectedvirtual

Return the array size.

Implements AMP::KeyData.

Definition at line 658 of file Database.h.

◆ clear()

void AMP::Database::clear ( )

Clear all keys from the database

◆ clone()

std::unique_ptr< KeyData > AMP::Database::clone ( ) const
overridevirtual

Copy the data.

Implements AMP::KeyData.

◆ cloneDatabase()

std::unique_ptr< Database > AMP::Database::cloneDatabase ( ) const

Copy the data.

◆ convertToDouble()

Array< double > AMP::Database::convertToDouble ( ) const
overrideprotectedvirtual

Return the data as a Array<double> (throw error if this is not valid)

Implements AMP::KeyData.

◆ convertToInt64()

Array< int64_t > AMP::Database::convertToInt64 ( ) const
overrideprotectedvirtual

Return the data as a Array<int64_t> (throw error if this is not valid)

Implements AMP::KeyData.

◆ convertUnits()

double AMP::KeyData::convertUnits ( const Units ,
std::string_view  = "" 
) const
inherited

Return the conversion factor (if used)

◆ copy()

void AMP::Database::copy ( const Database rhs)

Copy the data.

◆ create()

template<class... Args>
std::unique_ptr< Database > AMP::Database::create ( Args...  args)
inlinestatic

Create a database from key/value pairs.

This function will create a database from a set of key/value pairs of the form: create( "key1", value1, "key2", value2, ... ). Note that for simplicity each value must either be a scalar value (int, double, string, etc) or a std::vector/Array of scalar values

Parameters
[in]argsThe input arguments

Definition at line 775 of file Database.h.

◆ createAddDatabase()

std::shared_ptr< Database > AMP::Database::createAddDatabase ( std::string_view  key)
inline

Create a new empty database in the current database and return a pointer. If the specified key already exists in the database an error is thrown. This is equivalent to:

auto tmp = std::make_unique<Database>( key );
this->putDatabase( key, std::move( tmp ) );
return this->getDatabase( key );
void putDatabase(std::string_view key, std::unique_ptr< Database > db)
Definition Database.h:509
std::shared_ptr< Database > getDatabase(std::string_view key, source_location src=source_location::current())
Parameters
keyKey name in database.

Definition at line 527 of file Database.h.

References getDatabase(), and putDatabase().

◆ createFromString()

static std::unique_ptr< Database > AMP::Database::createFromString ( std::string_view  data)
static

Create database from string

Parameters
dataString containing the database data

◆ createWithUnits()

template<class... Args>
std::unique_ptr< Database > AMP::Database::createWithUnits ( Args...  args)
inlinestatic

Create a database from key/value/unit triplets.

This function will create a database from a set of key/value/unit triplets of the form: create( "key1", value1, unit1, "key2", value2, unit2, ... ). Note that for simplicity each value must either be a scalar value (int, double, string, etc) or a std::vector/Array of scalar values

Parameters
[in]argsThe input arguments

Definition at line 786 of file Database.h.

◆ deleteData()

void AMP::Database::deleteData ( std::string_view  key)

Delete the key if it exists

Parameters
[in]keyKey name to delete.

◆ empty()

size_t AMP::Database::empty ( ) const
inline

Return true if the database is empty.

Definition at line 251 of file Database.h.

References d_data.

◆ erase()

void AMP::Database::erase ( std::string_view  key,
bool  check = true 
)

Erase the given key If the specified key does not exists and check is true, an error is thrown.

Parameters
keyKey name in database
checkCheck if the key exists

◆ find()

int AMP::Database::find ( uint32_t  hash,
bool  use 
) const
inlineprotected

Definition at line 643 of file Database.h.

References d_hash, and d_used.

◆ getAllKeys()

std::vector< std::string > AMP::Database::getAllKeys ( bool  sort = true) const

Return all keys in the database.

This function will return the list of the keys available. The user may specify if they want the keys to be returned in sorted order.

Parameters
[in]sortSort the keys (default is true)

◆ getArray() [1/2]

template<class TYPE >
Array< TYPE > AMP::KeyData::getArray ( const Units unit = {},
std::string_view  name = "",
source_location  src = source_location::current() 
) const
inherited

Convert the data to a scalar of the given type.

◆ getArray() [2/2]

template<class TYPE >
Array< TYPE > AMP::Database::getArray ( std::string_view  key,
const Units unit = Units(),
source_location  src = source_location::current() 
) const

Get the vector entries from the database with the specified key name. If the specified key does not exist in the database or is not of the given type, then an error message is printed and the program exits.

Parameters
[in]keyKey name in database.
[in]unitDesired units
[in]srcSource location in case of error

◆ getClassType()

typeID AMP::Database::getClassType ( ) const
inlineoverridevirtual

Return class type.

Implements AMP::KeyData.

Definition at line 197 of file Database.h.

◆ getData() [1/2]

KeyData * AMP::Database::getData ( std::string_view  key)

Get a raw pointer to the data for a key in the database. If the specified key does not exist, a null pointer is returned.

Parameters
keyKey name in database.

◆ getData() [2/2]

const KeyData * AMP::Database::getData ( std::string_view  key) const

Get a raw pointer to the data for a key in the database. If the specified key does not exist, a null pointer is returned.

Parameters
keyKey name in database.

◆ getDatabase() [1/2]

std::shared_ptr< Database > AMP::Database::getDatabase ( std::string_view  key,
source_location  src = source_location::current() 
)

Get a raw pointer to the database for a key in the database. If the specified key does not exist, a null pointer is returned.

Parameters
[in]keyKey name in database
[in]srcSource location in case of error

Referenced by createAddDatabase(), and putDatabase().

◆ getDatabase() [2/2]

std::shared_ptr< const Database > AMP::Database::getDatabase ( std::string_view  key,
source_location  src = source_location::current() 
) const

Get a raw pointer to the database for a key in the database. If the specified key does not exist, a null pointer is returned.

Parameters
[in]keyKey name in database
[in]srcSource location in case of error

◆ getDataType() [1/2]

typeID AMP::Database::getDataType ( ) const
inlineoverridevirtual

Print the type.

Implements AMP::KeyData.

Definition at line 577 of file Database.h.

◆ getDataType() [2/2]

typeID AMP::Database::getDataType ( std::string_view  key) const

Get the fundamental type (e.g. double, int, float, ...)

◆ getDefaultAddKeyBehavior()

Check AMP::Database::getDefaultAddKeyBehavior ( ) const
inline

Get the default behavior when adding keys.

Definition at line 200 of file Database.h.

References d_check.

◆ getEquation()

std::unique_ptr< MathExpr > AMP::Database::getEquation ( std::string_view  key,
const Units unit = Units(),
source_location  src = source_location::current() 
) const

Return an equation for the key Note: scalar values can be represented as an equation and will return a new scalar equation

Parameters
[in]keyKey name in database
[in]unitDesired units
[in]srcSource location in case of error

◆ getName()

const std::string & AMP::Database::getName ( ) const
inline

Get the name of the database.

Definition at line 221 of file Database.h.

References d_name.

◆ getScalar() [1/2]

template<class TYPE >
TYPE AMP::KeyData::getScalar ( const Units unit = {},
std::string_view  name = "",
source_location  src = source_location::current() 
) const
inherited

Convert the data to a scalar of the given type.

◆ getScalar() [2/2]

template<class TYPE >
TYPE AMP::Database::getScalar ( std::string_view  key,
const Units unit = Units(),
source_location  src = source_location::current() 
) const

Get the scalar entry from the database with the specified key name. If the specified key does not exist in the database or is not a scalar of the given type, then an error message is printed and the program exits.

Parameters
[in]keyKey name in database.
[in]unitDesired units
[in]srcSource location in case of error

◆ getString()

std::string AMP::Database::getString ( std::string_view  key,
source_location  src = source_location::current() 
) const
inline

Get the key as a string

Parameters
[in]keyKey name in database.
[in]srcSource location in case of error

Definition at line 275 of file Database.h.

◆ getUnused()

std::vector< std::string > AMP::Database::getUnused ( bool  recursive = true) const

Get unused entries

Parameters
recursiveCheck sub databases (pre-pending by DatabaseName::)
Returns
Output string

◆ getVector()

template<class TYPE >
std::vector< TYPE > AMP::Database::getVector ( std::string_view  key,
const Units unit = Units(),
source_location  src = source_location::current() 
) const

Get the vector entries from the database with the specified key name. If the specified key does not exist in the database or is not of the given type, then an error message is printed and the program exits.

Parameters
[in]keyKey name in database.
[in]unitDesired units
[in]srcSource location in case of error

◆ getWithDefault()

template<class TYPE >
TYPE AMP::Database::getWithDefault ( std::string_view  key,
IdentityType< const TYPE & >  value,
const Units unit = Units(),
source_location  src = source_location::current() 
) const

Get the scalar entry from the database with the specified key name. If the specified key does not exist in the database the the default value will be printed

Parameters
[in]keyKey name in database
[in]valueDefault value
[in]unitDesired units
[in]srcSource location in case of error

◆ hashString()

static uint32_t AMP::Database::hashString ( std::string_view  s)
inlinestaticprotected

Definition at line 637 of file Database.h.

◆ is_floating_point()

bool AMP::Database::is_floating_point ( ) const
overrideprotectedvirtual

Return true if the type is a floating point type.

Implements AMP::KeyData.

◆ is_integral()

bool AMP::Database::is_integral ( ) const
overrideprotectedvirtual

Return true if the type is a integer point type.

Implements AMP::KeyData.

◆ isDatabase()

bool AMP::Database::isDatabase ( std::string_view  key,
source_location  src = source_location::current() 
) const

Check if the key is a database object.

◆ isEquation()

bool AMP::Database::isEquation ( std::string_view  key,
source_location  src = source_location::current() 
) const

Check if the named entry is an equation Note: scalar values can be represented as an equation and will return true

Parameters
[in]keyKey name in database
[in]srcSource location in case of error

◆ isString()

bool AMP::Database::isString ( std::string_view  key,
source_location  src = source_location::current() 
) const

Check if the named entry is a string.

◆ isType() [1/2]

template<class TYPE >
bool AMP::KeyData::isType ( ) const
inherited

◆ isType() [2/2]

template<class TYPE >
bool AMP::Database::isType ( std::string_view  key,
source_location  src = source_location::current() 
) const

Check if the entry can be stored as the given type.

◆ keyExists()

bool AMP::Database::keyExists ( std::string_view  key) const

Return true if the specified key exists in the database and false otherwise.

Parameters
[in]keyKey name to lookup.

◆ operator!=() [1/2]

bool AMP::Database::operator!= ( const Database rhs) const
inline

Return the number of entries in the database.

Definition at line 267 of file Database.h.

References operator==().

◆ operator!=() [2/2]

bool AMP::KeyData::operator!= ( const KeyData rhs) const
inlineinherited

Check if two sets of data are not equal.

Definition at line 69 of file Database.h.

References AMP::KeyData::operator==().

◆ operator()()

const Database & AMP::Database::operator() ( std::string_view  key,
source_location  src = source_location::current() 
) const

Access the database

Parameters
[in]keyKey name in database
[in]srcSource location in case of error

◆ operator=() [1/2]

Database & AMP::Database::operator= ( const Database )

Assignment operator.

◆ operator=() [2/2]

Database & AMP::Database::operator= ( Database &&  rhs)

Move assignment operator.

◆ operator==() [1/2]

bool AMP::Database::operator== ( const Database rhs) const

Return true if the databases are equivalent.

Referenced by operator!=().

◆ operator==() [2/2]

bool AMP::Database::operator== ( const KeyData rhs) const
overridevirtual

Return true if the databases are equivalent.

Implements AMP::KeyData.

◆ pack()

size_t AMP::Database::pack ( std::byte *  ) const
overridevirtual

Pack the data to a buffer.

Implements AMP::KeyData.

◆ packSize()

size_t AMP::Database::packSize ( ) const
overridevirtual

Return the number of bytes required to pack the data.

Implements AMP::KeyData.

◆ parseInputFile()

static std::shared_ptr< Database > AMP::Database::parseInputFile ( const std::string &  filename)
static

Open an database file.

Parameters
filenameName of input file to open

◆ print() [1/2]

void AMP::Database::print ( std::ostream &  os,
std::string_view  indent = "",
bool  sort = true,
bool  printType = false 
) const
overridevirtual

Print the data to a stream

Parameters
osOutput stream
indentIndenting to use before each line
sortSort the entries before printing
printTypePrint a comment with the stored datatype

Implements AMP::KeyData.

◆ print() [2/2]

std::string AMP::Database::print ( std::string_view  indent = "",
bool  sort = true,
bool  printType = false 
) const

Print the data to a string

Parameters
indentIndenting to use before each line
sortSort the entries before printing
printTypePrint a comment with the stored datatype
Returns
Output string

◆ putArray()

template<class TYPE >
void AMP::Database::putArray ( std::string_view  key,
Array< TYPE >  data,
Units  unit = Units(),
Check  check = Check::GetDatabaseDefault,
source_location  src = source_location::current() 
)

Put the vector entries into the database with the specified key name. If the specified key does not exist in the database or is not of the given type, then an error message is printed and the program exits.

Parameters
[in]keyKey name in database.
[in]dataData to store
[in]unitDesired units
[in]checkOptional value to indicate the behavior if the key exists
[in]srcSource location in case of error

Referenced by addArgs(), and addArgsWithUnits().

◆ putData()

void AMP::Database::putData ( std::string_view  key,
std::unique_ptr< KeyData data,
Check  check = Check::GetDatabaseDefault,
source_location  src = source_location::current() 
)

Put the data for a key in the database.

Parameters
[in]keyKey name in database.
[in]dataData to store
[in]checkOptional value to indicate the behavior if the key exists
[in]srcSource location in case of error

Referenced by putDatabase(), and putDatabase().

◆ putDatabase() [1/2]

std::shared_ptr< Database > AMP::Database::putDatabase ( std::string_view  key)
inline

Create a database and return it If the specified key already exists in the database an error is thrown.

Parameters
keyKey name in database.

Definition at line 540 of file Database.h.

References getDatabase(), and putData().

◆ putDatabase() [2/2]

void AMP::Database::putDatabase ( std::string_view  key,
std::unique_ptr< Database db 
)
inline

Put the database for a key in the database. If the specified key already exists in the database an error is thrown.

Parameters
keyKey name in database.
dbDatabase to store

Definition at line 509 of file Database.h.

References putData().

Referenced by createAddDatabase().

◆ putScalar()

template<class TYPE >
void AMP::Database::putScalar ( std::string_view  key,
TYPE  value,
Units  unit = Units(),
Check  check = Check::GetDatabaseDefault,
source_location  src = source_location::current() 
)

Put the scalar entry into the database with the specified key name.

Parameters
[in]keyKey name in database.
[in]valueValue to store
[in]unitDesired units
[in]checkOptional value to indicate the behavior if the key exists
[in]srcSource location in case of error

Referenced by addArgs(), and addArgsWithUnits().

◆ putVector()

template<class TYPE >
void AMP::Database::putVector ( std::string_view  key,
const std::vector< TYPE > &  data,
Units  unit = Units(),
Check  check = Check::GetDatabaseDefault,
source_location  src = source_location::current() 
)

Put the vector entries into the database with the specified key name. If the specified key does not exist in the database or is not of the given type, then an error message is printed and the program exits.

Parameters
[in]keyKey name in database.
[in]dataData to store
[in]unitDesired units
[in]checkOptional value to indicate the behavior if the key exists
[in]srcSource location in case of error

Referenced by addArgs(), and addArgsWithUnits().

◆ readDatabase()

void AMP::Database::readDatabase ( const std::string &  filename,
source_location  src = source_location::current() 
)

Open an database file

Parameters
filenameName of input file to open
[in]srcSource location in case of error

◆ readHDF5()

void AMP::Database::readHDF5 ( int64_t  fid,
const std::string &  name 
)
overridevirtual

Read the data from HDF5.

Implements AMP::KeyData.

◆ readYAML()

static std::unique_ptr< KeyData > AMP::Database::readYAML ( std::string_view  filename,
source_location  src = source_location::current() 
)
static

◆ setDefaultAddKeyBehavior()

void AMP::Database::setDefaultAddKeyBehavior ( Check  check,
bool  setChildren 
)

Set the default behavior when adding keys.

Set the default behavior when adding keys

This function will specify the default behavior when a user adds a key that is already in the database.

Parameters
[in]checkThe default behavior to set
[in]setChildrenChange the behavior of any children

◆ setName()

void AMP::Database::setName ( std::string  name)
inline

Get the name of the database.

Definition at line 224 of file Database.h.

References d_name.

◆ size()

size_t AMP::Database::size ( ) const
inline

Return the number of entries in the database.

Definition at line 255 of file Database.h.

References d_data.

◆ unit()

const Units & AMP::KeyData::unit ( ) const
inlineinherited

Return the units.

Definition at line 71 of file Database.h.

References AMP::KeyData::d_unit.

Referenced by addArgsWithUnits().

◆ unpack()

size_t AMP::Database::unpack ( const std::byte *  )
overridevirtual

Unpack the data from a buffer.

Implements AMP::KeyData.

◆ writeHDF5()

void AMP::Database::writeHDF5 ( int64_t  fid,
const std::string &  name 
) const
overridevirtual

Write the data to HDF5.

Implements AMP::KeyData.

Member Data Documentation

◆ d_check

Check AMP::Database::d_check
protected

Definition at line 621 of file Database.h.

Referenced by getDefaultAddKeyBehavior().

◆ d_data

std::vector<std::shared_ptr<KeyData> > AMP::Database::d_data
protected

Definition at line 625 of file Database.h.

Referenced by empty(), and size().

◆ d_hash

std::vector<uint32_t> AMP::Database::d_hash
protected

Definition at line 623 of file Database.h.

Referenced by find().

◆ d_keys

std::vector<std::string> AMP::Database::d_keys
protected

Definition at line 624 of file Database.h.

◆ d_name

std::string AMP::Database::d_name
protected

Definition at line 622 of file Database.h.

Referenced by getName(), and setName().

◆ d_unit

Units AMP::KeyData::d_unit
protectedinherited

Definition at line 105 of file Database.h.

Referenced by AMP::KeyData::unit().

◆ d_used

std::vector<bool> AMP::Database::d_used
mutableprotected

Definition at line 626 of file Database.h.

Referenced by find().


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



Advanced Multi-Physics (AMP)
Oak Ridge National Laboratory
Idaho National Laboratory
Los Alamos National Laboratory
This page automatically produced from the
source code by doxygen
Last updated: Tue Mar 10 2026 13:06:42.
Comments on this page