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

[MeL] Move common attributes / methods to base class.

parent f1651e63
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,23 @@ public:
std::vector<std::size_t> const& exclude_positions
) const = 0;
virtual ~PropertyVectorBase() = default;
MeshItemType getMeshItemType() const { return _mesh_item_type; }
std::string const& getPropertyName() const { return _property_name; }
std::size_t getNumberOfComponents() const { return _n_components; }
protected:
PropertyVectorBase(std::string const& property_name,
MeshItemType mesh_item_type,
std::size_t n_components)
: _n_components(n_components),
_mesh_item_type(mesh_item_type),
_property_name(property_name)
{}
std::size_t const _n_components;
MeshItemType const _mesh_item_type;
std::string const _property_name;
};
/// Class template PropertyVector is a std::vector with template parameter
......@@ -44,13 +61,10 @@ class PropertyVector : public std::vector<PROP_VAL_TYPE>,
friend class Properties;
public:
std::size_t getNumberOfComponents() const { return _n_components; }
std::size_t getNumberOfTuples() const
{
return std::vector<PROP_VAL_TYPE>::size() / _n_components;
}
MeshItemType getMeshItemType() const { return _mesh_item_type; }
std::string const& getPropertyName() const { return _property_name; }
PropertyVectorBase* clone(std::vector<std::size_t> const& exclude_positions) const
{
......@@ -76,9 +90,7 @@ protected:
MeshItemType mesh_item_type,
std::size_t n_components)
: std::vector<PROP_VAL_TYPE>(),
_n_components(n_components),
_mesh_item_type(mesh_item_type),
_property_name(property_name)
PropertyVectorBase(property_name, mesh_item_type, n_components)
{}
/// @brief The constructor taking meta information for the data.
......@@ -93,13 +105,8 @@ protected:
MeshItemType mesh_item_type,
std::size_t n_components)
: std::vector<PROP_VAL_TYPE>(n_property_values * n_components),
_mesh_item_type(mesh_item_type),
_property_name(property_name)
PropertyVectorBase(property_name, mesh_item_type, n_components)
{}
std::size_t const _n_components;
MeshItemType const _mesh_item_type;
std::string const _property_name;
};
/// Class template PropertyVector is a std::vector with template parameter
......@@ -141,7 +148,6 @@ public:
_values[group_id] = new T(value);
}
std::size_t getNumberOfComponents() const { return _n_components; }
std::size_t getNumberOfTuples() const
{
return std::vector<std::size_t>::size();
......@@ -151,8 +157,6 @@ public:
{
return _n_components * std::vector<std::size_t>::size();
}
MeshItemType getMeshItemType() const { return _mesh_item_type; }
std::string const& getPropertyName() const { return _property_name; }
PropertyVectorBase* clone(std::vector<std::size_t> const& exclude_positions) const
{
......@@ -204,17 +208,10 @@ protected:
MeshItemType mesh_item_type,
std::size_t n_components)
: std::vector<std::size_t>(item2group_mapping),
_n_components(n_components),
_mesh_item_type(mesh_item_type),
_property_name(property_name),
PropertyVectorBase(property_name, mesh_item_type, n_components),
_values(n_prop_groups * n_components)
{}
protected:
std::size_t const _n_components;
MeshItemType const _mesh_item_type;
std::string const _property_name;
private:
std::vector<T*> _values;
// hide method
......
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