16 #ifndef dealii_algorithms_general_data_storage_h 17 #define dealii_algorithms_general_data_storage_h 19 #include <deal.II/base/config.h> 21 #include <deal.II/base/exceptions.h> 22 #include <deal.II/base/subscriptor.h> 24 #include <boost/any.hpp> 25 #include <boost/core/demangle.hpp> 32 DEAL_II_NAMESPACE_OPEN
94 template <
class Stream>
193 template <
typename Type>
206 template <
typename Type>
219 template <
typename Type>
233 template <
typename Type>
247 template <
typename Type,
typename Arg,
typename... Args>
251 Args &... arguments);
263 template <
typename Type,
typename Arg,
typename... Args>
267 Args &&... arguments);
272 template <
typename Type>
283 template <
typename Type>
294 template <
typename Type>
317 <<
"No entry with the name " << arg1 <<
" exists.");
324 <<
"An entry with the name " << arg1 <<
" already exists.");
333 <<
"The stored type for entry with name \"" << arg1 <<
"\" is " 334 << arg2 <<
" but you requested type " << arg3 <<
".");
350 template <
class Stream>
356 os << it.first <<
'\t' <<
'\t' 357 << boost::core::demangle(it.second.type().name()) << std::endl;
362 template <
typename Type>
371 template <
typename Type>
380 template <
typename Type>
389 template <
typename Type>
399 template <
typename Type>
407 if (
any_data[name].type() ==
typeid(Type *))
409 p = boost::any_cast<Type *>(
any_data[name]);
411 else if (
any_data[name].type() ==
typeid(Type))
413 p = boost::any_cast<Type>(&
any_data[name]);
420 typeid(Type).name()));
427 template <
typename Type>
433 const auto it =
any_data.find(name);
435 if (it->second.type() ==
typeid(Type *))
437 const Type *p = boost::any_cast<Type *>(it->second);
440 else if (it->second.type() ==
typeid(Type))
442 const Type *p = boost::any_cast<Type>(&it->second);
449 it->second.type().name(),
450 typeid(Type).name()));
451 const Type *p =
nullptr;
457 template <
typename Type,
typename Arg,
typename... Args>
466 return get_object_with_name<Type>(name);
470 template <
typename Type,
typename Arg,
typename... Args>
474 Args &&... arguments)
478 Type(std::forward<Arg>(argument),
479 std::forward<Args>(arguments)...));
481 return get_object_with_name<Type>(name);
485 template <
typename Type>
492 return get_object_with_name<Type>(name);
499 DEAL_II_NAMESPACE_CLOSE
501 #endif // dealii_algorithms_general_data_storage_h void add_unique_copy(const std::string &name, const Type &entry)
void add_or_overwrite_copy(const std::string &name, const Type &entry)
void add_or_overwrite_reference(const std::string &name, Type &entry)
#define AssertThrow(cond, exc)
Type & get_object_with_name(const std::string &name)
Type & get_or_add_object_with_name(const std::string &name, Arg &argument, Args &... arguments)
#define DeclException1(Exception1, type1, outsequence)
bool stores_object_with_name(const std::string &name) const
void print_info(Stream &stream)
static ::ExceptionBase & ExcNameNotFound(std::string arg1)
std::map< std::string, boost::any > any_data
void add_unique_reference(const std::string &name, Type &entry)
void merge(const GeneralDataStorage &other_data)
static ::ExceptionBase & ExcTypeMismatch(std::string arg1, const char *arg2, const char *arg3)
GeneralDataStorage()=default
#define DeclException3(Exception3, type1, type2, type3, outsequence)
static ::ExceptionBase & ExcNameHasBeenFound(std::string arg1)
void remove_object_with_name(const std::string &name)