Skip to content

Commit

Permalink
Merge pull request #25 from sgodwincs/master
Browse files Browse the repository at this point in the history
Add component checking.
  • Loading branch information
vittorioromeo authored Jan 8, 2017
2 parents 8443c41 + e72c619 commit da13a6b
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/ecst/context/data/defer/proxy/proxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ ECST_CONTEXT_NAMESPACE
template <typename TComponentTag>
decltype(auto) get_component(TComponentTag, entity_id);

template <typename TComponentTag>
auto has_component(TComponentTag, entity_id) const noexcept;

template <typename TComponentTag>
void remove_component(TComponentTag, entity_id) noexcept;

Expand Down
8 changes: 8 additions & 0 deletions include/ecst/context/data/defer/proxy/proxy.inl
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ ECST_CONTEXT_NAMESPACE
return _context.get_component(ct, eid);
}

template <typename TSettings>
template <typename TComponentTag>
auto proxy<TSettings>::has_component(
TComponentTag ct, entity_id eid) const noexcept
{
return _context.has_component(ct, eid);
}

template <typename TSettings>
template <typename TComponentTag>
void proxy<TSettings>::remove_component(
Expand Down
7 changes: 7 additions & 0 deletions include/ecst/context/data/main_storage/main_storage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ ECST_CONTEXT_NAMESPACE
template <typename TComponent>
decltype(auto) get_component(entity_id) noexcept;

template <typename TComponentTag>
auto has_component(entity_id) const noexcept;

template <typename TComponent>
void remove_component(entity_id) noexcept;

Expand All @@ -48,6 +51,7 @@ ECST_CONTEXT_NAMESPACE

public:
auto& metadata(entity_id) noexcept;
auto& metadata(entity_id) const noexcept;
auto valid_handle(const handle& h) const noexcept;

entity_id create_entity();
Expand All @@ -62,6 +66,9 @@ ECST_CONTEXT_NAMESPACE
template <typename TComponentTag>
decltype(auto) get_component(TComponentTag, entity_id) noexcept;

template <typename TComponentTag>
auto has_component(TComponentTag, entity_id) const noexcept;

template <typename TComponentTag>
void remove_component(TComponentTag, entity_id) noexcept;

Expand Down
22 changes: 22 additions & 0 deletions include/ecst/context/data/main_storage/main_storage.inl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ ECST_CONTEXT_NAMESPACE
return _entity_storage.get_metadata(eid);
}

template <typename TSettings>
auto& ECST_PURE_FN main_storage<TSettings>::metadata(
entity_id eid) const noexcept
{
return _entity_storage.get_metadata(eid);
}

template <typename TSettings>
auto main_storage<TSettings>::valid_handle(const handle& h) const
noexcept
Expand Down Expand Up @@ -74,6 +81,13 @@ ECST_CONTEXT_NAMESPACE
_component_storage, eid);
}

template <typename TSettings>
template <typename TComponent>
auto main_storage<TSettings>::has_component(entity_id eid) const noexcept
{
return metadata(eid).template has_component<TComponent>();
}

template <typename TSettings>
template <typename TComponent>
void main_storage<TSettings>::remove_component(entity_id eid) noexcept
Expand All @@ -97,6 +111,14 @@ ECST_CONTEXT_NAMESPACE
return get_component<component_from_tag<TComponentTag>>(eid);
}

template <typename TSettings>
template <typename TComponentTag>
auto main_storage<TSettings>::has_component(
TComponentTag, entity_id eid) const noexcept
{
return has_component<component_from_tag<TComponentTag>>(eid);
}

template <typename TSettings>
template <typename TComponentTag>
void main_storage<TSettings>::remove_component(
Expand Down
3 changes: 3 additions & 0 deletions include/ecst/context/system/instance/data_proxy/impl/base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ ECST_CONTEXT_SYSTEM_NAMESPACE
template <typename TComponentTag>
decltype(auto) get(TComponentTag ct, entity_id eid) noexcept;

template<typename TComponentTag>
auto has(TComponentTag ct, entity_id eid) const noexcept;

template <typename TF>
void defer(TF&& f);

Expand Down
8 changes: 8 additions & 0 deletions include/ecst/context/system/instance/data_proxy/impl/base.inl
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ ECST_CONTEXT_SYSTEM_NAMESPACE
})(_context);
}

ECST_IMPL_DP_BASE_TEMPLATE
template <typename TComponentTag>
auto ECST_IMPL_DP_BASE::has(
TComponentTag ct, entity_id eid) const noexcept
{
return _context.has_component(ct, eid);
}

ECST_IMPL_DP_BASE_TEMPLATE
template <typename TF>
void ECST_IMPL_DP_BASE::defer(TF&& f)
Expand Down

0 comments on commit da13a6b

Please sign in to comment.