
Public Member Functions | |
| NamedData () | |
| template<typename DATA2> | |
| NamedData< DATA > & | operator= (const NamedData< DATA2 > &other) |
Adding members | |
| void | add (DATA &v, const std::string &name) |
| void | add (const DATA &v, const std::string &name) |
| template<typename DATA2> | |
| void | merge (NamedData< DATA2 > &) |
| template<typename DATA2> | |
| void | merge (const NamedData< DATA2 > &) |
Accessing and querying | |
contents | |
| unsigned int | size () const |
| Number of stored data objects. | |
| DATA & | operator() (unsigned int i) |
| Access to stored data object by index. | |
| const DATA & | operator() (unsigned int i) const |
| Read-only access to stored data object by index. | |
| const DATA & | read (unsigned int i) const |
| Read only access for a non-const object. | |
| const std::string & | name (unsigned int i) const |
| Name of object at index. | |
| unsigned int | find (const std::string &name) const |
| Find index of a named object. | |
| bool | is_const () const |
| Returns true if this object contains constant data. | |
| template<class OUT> | |
| void | print (OUT &o) const |
| List names of stored objects. | |
Static Public Member Functions | |
| ::ExceptionBase & | ExcNameMismatch (int arg1, std::string arg2) throw (errortext << "Name at position " << arg1 << " is not equal to " << arg2 ) |
| ::ExceptionBase & | ExcConstantObject () |
Private Attributes | |
| 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 |
| Names for the data. | |
Note that it is the actual data stored in this object. Therefore, for storing vectors and other large objects, it should be considered to use SmartPointer or boost::shared_ptr for DATA.
Objects of this kind have a smart way of treating constness: if a const data object is added or a const NamedData is supplied with merge(), the object will henceforth consider itself as const (is_constant will be true). Thus, any subsequent modification will be illegal and ExcConstantObject will be raised in debug mode.
Standard constructor creating an empty object.
| NamedData< DATA > & NamedData< DATA >::operator= | ( | const NamedData< DATA2 > & | other | ) | [inline] |
Assignment operator, copying conversible data from another object.
References NamedData< DATA >::is_const(), NamedData< DATA >::is_constant, and NamedData< DATA >::merge().
| void NamedData< DATA >::add | ( | DATA & | v, | |
| const std::string & | name | |||
| ) | [inline] |
Add a new data item to the end of the collection.
References Assert, NamedData< DATA >::data, NamedData< DATA >::ExcConstantObject(), NamedData< DATA >::is_constant, and NamedData< DATA >::names.
Referenced by MeshWorker::Assembler::SystemSimple< MATRIX, VECTOR >::initialize().
| void NamedData< DATA >::add | ( | const DATA & | v, | |
| const std::string & | name | |||
| ) | [inline] |
Add a new constant data item to the end of the collection and make the collection constant.
References Assert, NamedData< DATA >::data, NamedData< DATA >::ExcConstantObject(), NamedData< DATA >::is_constant, and NamedData< DATA >::names.
| void NamedData< DATA >::merge | ( | NamedData< DATA2 > & | other | ) | [inline] |
Merge the data of another NamedData to the end of this object.
If the other object had is_constant set, so will have this object after merge.
References Assert, NamedData< DATA >::data, NamedData< DATA >::ExcConstantObject(), NamedData< DATA >::is_const(), NamedData< DATA >::is_constant, NamedData< DATA >::name(), NamedData< DATA >::names, NamedData< DATA >::read(), and NamedData< DATA >::size().
Referenced by NamedData< DATA >::operator=().
| void NamedData< DATA >::merge | ( | const NamedData< DATA2 > & | other | ) | [inline] |
Merge the data of another NamedData to the end of this object.
After this operation, all data in this object will be treated as const.
References Assert, NamedData< DATA >::data, NamedData< DATA >::ExcConstantObject(), NamedData< DATA >::is_constant, NamedData< DATA >::name(), NamedData< DATA >::names, and NamedData< DATA >::size().
Number of stored data objects.
References NamedData< DATA >::data.
Referenced by NamedData< DATA >::merge(), NamedData< DATA >::name(), NamedData< DATA >::operator()(), NamedData< DATA >::print(), and NamedData< DATA >::read().
Access to stored data object by index.
true. In such a case, either cast the NamedData object to a const reference, or use the function read() instead of this operator. References Assert, AssertIndexRange, NamedData< DATA >::data, NamedData< DATA >::ExcConstantObject(), NamedData< DATA >::is_constant, and NamedData< DATA >::size().
| const DATA & NamedData< DATA >::operator() | ( | unsigned int | i | ) | const [inline] |
Read-only access to stored data object by index.
References AssertIndexRange, NamedData< DATA >::data, and NamedData< DATA >::size().
Read only access for a non-const object.
References AssertIndexRange, NamedData< DATA >::data, and NamedData< DATA >::size().
Referenced by NamedData< DATA >::merge().
| const std::string & NamedData< DATA >::name | ( | unsigned int | i | ) | const [inline] |
Name of object at index.
References AssertIndexRange, NamedData< DATA >::names, and NamedData< DATA >::size().
Referenced by MeshWorker::Assembler::CellsAndFaces< number >::initialize(), NamedData< DATA >::merge(), and MeshWorker::VectorSelector::print().
| unsigned int NamedData< DATA >::find | ( | const std::string & | name | ) | const [inline] |
Find index of a named object.
References numbers::invalid_unsigned_int, and NamedData< DATA >::names.
Referenced by NamedSelection::initialize().
Returns true if this object contains constant data.
References NamedData< DATA >::is_constant.
Referenced by NamedData< DATA >::merge(), and NamedData< DATA >::operator=().
| void NamedData< DATA >::print | ( | OUT & | o | ) | const [inline] |
| ::ExceptionBase& NamedData< DATA >::ExcNameMismatch | ( | int | arg1, | |
| std::string | arg2 | |||
| ) | throw (errortext << "Name at position " << arg1 << " is not equal to " << arg2 ) [static] |
Exception indicating that a function expected a vector to have a certain name, but NamedData had a different name in that position.
| ::ExceptionBase& NamedData< DATA >::ExcConstantObject | ( | ) | [static] |
Exception indicating that read access to stored data was attempted although the NamedData object contains const data and is_constant was true.
Referenced by NamedData< DATA >::add(), NamedData< DATA >::merge(), and NamedData< DATA >::operator()().
bool NamedData< DATA >::is_constant [private] |
True if the object is to be treated constant.
Referenced by NamedData< DATA >::add(), NamedData< DATA >::is_const(), NamedData< DATA >::merge(), NamedData< DATA >::operator()(), and NamedData< DATA >::operator=().
The actual data stored.
Referenced by NamedData< DATA >::add(), NamedData< DATA >::merge(), NamedData< DATA >::operator()(), NamedData< DATA >::read(), and NamedData< DATA >::size().
Names for the data.
Referenced by NamedData< DATA >::add(), NamedData< DATA >::find(), NamedData< DATA >::merge(), NamedData< DATA >::name(), and NamedData< DATA >::print().
documentation generated on Sun Sep 5 23:06:36 2010 by
doxygen
1.5.6