15#ifndef dealii_algorithms_general_data_storage_h
16#define dealii_algorithms_general_data_storage_h
23#include <boost/core/demangle.hpp>
80 template <
class Stream>
179 template <
typename Type>
192 template <
typename Type>
205 template <
typename Type>
219 template <
typename Type>
233 template <
typename Type,
typename Arg,
typename... Args>
246 template <
typename Type,
typename Arg>
260 template <
typename Type,
typename Arg,
typename... Args>
264 Args &&...arguments);
273 template <
typename Type,
typename Arg>
280 template <
typename Type>
291 template <
typename Type>
302 template <
typename Type>
325 <<
"No entry with the name " << arg1 <<
" exists.");
332 <<
"An entry with the name " << arg1 <<
" already exists.");
341 <<
"The stored type for entry with name \"" << arg1 <<
"\" is "
342 << arg2 <<
" but you requested type " << arg3 <<
'.');
358template <
class Stream>
364 os << it.first <<
'\t' <<
'\t'
365 << boost::core::demangle(it.second.type().name()) << std::endl;
370template <
typename Type>
379template <
typename Type>
388template <
typename Type>
397template <
typename Type>
407template <
typename Type>
415 if (
any_data[name].type() ==
typeid(Type *))
417 p = std::any_cast<Type *>(
any_data[name]);
419 else if (
any_data[name].type() ==
typeid(Type))
421 p = std::any_cast<Type>(&
any_data[name]);
428 typeid(Type).name()));
435template <
typename Type>
441 const auto it =
any_data.find(name);
443 if (it->second.type() ==
typeid(Type *))
445 const Type *p = std::any_cast<Type *>(it->second);
448 else if (it->second.type() ==
typeid(Type))
450 const Type *p = std::any_cast<Type>(&it->second);
457 it->second.type().name(),
458 typeid(Type).name()));
459 const Type *p =
nullptr;
466template <
typename Type,
typename Arg>
474 return get_object_with_name<Type>(name);
479template <
typename Type,
typename Arg,
typename... Args>
488 return get_object_with_name<Type>(name);
493template <
typename Type,
typename Arg>
501 return get_object_with_name<Type>(name);
506template <
typename Type,
typename Arg,
typename... Args>
514 Type(std::forward<Arg>(argument),
515 std::forward<Args>(arguments)...));
517 return get_object_with_name<Type>(name);
521template <
typename Type>
528 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)