NeoN
A framework for CFD software
Loading...
Searching...
No Matches
stencilDataBase.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2023 - 2025 NeoN authors
2//
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
7#include <unordered_map>
8#include <any>
9#include <string>
10
11namespace NeoN
12{
13
22{
23public:
24
28 StencilDataBase() = default;
29
37 template<typename T>
38 void insert(const std::string& key, T value)
39 {
40 stencilDB_.emplace(key, value);
41 }
42
49 std::any& operator[](const std::string& key);
50
58 const std::any& operator[](const std::string& key) const;
59
68 template<typename T>
69 T& get(const std::string& key)
70 {
71 return std::any_cast<T&>(stencilDB_.at(key));
72 }
73
83 template<typename T>
84 const T& get(const std::string& key) const
85 {
86 return std::any_cast<const T&>(stencilDB_.at(key));
87 }
88
96 bool contains(const std::string& key) const;
97
98private:
99
103 std::unordered_map<std::string, std::any> stencilDB_;
104};
105
106} // namespace NeoN
A class that represents a stencil database.
std::any & operator[](const std::string &key)
Retrieves a reference to the value associated with the given key.
StencilDataBase()=default
Default constructor for StencilDataBase.
bool contains(const std::string &key) const
Checks if the stencil database contains a value associated with the given key.
void insert(const std::string &key, T value)
Inserts a value into the stencil database.
const std::any & operator[](const std::string &key) const
Retrieves a const reference to the value associated with the given key.
const T & get(const std::string &key) const
Retrieves a const reference to the value associated with the given key.
T & get(const std::string &key)
Retrieves a reference to the value associated with the given key.
Definition array.hpp:20