Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ObjectList inheritance #2582

Merged
merged 1 commit into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions Sming/Core/Data/LinkedObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ class LinkedObject
return mNext;
}

LinkedObject* getNext() const
{
return mNext;
}

bool insertAfter(LinkedObject* object)
{
if(object == nullptr) {
Expand Down Expand Up @@ -84,7 +79,7 @@ template <typename ObjectType> class LinkedObjectTemplate : public LinkedObject

IteratorTemplate& operator++()
{
mObject = mObject->getNext();
this->mObject = static_cast<TPtr>(this->mObject->next());
return *this;
}

Expand Down Expand Up @@ -129,7 +124,7 @@ template <typename ObjectType> class LinkedObjectTemplate : public LinkedObject

ObjectType* getNext() const
{
return reinterpret_cast<ObjectType*>(this->next());
return static_cast<ObjectType*>(this->next());
}

bool insertAfter(ObjectType* object)
Expand Down
14 changes: 10 additions & 4 deletions Sming/Core/Data/LinkedObjectList.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ class LinkedObjectList
template <typename ObjectType> class LinkedObjectListTemplate : public LinkedObjectList
{
public:
using Iterator =
typename LinkedObjectTemplate<ObjectType>::template IteratorTemplate<ObjectType, ObjectType*, ObjectType&>;
using ConstIterator =
typename LinkedObjectTemplate<ObjectType>::template IteratorTemplate<const ObjectType, const ObjectType*,
const ObjectType&>;

LinkedObjectListTemplate() = default;

LinkedObjectListTemplate(ObjectType* object) : LinkedObjectList(object)
Expand All @@ -105,22 +111,22 @@ template <typename ObjectType> class LinkedObjectListTemplate : public LinkedObj
return reinterpret_cast<const ObjectType*>(mHead);
}

typename ObjectType::Iterator begin()
Iterator begin()
{
return head();
}

typename ObjectType::Iterator end()
Iterator end()
{
return nullptr;
}

typename ObjectType::ConstIterator begin() const
ConstIterator begin() const
{
return head();
}

typename ObjectType::ConstIterator end() const
ConstIterator end() const
{
return nullptr;
}
Expand Down