X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgame%2Fcomponent.h;h=6406cb5743e3f417f0cb7f27a08c92e439aecef8;hb=e4f03880d49bdbe0c7269be0f40f23b197bcea77;hp=44927ffd2e73c640f9d8a609f4e4b66984633572;hpb=a99b57a74252fd3de649d544d070b747f91fcf4d;p=libs%2Fgame.git diff --git a/source/game/component.h b/source/game/component.h index 44927ff..6406cb5 100644 --- a/source/game/component.h +++ b/source/game/component.h @@ -2,6 +2,7 @@ #define MSP_GAME_COMPONENT_H_ #include +#include "accessguard.h" #include "handle.h" namespace Msp::Game { @@ -34,7 +35,7 @@ protected: BufferedComponent(Handle e): Component(e) { } - const T &read() const { return data[read_index]; } + const T &read() const; T &write(); public: @@ -42,9 +43,21 @@ public: virtual void commit_tick() { if(written) read_index = write_index; } }; +template +const T &BufferedComponent::read() const +{ +#ifdef DEBUG + AccessGuard::get_instance().check>(); +#endif + return data[read_index]; +} + template T &BufferedComponent::write() { +#ifdef DEBUG + AccessGuard::get_instance().check>(); +#endif if(!written && write_index!=read_index) { data[write_index] = data[read_index];