Skip to content

Commit

Permalink
constexpr CmptType
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubpa committed Jul 30, 2020
1 parent 1c51806 commit adf2b13
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions doc/todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
- [x] lock `FilterChange`
- [ ] `EntityMngr` `Query`-driven API
- [x] `RTDCmptsView` = `const EntityLocator* locator + void** cmpts`
- [ ] Filter Builder

### maybe deprecate

Expand Down
2 changes: 1 addition & 1 deletion include/UECS/CmptTag.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Ubpa::UECS {
class LastFrame {
public:
LastFrame(const Cmpt* cmpt) noexcept : cmpt{ cmpt } {}
const Cmpt* get() const noexcept { return cmpt; }
const Cmpt* Get() const noexcept { return cmpt; }
operator const Cmpt* () const noexcept { return cmpt; }
const Cmpt* operator->() const noexcept { return cmpt; }
private:
Expand Down
8 changes: 4 additions & 4 deletions include/UECS/CmptType.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ namespace Ubpa::UECS {
static constexpr CmptType Invalid() noexcept { return CmptType{ static_cast<size_t>(-1) }; }

template<typename Cmpt>
bool Is() const noexcept { return hashcode == TypeID<Cmpt>; }
constexpr bool Is() const noexcept { return hashcode == TypeID<Cmpt>; }

bool operator<(const CmptType& rhs) const noexcept { return hashcode < rhs.hashcode; }
bool operator==(const CmptType& rhs) const noexcept { return hashcode == rhs.hashcode; }
bool operator!=(const CmptType& rhs) const noexcept { return hashcode != rhs.hashcode; }
constexpr bool operator<(const CmptType& rhs) const noexcept { return hashcode < rhs.hashcode; }
constexpr bool operator==(const CmptType& rhs) const noexcept { return hashcode == rhs.hashcode; }
constexpr bool operator!=(const CmptType& rhs) const noexcept { return hashcode != rhs.hashcode; }
private:
size_t hashcode;
};
Expand Down
4 changes: 2 additions & 2 deletions include/UECS/SystemMngr.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ namespace Ubpa::UECS{
bool IsRegister(std::string_view name) const {
return onUpdateMap.find(name) != onUpdateMap.end();
}
void Deregister(const std::string& name) {
onUpdateMap.erase(name);
void Deregister(std::string_view name) {
onUpdateMap.erase(onUpdateMap.find(name));
}

template<typename... Systems>
Expand Down

0 comments on commit adf2b13

Please sign in to comment.