From 810ed7c064ff5530bd0b3587f7b01e02ee867874 Mon Sep 17 00:00:00 2001 From: Eberhard Graether Date: Wed, 16 Jul 2014 11:54:16 +0200 Subject: [PATCH] build: fixed errors in clang * removed const m_dimensions in VectorBase and replaced it with N * changed signature of DummyNode::operator= * fixed warning for DummyNode wrongly declared as class --- src/lib/component/controller/GraphLayouter.h | 2 +- .../component/view/graphElements/GraphNode.h | 3 +- src/lib/utility/math/VectorBase.h | 40 +++++++------------ 3 files changed, 18 insertions(+), 27 deletions(-) diff --git a/src/lib/component/controller/GraphLayouter.h b/src/lib/component/controller/GraphLayouter.h index 58e5a284..f2f3050d 100644 --- a/src/lib/component/controller/GraphLayouter.h +++ b/src/lib/component/controller/GraphLayouter.h @@ -3,7 +3,7 @@ #include -class DummyNode; +struct DummyNode; typedef void (*LayoutFunction)(std::vector&); diff --git a/src/lib/component/view/graphElements/GraphNode.h b/src/lib/component/view/graphElements/GraphNode.h index 9281579b..67126dd3 100644 --- a/src/lib/component/view/graphElements/GraphNode.h +++ b/src/lib/component/view/graphElements/GraphNode.h @@ -76,13 +76,14 @@ public: return !(*this < other); } - void operator=(DummyNode& other) + DummyNode& operator=(const DummyNode& other) { name = other.name; tokenId = other.tokenId; position = other.position; subNodes = other.subNodes; actualNode = other.actualNode; + return *this; } std::string name; diff --git a/src/lib/utility/math/VectorBase.h b/src/lib/utility/math/VectorBase.h index 9a8bf73e..ec71ac30 100644 --- a/src/lib/utility/math/VectorBase.h +++ b/src/lib/utility/math/VectorBase.h @@ -94,41 +94,36 @@ protected: private: inline void checkIndexInRange(unsigned int index, const std::string& function) const { - if (index >= m_dimensions) + if (index >= N) { std::stringstream message; - message << function << ": index " << index << " is out of range, maximum is " << m_dimensions - 1; + message << function << ": index " << index << " is out of range, maximum is " << N - 1; throw std::range_error(message.str()); } } inline void setValues(const T values[N]) { - for (unsigned int i = 0; i < m_dimensions; i++) + for (unsigned int i = 0; i < N; i++) { m_values[i] = values[i]; } } - - const unsigned int m_dimensions; }; template VectorBase::VectorBase() - : m_dimensions(N) {} template VectorBase::VectorBase(const T values[N]) - : m_dimensions(N) { setValues(values); } template VectorBase::VectorBase(const VectorBase& vector) - : m_dimensions(vector.m_dimensions) { setValues(vector.m_values); } @@ -157,7 +152,7 @@ void VectorBase::setValue(const unsigned int index, const T& value) template unsigned int VectorBase::getDimensions() const { - return m_dimensions; + return N; } template @@ -165,7 +160,7 @@ float VectorBase::getLengthSquared() const { float result = 0.0f; - for (unsigned int i = 0; i < m_dimensions; i++) + for (unsigned int i = 0; i < N; i++) { result += float(m_values[i] * m_values[i]); } @@ -187,7 +182,7 @@ VectorBase VectorBase::normalize() if (length > 0.0f) { T tmpValues[N]; - for (unsigned int i = 0; i < m_dimensions; i++) + for (unsigned int i = 0; i < N; i++) { tmpValues[i] = m_values[i] / length; } @@ -208,14 +203,14 @@ VectorBase VectorBase::normalized() const if (length > 0.0f) { - for (unsigned int i = 0; i < m_dimensions; i++) + for (unsigned int i = 0; i < N; i++) { tmpValues[i] = m_values[i] / length; } } else { - for (unsigned int i = 0; i < m_dimensions; i++) + for (unsigned int i = 0; i < N; i++) { tmpValues[i] = 0; } @@ -246,7 +241,7 @@ template VectorBase VectorBase::add(const VectorBase& other) { T tmpValues[N]; - for (unsigned int i = 0; i < m_dimensions; i++) + for (unsigned int i = 0; i < N; i++) { tmpValues[i] = m_values[i] + other.m_values[i]; } @@ -261,7 +256,7 @@ template VectorBase VectorBase::subtract(const VectorBase& other) { T tmpValues[N]; - for (unsigned int i = 0; i < m_dimensions; i++) + for (unsigned int i = 0; i < N; i++) { tmpValues[i] = m_values[i] - other.m_values[i]; } @@ -276,7 +271,7 @@ template VectorBase VectorBase::scalarMultiplication(const U& scalar) { T tmpValues[N]; - for (unsigned int i = 0; i < m_dimensions; i++) + for (unsigned int i = 0; i < N; i++) { tmpValues[i] = m_values[i] * scalar; } @@ -291,7 +286,7 @@ template T VectorBase::dotProduct(const VectorBase& other) { T result = 0.0f; - for (unsigned int i = 0; i < m_dimensions; i++) + for (unsigned int i = 0; i < N; i++) { result += (m_values[i] * other.m_values[i]); } @@ -302,12 +297,7 @@ template template bool VectorBase::isEqual(const VectorBase& other) const { - if (m_dimensions != other.m_dimensions) - { - return false; - } - - for (unsigned int i = 0; i < m_dimensions; i++) + for (unsigned int i = 0; i < N; i++) { if (m_values[i] != other.m_values[i]) { @@ -427,11 +417,11 @@ std::string VectorBase::toString() const std::stringstream result; result << "["; - for (unsigned int i = 0; i < m_dimensions - 1; i++) + for (unsigned int i = 0; i < N - 1; i++) { result << m_values[i] << ", "; } - result << m_values[m_dimensions - 1] << "]"; + result << m_values[N - 1] << "]"; return result.str(); }