13#ifndef dealii_algorithms_general_data_storage_h
14#define dealii_algorithms_general_data_storage_h
21#include <boost/core/demangle.hpp>
78 template <
class Stream>
177 template <
typename Type>
190 template <
typename Type>
203 template <
typename Type>
217 template <
typename Type>
231 template <
typename Type,
typename Arg,
typename... Args>
244 template <
typename Type,
typename Arg>
258 template <
typename Type,
typename Arg,
typename... Args>
262 Args &&...arguments);
271 template <
typename Type,
typename Arg>
278 template <
typename Type>
289 template <
typename Type>
300 template <
typename Type>
323 <<
"No entry with the name " << arg1 <<
" exists.");
330 <<
"An entry with the name " << arg1 <<
" already exists.");
339 <<
"The stored type for entry with name \"" << arg1 <<
"\" is "
340 << arg2 <<
" but you requested type " << arg3 <<
'.');
356template <
class Stream>
362 os << it.first <<
'\t' <<
'\t'
363 << boost::core::demangle(it.second.type().name()) << std::endl;
368template <
typename Type>
377template <
typename Type>
386template <
typename Type>
395template <
typename Type>
405template <
typename Type>
413 if (
any_data[name].type() ==
typeid(Type *))
415 p = std::any_cast<Type *>(
any_data[name]);
417 else if (
any_data[name].type() ==
typeid(Type))
419 p = std::any_cast<Type>(&
any_data[name]);
426 typeid(Type).name()));
433template <
typename Type>
439 const auto it =
any_data.find(name);
441 if (it->second.type() ==
typeid(Type *))
443 const Type *p = std::any_cast<Type *>(it->second);
446 else if (it->second.type() ==
typeid(Type))
448 const Type *p = std::any_cast<Type>(&it->second);
455 it->second.type().name(),
456 typeid(Type).name()));
457 const Type *p =
nullptr;
464template <
typename Type,
typename Arg>
472 return get_object_with_name<Type>(name);
477template <
typename Type,
typename Arg,
typename... Args>
486 return get_object_with_name<Type>(name);
491template <
typename Type,
typename Arg>
499 return get_object_with_name<Type>(name);
504template <
typename Type,
typename Arg,
typename... Args>
512 Type(std::forward<Arg>(argument),
513 std::forward<Args>(arguments)...));
515 return get_object_with_name<Type>(name);
519template <
typename Type>
526 return get_object_with_name<Type>(name);
GeneralDataStorage(GeneralDataStorage &&)=default
void merge(const GeneralDataStorage &other_data)
Type & get_or_add_object_with_name(const std::string &name, Arg &argument)
void add_unique_reference(const std::string &name, Type &entry)
void add_unique_copy(const std::string &name, const Type &entry)
GeneralDataStorage()=default
void remove_object_with_name(const std::string &name)
void add_or_overwrite_copy(const std::string &name, const Type &entry)
const Type & get_object_with_name(const std::string &name) const
bool stores_object_with_name(const std::string &name) const
void print_info(Stream &stream)
Type & get_or_add_object_with_name(const std::string &name, Arg &&argument, Args &&...arguments)
void add_or_overwrite_reference(const std::string &name, Type &entry)
Type & get_or_add_object_with_name(const std::string &name)
GeneralDataStorage(const GeneralDataStorage &)=default
std::map< std::string, std::any > any_data
Type & get_or_add_object_with_name(const std::string &name, Arg &argument, Args &...arguments)
Type & get_or_add_object_with_name(const std::string &name, Arg &&argument)
Type & get_object_with_name(const std::string &name)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcNameNotFound(std::string arg1)
static ::ExceptionBase & ExcNameHasBeenFound(std::string arg1)
static ::ExceptionBase & ExcTypeMismatch(std::string arg1, const char *arg2, const char *arg3)
#define DeclException3(Exception3, type1, type2, type3, outsequence)
#define DeclException1(Exception1, type1, outsequence)
#define AssertThrow(cond, exc)