X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgame%2Fowned.h;h=fc2acab6ecb02ab0d4079630dae5f5fe5b8fc939;hb=48051ee2bab13f65e48c371e453b9ea65920921e;hp=b305ae21d1aea7f371ab5b9a661f00f09153841b;hpb=33aed7ee82844023346f8cb9c3108cb0d6c80369;p=libs%2Fgame.git diff --git a/source/game/owned.h b/source/game/owned.h index b305ae2..fc2acab 100644 --- a/source/game/owned.h +++ b/source/game/owned.h @@ -2,6 +2,7 @@ #define MSP_GAME_OWNED_H_ #include +#include "accessguard.h" #include "events.h" #include "handle.h" #include "stage.h" @@ -43,11 +44,15 @@ template template Owned::Owned(Handle

parent, Args &&... args) { +#ifdef DEBUG + AccessGuard::get_instance().check(); +#endif + if(!parent) throw std::invalid_argument("Owned::Owned"); Stage &stage = get_stage(*parent); - Pool &pool = stage.get_pools().template get_pool(); + Pool &pool = stage.get_pools().get_pool(); this->ptr = pool.create(parent, std::forward(args)...); if constexpr(std::is_base_of_v) { @@ -89,6 +94,10 @@ void Owned::destroy() if(!obj) return; +#ifdef DEBUG + AccessGuard::get_instance().check(); +#endif + Stage &stage = get_stage(*obj); if constexpr(std::is_base_of_v) @@ -102,7 +111,7 @@ void Owned::destroy() parent->remove_child(*this); } - Pool &pool = stage.get_pools().template get_pool(); + Pool &pool = stage.get_pools().get_pool(); pool.destroy(this->ptr); }