15#ifndef dealii_algorithms_general_data_storage_h
16#define dealii_algorithms_general_data_storage_h
23#include <boost/core/demangle.hpp>
91 template <
class Stream>
190 template <
typename Type>
203 template <
typename Type>
216 template <
typename Type>
230 template <
typename Type>
244 template <
typename Type,
typename Arg,
typename... Args>
257 template <
typename Type,
typename Arg>
271 template <
typename Type,
typename Arg,
typename... Args>
275 Args &&...arguments);
284 template <
typename Type,
typename Arg>
291 template <
typename Type>
302 template <
typename Type>
313 template <
typename Type>
336 <<
"No entry with the name " << arg1 <<
" exists.");
343 <<
"An entry with the name " << arg1 <<
" already exists.");
352 <<
"The stored type for entry with name \"" << arg1 <<
"\" is "
353 << arg2 <<
" but you requested type " << arg3 <<
'.');
369template <
class Stream>
375 os << it.first <<
'\t' <<
'\t'
376 << boost::core::demangle(it.second.type().name()) << std::endl;
381template <
typename Type>
390template <
typename Type>
399template <
typename Type>
408template <
typename Type>
418template <
typename Type>
426 if (
any_data[name].type() ==
typeid(Type *))
428 p = std::any_cast<Type *>(
any_data[name]);
430 else if (
any_data[name].type() ==
typeid(Type))
432 p = std::any_cast<Type>(&
any_data[name]);
439 typeid(Type).name()));
446template <
typename Type>
454 if (
it->second.type() ==
typeid(Type *))
456 const Type *
p = std::any_cast<Type *>(
it->second);
459 else if (
it->second.type() ==
typeid(Type))
461 const Type *
p = std::any_cast<Type>(&
it->second);
468 it->second.type().name(),
469 typeid(Type).name()));
470 const Type *
p =
nullptr;
477template <
typename Type,
typename Arg>
485 return get_object_with_name<Type>(name);
490template <
typename Type,
typename Arg,
typename... Args>
499 return get_object_with_name<Type>(name);
504template <
typename Type,
typename Arg>
512 return get_object_with_name<Type>(name);
517template <
typename Type,
typename Arg,
typename... Args>
525 Type(std::forward<Arg>(argument),
526 std::forward<Args>(arguments)...));
528 return get_object_with_name<Type>(name);
532template <
typename Type>
539 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)