15#ifndef dealii_any_data_h
16#define dealii_any_data_h
46 template <
typename type>
64 template <
typename type>
76 template <
typename type>
91 template <
typename type>
104 template <
typename type>
112 template <
typename type>
123 template <
typename type>
130 template <
typename type>
132 entry(
const unsigned int i);
135 template <
typename type>
137 entry(
const unsigned int i)
const;
140 template <
typename type>
142 read(
const unsigned int i)
const;
145 template <
typename type>
147 read_ptr(
const unsigned int i)
const;
150 template <
typename type>
155 template <
typename type>
157 try_read(
const unsigned int i)
const;
161 name(
const unsigned int i)
const;
170 find(
const std::string &
name)
const;
182 template <
typename type>
184 is_type(
const unsigned int i)
const;
187 template <
typename StreamType>
189 list(StreamType &os)
const;
194 <<
"No entry with the name " << arg1 <<
" exists.");
200 <<
"The requested type " << arg1 <<
" and the stored type "
201 << arg2 <<
" must coincide.");
210 <<
"Name at position " << arg1 <<
" is not equal to " << arg2
228template <
typename type>
233 const type *p = std::any_cast<type>(&
data[i]);
240template <
typename type>
245 const type *p = std::any_cast<type>(&
data[i]);
247 p = std::any_cast<const type>(&
data[i]);
254template <
typename type>
259 const type *p = std::any_cast<type>(&
data[i]);
261 p = std::any_cast<const type>(&
data[i]);
268template <
typename type>
273 const type *
const *p = std::any_cast<type *>(&
data[i]);
275 p = std::any_cast<const type *>(&
data[i]);
282template <
typename type>
287 const type *
const *p = std::any_cast<type *>(&
data[i]);
289 p = std::any_cast<const type *>(&
data[i]);
296template <
typename type>
301 const type *p = std::any_cast<type>(&
data[i]);
303 p = std::any_cast<const type>(&
data[i]);
308inline const std::string &
319 std::vector<std::string>::const_iterator it =
322 if (it ==
names.end())
325 return it -
names.begin();
339template <
typename type>
343 return data[i].type() ==
typeid(type);
347template <
typename type>
351 const unsigned int i =
find(n);
352 const type *p = std::any_cast<type>(&
data[i]);
358template <
typename type>
362 const unsigned int i =
find(n);
363 const type *p = std::any_cast<type>(&
data[i]);
370template <
typename type>
374 const unsigned int i =
find(n);
375 const type *p = std::any_cast<type>(&
data[i]);
381template <
typename type>
385 const unsigned int i =
find(n);
386 const type *
const *p = std::any_cast<type *>(&
data[i]);
388 p = std::any_cast<const type *>(&
data[i]);
395template <
typename type>
403 const type *
const *p = std::any_cast<type *>(&
data[i]);
405 p = std::any_cast<const type *>(&
data[i]);
410template <
typename type>
415 std::vector<std::string>::const_iterator it =
418 if (it ==
names.end())
422 unsigned int i = it -
names.begin();
423 const type *p = std::any_cast<type>(&
data[i]);
428template <
typename type>
441 for (
unsigned int i = 0; i < other.
size(); ++i)
449template <
typename StreamType>
453 for (
unsigned int i = 0; i <
names.size(); ++i)
455 os << i <<
'\t' <<
names[i] <<
'\t' <<
data[i].type().name() << std::endl;
const std::string & name(const unsigned int i) const
Name of object at index.
const type * try_read(const std::string &name) const
Dedicated read only access by name without exceptions.
type entry(const std::string &name)
Access to stored data object by name.
unsigned int try_find(const std::string &name) const
Try to find index of a named object.
const type * read_ptr(const std::string &name) const
Dedicated read only access by name for pointer data.
unsigned int find(const std::string &name) const
Find index of a named object.
void add(type entry, const std::string &name)
Add a new data object.
unsigned int size() const
Number of stored data objects.
std::vector< std::any > data
The stored data.
void list(StreamType &os) const
List the contents to a stream.
bool is_type(const unsigned int i) const
Find out if object is of a certain type.
void merge(const AnyData &other)
Merge the data of another AnyData to the end of this object.
type read(const std::string &name) const
Dedicated read only access by name.
const type * try_read_ptr(const std::string &name) const
AnyData()=default
Default constructor for empty object.
std::vector< std::string > names
The names of the stored data.
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcNameMismatch(int arg1, std::string arg2)
#define Assert(cond, exc)
static ::ExceptionBase & ExcNameNotFound(std::string arg1)
An entry with this name does not exist in the AnyData object.
#define DeclException2(Exception2, type1, type2, outsequence)
#define AssertDimension(dim1, dim2)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcTypeMismatch(std::string arg1, std::string arg2)
The requested type and the stored type are different.
#define DeclException1(Exception1, type1, outsequence)
static const unsigned int invalid_unsigned_int