Skip to content
Snippets Groups Projects
Commit f33804e8 authored by Tom Fischer's avatar Tom Fischer
Browse files

[ML] PropertyVector: add docu.

parent 6c406362
No related branches found
No related tags found
No related merge requests found
/**
* \file
* \brief Definition of the class Properties that implements a container of
* properties.
*
* \copyright
* Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org)
......@@ -22,6 +19,10 @@
namespace MeshLib
{
/// Class template PropertyVector is a std::vector with template parameter
/// PROP_VAL_TYPE. The reason for the derivation of std::vector is
/// the template specialisation for pointer types below.
/// \tparam PROP_VAL_TYPE typical this is a scalar, a vector or a matrix
template <typename PROP_VAL_TYPE>
class PropertyVector : public std::vector<PROP_VAL_TYPE>
{
......@@ -35,16 +36,32 @@ public:
{}
};
/// Class template PropertyVector is a std::vector with template parameter
/// T, where T is a pointer type.
/// The behaviour has changed for the constructor, destructor and the operator[].
/// The user has to provide the size and an item to group mapping for construction.
/// The destructor takes care to delete the entries of the vector.
/// The operator[] uses an item to group property map to access to the
/// correct property.
/// \tparam T pointer type, the type the type points to is typical a scalar,
/// a vector or a matrix type
template <typename T>
class PropertyVector<T*> : public std::vector<T*>
{
public:
/// @param n_prop_groups number of different property values
/// @param item2group_mapping Class Mesh has a mapping from the mesh items
/// (Node or Element) to an index (position in the data structure).
/// The vector item2group_mapping must have the same number of entries as
/// the above mapping and the values have to be in the range
/// \f$[0, \text{n_prop_groups})\f$.
PropertyVector(std::size_t n_prop_groups,
std::vector<std::size_t> const& item2group_mapping)
: std::vector<T*>(n_prop_groups),
_item2group_mapping(item2group_mapping)
{}
/// Destructor ensures the deletion of the heap-constructed objects.
~PropertyVector()
{
std::for_each(
......@@ -52,6 +69,8 @@ public:
);
}
/// The operator[] uses the item to group property map to access to the
/// correct property value/object.
T* const& operator[](std::size_t id) const
{
return (*static_cast<std::vector<T*> const*>(this))[_item2group_mapping[id]];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment