16#ifndef dealii_any_data_h
17#define dealii_any_data_h
24#include <boost/any.hpp>
48 template <
typename type>
66 template <
typename type>
78 template <
typename type>
93 template <
typename type>
106 template <
typename type>
114 template <
typename type>
125 template <
typename type>
132 template <
typename type>
134 entry(
const unsigned int i);
137 template <
typename type>
139 entry(
const unsigned int i)
const;
142 template <
typename type>
144 read(
const unsigned int i)
const;
147 template <
typename type>
149 read_ptr(
const unsigned int i)
const;
152 template <
typename type>
157 template <
typename type>
159 try_read(
const unsigned int i)
const;
163 name(
const unsigned int i)
const;
172 find(
const std::string &
name)
const;
184 template <
typename type>
186 is_type(
const unsigned int i)
const;
189 template <
class StreamType>
191 list(StreamType &os)
const;
196 <<
"No entry with the name " << arg1 <<
" exists.");
202 <<
"The requested type " << arg1 <<
" and the stored type "
203 << arg2 <<
" must coincide.");
212 <<
"Name at position " << arg1 <<
" is not equal to " << arg2
230template <
typename type>
235 type *p = boost::any_cast<type>(&
data[i]);
242template <
typename type>
247 const type *p = boost::any_cast<type>(&
data[i]);
249 p = boost::any_cast<const type>(&
data[i]);
256template <
typename type>
261 const type *p = boost::any_cast<type>(&
data[i]);
263 p = boost::any_cast<const type>(&
data[i]);
270template <
typename type>
275 const type *
const *p = boost::any_cast<type *>(&
data[i]);
277 p = boost::any_cast<const type *>(&
data[i]);
284template <
typename type>
289 const type *
const *p = boost::any_cast<type *>(&
data[i]);
291 p = boost::any_cast<const type *>(&
data[i]);
298template <
typename type>
303 const type *p = boost::any_cast<type>(&
data[i]);
305 p = boost::any_cast<const type>(&
data[i]);
310inline const std::string &
321 std::vector<std::string>::const_iterator it =
324 if (it ==
names.end())
327 return it -
names.begin();
341template <
typename type>
345 return data[i].type() ==
typeid(type);
349template <
typename type>
353 const unsigned int i =
find(n);
354 type * p = boost::any_cast<type>(&
data[i]);
360template <
typename type>
364 const unsigned int i =
find(n);
365 const type * p = boost::any_cast<type>(&
data[i]);
372template <
typename type>
376 const unsigned int i =
find(n);
377 const type * p = boost::any_cast<type>(&
data[i]);
383template <
typename type>
387 const unsigned int i =
find(n);
388 const type *
const *p = boost::any_cast<type *>(&
data[i]);
390 p = boost::any_cast<const type *>(&
data[i]);
397template <
typename type>
405 const type *
const *p = boost::any_cast<type *>(&
data[i]);
407 p = boost::any_cast<const type *>(&
data[i]);
412template <
typename type>
417 std::vector<std::string>::const_iterator it =
420 if (it ==
names.end())
424 unsigned int i = it -
names.begin();
425 const type * p = boost::any_cast<type>(&
data[i]);
430template <
typename type>
443 for (
unsigned int i = 0; i < other.
size(); ++i)
451template <
class StreamType>
455 for (
unsigned int i = 0; i <
names.size(); ++i)
457 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.
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.
const 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< boost::any > data
The stored data.
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)
SymmetricTensor< 2, dim, Number > e(const Tensor< 2, dim, Number > &F)
static const unsigned int invalid_unsigned_int