16 #ifndef dealii__any_data_h 17 #define dealii__any_data_h 19 #include <deal.II/base/config.h> 20 #include <deal.II/base/exceptions.h> 21 #include <deal.II/base/subscriptor.h> 23 #include <boost/any.hpp> 28 DEAL_II_NAMESPACE_OPEN
43 unsigned int size()
const;
46 template <
typename type>
62 template <
typename type>
73 template <
typename type>
74 const type
entry (
const std::string &
name)
const;
87 template <
typename type>
88 const type
read (
const std::string &
name)
const;
99 template <
typename type>
106 template <
typename type>
116 template <
typename type>
122 template <
typename type>
123 type
entry (
const unsigned int i);
126 template <
typename type>
127 const type
entry (
const unsigned int i)
const;
130 template <
typename type>
131 const type
read (
const unsigned int i)
const;
134 template <
typename type>
135 const type *
read_ptr (
const unsigned int i)
const;
138 template <
typename type>
142 template <
typename type>
143 const type *
try_read (
const unsigned int i)
const;
146 const std::string &
name(
const unsigned int i)
const;
154 unsigned int find(
const std::string &
name)
const;
165 template <
typename type>
166 bool is_type(
const unsigned int i)
const;
169 template <
class StreamType>
170 void list (StreamType &os)
const;
174 <<
"No entry with the name " << arg1 <<
" exists.");
179 <<
"The requested type " << arg1
180 <<
" and the stored type " << arg2
181 <<
" must coincide.");
188 <<
"Name at position " << arg1 <<
" is not equal to " << arg2 <<
".");
211 template <
typename type>
217 type *p = boost::any_cast<type>(&
data[i]);
224 template <
typename type>
230 const type *p = boost::any_cast<type>(&
data[i]);
232 p = boost::any_cast<
const type>(&
data[i]);
239 template <
typename type>
245 const type *p = boost::any_cast<type>(&
data[i]);
247 p = boost::any_cast<
const type>(&
data[i]);
254 template <
typename type>
260 const type *
const *p = boost::any_cast<type *>(&
data[i]);
262 p = boost::any_cast<
const type *>(&
data[i]);
269 template <
typename type>
275 const type *
const *p = boost::any_cast<type *>(&
data[i]);
277 p = boost::any_cast<
const type *>(&
data[i]);
284 template <
typename type>
290 const type *p = boost::any_cast<type>(&
data[i]);
292 p = boost::any_cast<
const type>(&
data[i]);
310 std::vector<std::string>::const_iterator it =
313 if (it ==
names.end())
316 return it -
names.begin();
331 template <
typename type>
336 return data[i].type() ==
typeid(type);
340 template <
typename type>
345 const unsigned int i =
find(n);
346 type *p = boost::any_cast<type>(&
data[i]);
353 template <
typename type>
358 const unsigned int i =
find(n);
359 const type *p = boost::any_cast<type>(&
data[i]);
366 template <
typename type>
371 const unsigned int i =
find(n);
372 const type *p = boost::any_cast<type>(&
data[i]);
379 template <
typename type>
384 const unsigned int i =
find(n);
385 const type *
const *p = boost::any_cast<type *>(&
data[i]);
387 p = boost::any_cast<
const type *>(&
data[i]);
394 template <
typename type>
403 const type *
const *p = boost::any_cast<type *>(&
data[i]);
405 p = boost::any_cast<
const type *>(&
data[i]);
410 template <
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 = boost::any_cast<type>(&
data[i]);
429 template <
typename type>
444 for (
unsigned int i=0; i<other.
size(); ++i)
452 template <
class StreamType>
456 for (
unsigned int i=0; i<
names.size(); ++i)
460 <<
'\t' <<
data[i].type().name()
470 DEAL_II_NAMESPACE_CLOSE
bool is_type(const unsigned int i) const
Find out if object is of a certain type.
static ::ExceptionBase & ExcNameNotFound(std::string arg1)
An entry with this name does not exist in the AnyData object.
static const unsigned int invalid_unsigned_int
type entry(const std::string &name)
Access to stored data object by name.
#define DeclException2(Exception2, type1, type2, outsequence)
void merge(const AnyData &other)
Merge the data of another AnyData to the end of this object.
#define AssertDimension(dim1, dim2)
const type read(const std::string &name) const
Dedicated read only access by name.
AnyData()
Default constructor for empty object.
#define AssertIndexRange(index, range)
#define DeclException1(Exception1, type1, outsequence)
#define Assert(cond, exc)
const type * try_read_ptr(const std::string &name) const
static ::ExceptionBase & ExcTypeMismatch(char *arg1, char *arg2)
The requested type and the stored type are different.
std::vector< boost::any > data
The stored data.
const type * read_ptr(const std::string &name) const
Dedicated read only access by name for pointer data.
const type * try_read(const std::string &name) const
Dedicated read only access by name without exceptions.
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::string > names
The names of the stored data.
void list(StreamType &os) const
List the contents to a stream.
unsigned int try_find(const std::string &name) const
Try to find index of a named object.
static ::ExceptionBase & ExcNameMismatch(int arg1, std::string arg2)
const std::string & name(const unsigned int i) const
Name of object at index.