Skip to content

Commit

Permalink
AI: deployed typesafe_aspect_ptr consistently
Browse files Browse the repository at this point in the history
No reason this couldn't have used aspect_type<t>typesafe_ptr before, so this just
makes uses of this specific type easier to find.

(cherry-picked from commit 1e846ac)
  • Loading branch information
Vultraz committed Oct 7, 2018
1 parent fcf3584 commit 2417af2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions src/ai/composite/aspect.hpp
Expand Up @@ -212,14 +212,14 @@ class composite_aspect;
template<typename T>
class typesafe_known_aspect : public known_aspect {
public:
typesafe_known_aspect(const std::string &name, std::shared_ptr< typesafe_aspect<T>> &where, aspect_map &aspects)
typesafe_known_aspect(const std::string &name, typesafe_aspect_ptr<T>& where, aspect_map &aspects)
: known_aspect(name), where_(where), aspects_(aspects)
{
}

void set(aspect_ptr a)
{
std::shared_ptr< typesafe_aspect <T>> c = std::dynamic_pointer_cast< typesafe_aspect<T>>(a);
typesafe_aspect_ptr<T> c = std::dynamic_pointer_cast<typesafe_aspect<T>>(a);
if (c) {
assert (c->get_id()== this->get_name());
where_ = c;
Expand All @@ -242,9 +242,8 @@ class typesafe_known_aspect : public known_aspect {
}

protected:
std::shared_ptr<typesafe_aspect <T>> &where_;
typesafe_aspect_ptr<T>& where_;
aspect_map &aspects_;

};


Expand Down
2 changes: 1 addition & 1 deletion src/ai/contexts.cpp
Expand Up @@ -174,7 +174,7 @@ synced_command_result_ptr readonly_context_impl::check_synced_command_action(con


template<typename T>
void readonly_context_impl::add_known_aspect(const std::string &name, std::shared_ptr< typesafe_aspect <T>> &where)
void readonly_context_impl::add_known_aspect(const std::string &name, typesafe_aspect_ptr<T>& where)
{
std::shared_ptr< typesafe_known_aspect <T>> ka_ptr(new typesafe_known_aspect<T>(name,where,aspects_));
known_aspects_.emplace(name,ka_ptr);
Expand Down
2 changes: 1 addition & 1 deletion src/ai/contexts.hpp
Expand Up @@ -1489,7 +1489,7 @@ class readonly_context_impl : public virtual side_context_proxy, public readonly

private:
template<typename T>
void add_known_aspect(const std::string &name, std::shared_ptr< typesafe_aspect <T>>& where);
void add_known_aspect(const std::string &name, typesafe_aspect_ptr<T>& where);

const config cfg_;

Expand Down

0 comments on commit 2417af2

Please sign in to comment.