-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
97 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#pragma once | ||
|
||
#include "CmptPtr.h" | ||
#include "CmptType.h" | ||
|
||
#include <set> | ||
|
||
namespace Ubpa { | ||
class EntityLocator; | ||
class RTDCmptViewer { | ||
public: | ||
class Iterator /*: public std::iterator<std::forward_iterator_tag, CmptPtr>*/ { | ||
public: | ||
using iterator_category = std::forward_iterator_tag; | ||
using value_type = CmptPtr; | ||
using difference_type = std::ptrdiff_t; | ||
using pointer = CmptPtr*; | ||
using reference = CmptPtr&; | ||
|
||
Iterator(std::set<CmptType>::iterator typeIter = std::set<CmptType>::iterator{}, void** ptr_cmpt = nullptr) | ||
: typeIter(typeIter), ptr_cmpt{ ptr_cmpt } {} | ||
bool operator==(const Iterator& rhs) const noexcept { | ||
return ptr_cmpt == rhs.ptr_cmpt; | ||
} | ||
bool operator!=(const Iterator& rhs) const noexcept { | ||
return !this->operator==(rhs); | ||
} | ||
CmptPtr operator*() const noexcept { return cmptptr; } | ||
const CmptPtr* operator->() const noexcept { | ||
cmptptr = { *typeIter, *ptr_cmpt }; | ||
return &cmptptr; | ||
} | ||
Iterator& operator++() { | ||
typeIter++; | ||
ptr_cmpt++; | ||
return *this; | ||
} | ||
private: | ||
std::set<CmptType>::iterator typeIter; | ||
void** ptr_cmpt; | ||
mutable CmptPtr cmptptr{ CmptType::Invalid(), nullptr }; | ||
}; | ||
|
||
RTDCmptViewer(EntityLocator* locator, void** cmpts) | ||
: locator{ locator }, cmpts{ cmpts }{} | ||
|
||
Iterator begin() const noexcept; | ||
Iterator end() const noexcept; | ||
|
||
const std::set<CmptType>& CmptTypes() const noexcept; | ||
void* const* Components() const noexcept { return cmpts; } | ||
|
||
private: | ||
EntityLocator* locator; | ||
void** cmpts; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include <UECS/RTDCmptViewer.h> | ||
|
||
#include <UECS/EntityLocator.h> | ||
|
||
using namespace Ubpa; | ||
using namespace std; | ||
|
||
RTDCmptViewer::Iterator RTDCmptViewer::begin() const noexcept { | ||
return { locator->CmptTypes().begin(), cmpts }; | ||
} | ||
|
||
RTDCmptViewer::Iterator RTDCmptViewer::end() const noexcept { | ||
return { locator->CmptTypes().end(), cmpts + locator->CmptTypes().size() }; | ||
} | ||
|
||
const set<CmptType>& RTDCmptViewer::CmptTypes() const noexcept { | ||
return locator->CmptTypes(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters