16#ifndef dealii_algorithms_general_data_storage_h
17#define dealii_algorithms_general_data_storage_h
24#include <boost/any.hpp>
25#include <boost/core/demangle.hpp>
92 template <
class Stream>
191 template <
typename Type>
204 template <
typename Type>
217 template <
typename Type>
231 template <
typename Type>
245 template <
typename Type,
typename Arg,
typename... Args>
258 template <
typename Type,
typename Arg>
272 template <
typename Type,
typename Arg,
typename... Args>
276 Args &&...arguments);
285 template <
typename Type,
typename Arg>
292 template <
typename Type>
303 template <
typename Type>
314 template <
typename Type>
337 <<
"No entry with the name " << arg1 <<
" exists.");
344 <<
"An entry with the name " << arg1 <<
" already exists.");
353 <<
"The stored type for entry with name \"" << arg1 <<
"\" is "
354 << arg2 <<
" but you requested type " << arg3 <<
'.');
370template <
class Stream>
376 os << it.first <<
'\t' <<
'\t'
377 << boost::core::demangle(it.second.type().name()) << std::endl;
382template <
typename Type>
391template <
typename Type>
400template <
typename Type>
409template <
typename Type>
419template <
typename Type>
427 if (
any_data[name].type() ==
typeid(Type *))
429 p = boost::any_cast<Type *>(
any_data[name]);
431 else if (
any_data[name].type() ==
typeid(Type))
433 p = boost::any_cast<Type>(&
any_data[name]);
440 typeid(Type).name()));
447template <
typename Type>
453 const auto it =
any_data.find(name);
455 if (it->second.type() ==
typeid(Type *))
457 const Type *p = boost::any_cast<Type *>(it->second);
460 else if (it->second.type() ==
typeid(Type))
462 const Type *p = boost::any_cast<Type>(&it->second);
469 it->second.type().name(),
470 typeid(Type).name()));
471 const Type *p =
nullptr;
478template <
typename Type,
typename Arg>
486 return get_object_with_name<Type>(name);
491template <
typename Type,
typename Arg,
typename... Args>
500 return get_object_with_name<Type>(name);
505template <
typename Type,
typename Arg>
513 return get_object_with_name<Type>(name);
518template <
typename Type,
typename Arg,
typename... Args>
526 Type(std::forward<Arg>(argument),
527 std::forward<Args>(arguments)...));
529 return get_object_with_name<Type>(name);
533template <
typename Type>
540 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)
std::map< std::string, boost::any > any_data
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
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)