15#ifndef dealii_algorithms_general_data_storage_h
16#define dealii_algorithms_general_data_storage_h
23#include <boost/core/demangle.hpp>
79 template <
class Stream>
178 template <
typename Type>
191 template <
typename Type>
204 template <
typename Type>
218 template <
typename Type>
232 template <
typename Type,
typename Arg,
typename... Args>
245 template <
typename Type,
typename Arg>
259 template <
typename Type,
typename Arg,
typename... Args>
263 Args &&...arguments);
272 template <
typename Type,
typename Arg>
279 template <
typename Type>
290 template <
typename Type>
301 template <
typename Type>
324 <<
"No entry with the name " << arg1 <<
" exists.");
331 <<
"An entry with the name " << arg1 <<
" already exists.");
340 <<
"The stored type for entry with name \"" << arg1 <<
"\" is "
341 << arg2 <<
" but you requested type " << arg3 <<
'.');
357template <
class Stream>
363 os << it.first <<
'\t' <<
'\t'
364 << boost::core::demangle(it.second.type().name()) << std::endl;
369template <
typename Type>
378template <
typename Type>
387template <
typename Type>
396template <
typename Type>
406template <
typename Type>
414 if (
any_data[name].type() ==
typeid(Type *))
416 p = std::any_cast<Type *>(
any_data[name]);
418 else if (
any_data[name].type() ==
typeid(Type))
420 p = std::any_cast<Type>(&
any_data[name]);
427 typeid(Type).name()));
434template <
typename Type>
440 const auto it =
any_data.find(name);
442 if (it->second.type() ==
typeid(Type *))
444 const Type *p = std::any_cast<Type *>(it->second);
447 else if (it->second.type() ==
typeid(Type))
449 const Type *p = std::any_cast<Type>(&it->second);
456 it->second.type().name(),
457 typeid(Type).name()));
458 const Type *p =
nullptr;
465template <
typename Type,
typename Arg>
473 return get_object_with_name<Type>(name);
478template <
typename Type,
typename Arg,
typename... Args>
487 return get_object_with_name<Type>(name);
492template <
typename Type,
typename Arg>
500 return get_object_with_name<Type>(name);
505template <
typename Type,
typename Arg,
typename... Args>
513 Type(std::forward<Arg>(argument),
514 std::forward<Args>(arguments)...));
516 return get_object_with_name<Type>(name);
520template <
typename Type>
527 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)