Skip to content
Snippets Groups Projects
Commit 50a3024a authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[GL] Update interfaces to unique_ptr usage.

parent 682e10f2
No related branches found
No related tags found
No related merge requests found
...@@ -22,11 +22,11 @@ ...@@ -22,11 +22,11 @@
namespace GeoLib namespace GeoLib
{ {
PointVec::PointVec(const std::string& name, PointVec::PointVec(
std::unique_ptr<std::vector<Point*>> points, const std::string& name, std::unique_ptr<std::vector<Point*>> points,
std::map<std::string, std::size_t>* name_id_map, std::unique_ptr<std::map<std::string, std::size_t>> name_id_map,
PointType type, double rel_eps) PointType type, double rel_eps)
: TemplateVec<Point>(name, std::move(points), name_id_map), : TemplateVec<Point>(name, std::move(points), std::move(name_id_map)),
_type(type), _type(type),
_aabb(_data_vec->begin(), _data_vec->end()), _aabb(_data_vec->begin(), _data_vec->end()),
_rel_eps(rel_eps * std::sqrt(MathLib::sqrDist(_aabb.getMinPoint(), _rel_eps(rel_eps * std::sqrt(MathLib::sqrDist(_aabb.getMinPoint(),
......
...@@ -66,9 +66,13 @@ public: ...@@ -66,9 +66,13 @@ public:
* real tolerance \f$tol\f$. Two points \f$p_0, p_1 \f$ are identical iff * real tolerance \f$tol\f$. Two points \f$p_0, p_1 \f$ are identical iff
* \f$|p_1 - p_0| \le tol.\f$ * \f$|p_1 - p_0| \le tol.\f$
*/ */
PointVec (const std::string& name, std::unique_ptr<std::vector<Point*>> points, PointVec(const std::string& name,
std::map<std::string, std::size_t>* name_id_map = nullptr, std::unique_ptr<std::vector<Point*>>
PointType type = PointVec::PointType::POINT, double rel_eps = std::numeric_limits<double>::epsilon()); points,
std::unique_ptr<std::map<std::string, std::size_t>> name_id_map =
nullptr,
PointType type = PointVec::PointType::POINT,
double rel_eps = std::numeric_limits<double>::epsilon());
/** /**
* Method adds a Point to the (internal) standard vector and takes the ownership. * Method adds a Point to the (internal) standard vector and takes the ownership.
......
...@@ -58,10 +58,10 @@ public: ...@@ -58,10 +58,10 @@ public:
* the data_vec. * the data_vec.
*/ */
TemplateVec(std::string name, std::unique_ptr<std::vector<T*>> data_vec, TemplateVec(std::string name, std::unique_ptr<std::vector<T*>> data_vec,
NameIdMap* elem_name_map = nullptr) std::unique_ptr<NameIdMap> elem_name_map = nullptr)
: _name(std::move(name)), : _name(std::move(name)),
_data_vec(std::move(data_vec)), _data_vec(std::move(data_vec)),
_name_id_map(elem_name_map) _name_id_map(std::move(elem_name_map))
{ {
if (_data_vec == nullptr) if (_data_vec == nullptr)
{ {
...@@ -69,7 +69,7 @@ public: ...@@ -69,7 +69,7 @@ public:
} }
if (!_name_id_map) if (!_name_id_map)
_name_id_map = new NameIdMap; _name_id_map.reset(new NameIdMap);
} }
/** /**
...@@ -78,7 +78,6 @@ public: ...@@ -78,7 +78,6 @@ public:
virtual ~TemplateVec () virtual ~TemplateVec ()
{ {
for (std::size_t k(0); k < size(); k++) delete (*_data_vec)[k]; for (std::size_t k(0); k < size(); k++) delete (*_data_vec)[k];
delete _name_id_map;
} }
/** sets the name of the vector of geometric objects /** sets the name of the vector of geometric objects
...@@ -238,6 +237,6 @@ protected: ...@@ -238,6 +237,6 @@ protected:
/** /**
* store names associated with the element ids * store names associated with the element ids
*/ */
NameIdMap* _name_id_map; std::unique_ptr<NameIdMap> _name_id_map;
}; };
} // end namespace GeoLib } // end namespace GeoLib
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