NeoFOAM
WIP Prototype of a modern OpenFOAM core
Loading...
Searching...
No Matches
Public Member Functions | List of all members
NeoFOAM::Database Class Reference

#include <database.hpp>

Public Member Functions

Collectioninsert (const std::string &key, Collection &&col)
 Inserts a collection into the database with the specified key.
 
bool contains (const std::string &name) const
 Checks if the database contains an collection with the specified name.
 
bool remove (const std::string &name)
 Removes a collection from the database.
 
Collectionat (const std::string &name)
 Retrieves a collection by its name.
 
const Collectionat (const std::string &name) const
 Retrieves a collection by its name (const version).
 
template<typename CollectionType = Collection>
CollectionType & at (const std::string &name)
 Retrieves a collection by its name and casts it to the specified type.
 
std::size_t size () const
 Returns the size of the database.
 

Detailed Description

Definition at line 16 of file database.hpp.

Member Function Documentation

◆ at() [1/3]

Collection & NeoFOAM::Database::at ( const std::string &  name)

Retrieves a collection by its name.

This function searches for and returns a reference to a collection identified by the given name. If the collection does not exist, the behavior is undefined.

Parameters
nameThe name of the collection to retrieve.
Returns
Collection& A reference to the collection with the specified name.

◆ at() [2/3]

template<typename CollectionType = Collection>
CollectionType & NeoFOAM::Database::at ( const std::string &  name)
inline

Retrieves a collection by its name and casts it to the specified type.

This function retrieves a collection by its name and attempts to cast it to the specified type. If the collection does not exist or the cast fails, an exception is thrown.

Template Parameters
CollectionTypeThe type to cast the collection to.
Parameters
nameThe name of the collection to retrieve.
Returns
CollectionType& A reference to the collection cast to the specified type.

Definition at line 82 of file database.hpp.

◆ at() [3/3]

const Collection & NeoFOAM::Database::at ( const std::string &  name) const

Retrieves a collection by its name (const version).

This function searches for and returns a const reference to a collection identified by the given name. If the collection does not exist, the behavior is undefined.

Parameters
nameThe name of the collection to retrieve.
Returns
const Collection& A const reference to the collection with the specified name.

◆ contains()

bool NeoFOAM::Database::contains ( const std::string &  name) const

Checks if the database contains an collection with the specified name.

Parameters
nameThe name of the collection to check for.
Returns
true if the collection exists in the database, false otherwise.

◆ insert()

Collection & NeoFOAM::Database::insert ( const std::string &  key,
Collection &&  col 
)

Inserts a collection into the database with the specified key.

Parameters
keyThe key associated with the collection to be inserted.
colThe collection to be inserted into the database.
Returns
Collection& A reference to the inserted collection.

◆ remove()

bool NeoFOAM::Database::remove ( const std::string &  name)

Removes a collection from the database.

This function removes the collection with the specified name from the database.

Parameters
nameThe name of the collection to be removed.
Returns
true if the collection was successfully removed, false otherwise.

◆ size()

std::size_t NeoFOAM::Database::size ( ) const

Returns the size of the database.

This function provides the number of elements currently stored in the database.

Returns
std::size_t The number of elements in the database.

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