15#ifndef dealii_any_data_h
16#define dealii_any_data_h
47 template <
typename type>
65 template <
typename type>
77 template <
typename type>
92 template <
typename type>
105 template <
typename type>
113 template <
typename type>
124 template <
typename type>
131 template <
typename type>
133 entry(
const unsigned int i);
136 template <
typename type>
138 entry(
const unsigned int i)
const;
141 template <
typename type>
143 read(
const unsigned int i)
const;
146 template <
typename type>
148 read_ptr(
const unsigned int i)
const;
151 template <
typename type>
156 template <
typename type>
158 try_read(
const unsigned int i)
const;
162 name(
const unsigned int i)
const;
171 find(
const std::string &
name)
const;
183 template <
typename type>
185 is_type(
const unsigned int i)
const;
188 template <
typename StreamType>
190 list(StreamType &os)
const;
195 <<
"No entry with the name " << arg1 <<
" exists.");
201 <<
"The requested type " << arg1 <<
" and the stored type "
202 << arg2 <<
" must coincide.");
211 <<
"Name at position " << arg1 <<
" is not equal to " << arg2
229template <
typename type>
234 const type *p = std::any_cast<type>(&
data[i]);
241template <
typename type>
246 const type *p = std::any_cast<type>(&
data[i]);
248 p = std::any_cast<const type>(&
data[i]);
255template <
typename type>
260 const type *p = std::any_cast<type>(&
data[i]);
262 p = std::any_cast<const type>(&
data[i]);
269template <
typename type>
274 const type *
const *p = std::any_cast<type *>(&
data[i]);
276 p = std::any_cast<const type *>(&
data[i]);
283template <
typename type>
288 const type *
const *p = std::any_cast<type *>(&
data[i]);
290 p = std::any_cast<const type *>(&
data[i]);
297template <
typename type>
302 const type *p = std::any_cast<type>(&
data[i]);
304 p = std::any_cast<const type>(&
data[i]);
309inline const std::string &
162 name(
const unsigned int i)
const; {
…}
320 std::vector<std::string>::const_iterator it =
323 if (it ==
names.end())
326 return it -
names.begin();
340template <
typename type>
344 return data[i].type() ==
typeid(type);
348template <
typename type>
352 const unsigned int i =
find(n);
353 const type *p = std::any_cast<type>(&
data[i]);
359template <
typename type>
363 const unsigned int i =
find(n);
364 const type *p = std::any_cast<type>(&
data[i]);
371template <
typename type>
375 const unsigned int i =
find(n);
376 const type *p = std::any_cast<type>(&
data[i]);
382template <
typename type>
386 const unsigned int i =
find(n);
387 const type *
const *p = std::any_cast<type *>(&
data[i]);
389 p = std::any_cast<const type *>(&
data[i]);
396template <
typename type>
404 const type *
const *p = std::any_cast<type *>(&
data[i]);
406 p = std::any_cast<const type *>(&
data[i]);
411template <
typename type>
416 std::vector<std::string>::const_iterator it =
419 if (it ==
names.end())
423 unsigned int i = it -
names.begin();
424 const type *p = std::any_cast<type>(&
data[i]);
429template <
typename type>
442 for (
unsigned int i = 0; i < other.
size(); ++i)
450template <
typename StreamType>
454 for (
unsigned int i = 0; i <
names.size(); ++i)
456 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)
constexpr unsigned int invalid_unsigned_int