Skip to content

Commit

Permalink
Renames m_self to m_impl consistent with...
Browse files Browse the repository at this point in the history
- World class's member variable of same purpose.
- Being a pointer to an *implementation*.
  • Loading branch information
louis-langholtz committed Oct 31, 2023
1 parent 436c388 commit de33188
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 73 deletions.
46 changes: 23 additions & 23 deletions Library/include/playrho/d2/Joint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,15 @@ class Joint

/// @brief Copy constructor.
/// @details This constructor copies all the details of \a other.
Joint(const Joint& other) : m_self{other.m_self ? other.m_self->Clone_() : nullptr}
Joint(const Joint& other) : m_impl{other.m_impl ? other.m_impl->Clone_() : nullptr}
{
// Intentionally empty.
}

/// @brief Move constructor.
/// @details This constructor moves all the details of \a other into <code>*this</code> and
/// leaves \a other in the default constructed state.
Joint(Joint&& other) noexcept : m_self{std::move(other.m_self)}
Joint(Joint&& other) noexcept : m_impl{std::move(other.m_impl)}
{
// Intentionally empty.
}
Expand Down Expand Up @@ -212,7 +212,7 @@ class Joint
/// @see https://foonathan.net/2015/10/overload-resolution-1/
template <typename T, typename Tp = DecayedTypeIfNotSame<T, Joint>,
typename = std::enable_if_t<std::is_constructible_v<Tp, T>>>
explicit Joint(T&& arg) : m_self{std::make_unique<detail::JointModel<Tp>>(std::forward<T>(arg))}
explicit Joint(T&& arg) : m_impl{std::make_unique<detail::JointModel<Tp>>(std::forward<T>(arg))}
{
// Intentionally empty.
}
Expand All @@ -221,7 +221,7 @@ class Joint
/// @details This operator copies all the details of \a other into <code>*this</code>.
Joint& operator=(const Joint& other)
{
m_self = other.m_self ? other.m_self->Clone_() : nullptr;
m_impl = other.m_impl ? other.m_impl->Clone_() : nullptr;
return *this;
}

Expand All @@ -230,7 +230,7 @@ class Joint
/// leaves \a other in the default constructed state.
Joint& operator=(Joint&& other) noexcept
{
m_self = std::move(other.m_self);
m_impl = std::move(other.m_impl);
return *this;
}

Expand All @@ -249,18 +249,18 @@ class Joint
/// @brief Swap function.
void swap(Joint& other) noexcept
{
std::swap(m_self, other.m_self);
std::swap(m_impl, other.m_impl);
}

/// @brief Checks whether this instance contains a value.
bool has_value() const noexcept
{
return static_cast<bool>(m_self);
return static_cast<bool>(m_impl);
}

friend TypeID GetType(const Joint& object) noexcept
{
return object.m_self ? object.m_self->GetType_() : GetTypeID<void>();
return object.m_impl ? object.m_impl->GetType_() : GetTypeID<void>();
}

template <typename T>
Expand All @@ -271,8 +271,8 @@ class Joint

friend bool operator==(const Joint& lhs, const Joint& rhs) noexcept
{
return (lhs.m_self == rhs.m_self) ||
((lhs.m_self && rhs.m_self) && (lhs.m_self->IsEqual_(*rhs.m_self)));
return (lhs.m_impl == rhs.m_impl) ||
((lhs.m_impl && rhs.m_impl) && (lhs.m_impl->IsEqual_(*rhs.m_impl)));
}

friend bool operator!=(const Joint& lhs, const Joint& rhs) noexcept
Expand All @@ -282,46 +282,46 @@ class Joint

friend BodyID GetBodyA(const Joint& object) noexcept
{
return object.m_self ? object.m_self->GetBodyA_() : InvalidBodyID;
return object.m_impl ? object.m_impl->GetBodyA_() : InvalidBodyID;
}

friend BodyID GetBodyB(const Joint& object) noexcept
{
return object.m_self ? object.m_self->GetBodyB_() : InvalidBodyID;
return object.m_impl ? object.m_impl->GetBodyB_() : InvalidBodyID;
}

friend bool GetCollideConnected(const Joint& object) noexcept
{
return object.m_self ? object.m_self->GetCollideConnected_() : false;
return object.m_impl ? object.m_impl->GetCollideConnected_() : false;
}

friend bool ShiftOrigin(Joint& object, const Length2& value) noexcept
{
return object.m_self ? object.m_self->ShiftOrigin_(value) : false;
return object.m_impl ? object.m_impl->ShiftOrigin_(value) : false;
}

friend void InitVelocity(Joint& object, const Span<BodyConstraint>& bodies,
const playrho::StepConf& step, const ConstraintSolverConf& conf)
{
if (object.m_self) {
object.m_self->InitVelocity_(bodies, step, conf);
if (object.m_impl) {
object.m_impl->InitVelocity_(bodies, step, conf);
}
}

friend bool SolveVelocity(Joint& object, const Span<BodyConstraint>& bodies,
const playrho::StepConf& step)
{
return object.m_self ? object.m_self->SolveVelocity_(bodies, step) : false;
return object.m_impl ? object.m_impl->SolveVelocity_(bodies, step) : false;
}

friend bool SolvePosition(const Joint& object, const Span<BodyConstraint>& bodies,
const ConstraintSolverConf& conf)
{
return object.m_self ? object.m_self->SolvePosition_(bodies, conf) : false;
return object.m_impl ? object.m_impl->SolvePosition_(bodies, conf) : false;
}

private:
std::unique_ptr<detail::JointConcept> m_self; ///< Self pointer.
std::unique_ptr<detail::JointConcept> m_impl; ///< Pointer to implementation.
};

// Traits...
Expand Down Expand Up @@ -433,8 +433,8 @@ inline std::add_pointer_t<std::add_const_t<T>> TypeCast(const Joint* value) noex
{
static_assert(!std::is_reference_v<T>, "T may not be a reference.");
using ReturnType = std::add_pointer_t<T>;
if (value && value->m_self && (GetType(*value) == GetTypeID<T>())) {
return static_cast<ReturnType>(value->m_self->GetData_());
if (value && value->m_impl && (GetType(*value) == GetTypeID<T>())) {
return static_cast<ReturnType>(value->m_impl->GetData_());
}
return nullptr;
}
Expand All @@ -444,8 +444,8 @@ inline std::add_pointer_t<T> TypeCast(Joint* value) noexcept
{
static_assert(!std::is_reference_v<T>, "T may not be a reference.");
using ReturnType = std::add_pointer_t<T>;
if (value && value->m_self && (GetType(*value) == GetTypeID<T>())) {
return static_cast<ReturnType>(value->m_self->GetData_());
if (value && value->m_impl && (GetType(*value) == GetTypeID<T>())) {
return static_cast<ReturnType>(value->m_impl->GetData_());
}
return nullptr;
}
Expand Down
Loading

0 comments on commit de33188

Please sign in to comment.