17 #ifndef __deal2__named_data_h
18 #define __deal2__named_data_h
20 #include <deal.II/base/config.h>
22 #include <deal.II/base/subscriptor.h>
47 template <
typename DATA>
61 template <
typename DATA2>
72 void add(DATA &v,
const std::string &
name);
80 void add(
const DATA &v,
const std::string &name);
91 template <
typename DATA2>
102 template <
typename DATA2>
110 unsigned int size()
const;
128 const DATA &
operator() (
unsigned int i)
const;
131 const DATA &
read (
unsigned int i)
const;
134 const std::string &
name(
unsigned int i)
const;
137 unsigned int find(
const std::string &name)
const;
144 void print(OUT &o)
const;
154 <<
"Name at position " << arg1 <<
" is not equal to " << arg2);
195 void add (
const std::string &name);
202 template <
typename DATA>
211 unsigned int size()
const;
224 unsigned int operator() (
unsigned int i)
const;
242 template<
typename DATA>
250 template<
typename DATA>
255 Assert(!is_constant, ExcConstantObject());
261 template<
typename DATA>
266 Assert(!is_constant, ExcConstantObject());
267 DATA &aux =
const_cast<DATA &
>(v);
274 template<
typename DATA>
275 template<
typename DATA2>
280 Assert(!is_constant, ExcConstantObject());
282 for (
unsigned int i=0; i<other.
size(); ++i)
284 names.push_back(other.
name(i));
285 data.push_back(other.
read(i));
291 template<
typename DATA>
292 template<
typename DATA2>
297 Assert(!is_constant, ExcConstantObject());
298 for (
unsigned int i=0; i<other.
size(); ++i)
300 names.push_back(other.
name(i));
301 data.push_back(other(i));
308 template<
typename DATA>
309 template<
typename DATA2>
322 template<
typename DATA>
331 template<
typename DATA>
340 template<
typename DATA>
345 Assert(!is_constant, ExcConstantObject());
351 template<
typename DATA>
361 template<
typename DATA>
371 template<
typename DATA>
381 template<
typename DATA>
386 const std::vector<std::string>::const_iterator
387 i = std::find(names.begin(), names.end(), name);
388 if (i == names.end())
389 return deal_II_numbers::invalid_unsigned_int;
390 return i - names.begin();
394 template<
typename DATA>
401 for (
unsigned int i=0; i<size(); ++i)
402 o <<
' ' <<
'\"' << names[i] <<
'\"';
415 template <
typename DATA>
420 for (
unsigned int i=0; i<
names.size(); ++i)
443 DEAL_II_NAMESPACE_CLOSE
const std::string & name(unsigned int i) const
Name of object at index.
DATA & operator()(unsigned int i)
Access to stored data object by index.
void add(DATA &v, const std::string &name)
void add(const std::string &name)
std::vector< unsigned int > indices
#define AssertIndexRange(index, range)
unsigned int operator()(unsigned int i) const
void initialize(const NamedData< DATA > &data)
const DATA & read(unsigned int i) const
Read only access for a non-const object.
unsigned int size() const
#define Assert(cond, exc)
std::vector< std::string > names
Names for the data.
unsigned int size() const
Number of stored data objects.
unsigned int find(const std::string &name) const
Find index of a named object.
void merge(NamedData< DATA2 > &)
bool is_const() const
Returns true if this object contains constant data.
bool is_constant
True if the object is to be treated constant.
std::vector< DATA > data
The actual data stored.
std::vector< std::string > names
::ExceptionBase & ExcNotInitialized()
DeclException0(ExcConstantObject)
DeclException2(ExcNameMismatch, int, std::string,<< "Name at position "<< arg1<< " is not equal to "<< arg2)
void print(OUT &o) const
List names of stored objects.
NamedData< DATA > & operator=(const NamedData< DATA2 > &other)