X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgame%2Faccessguard.h;h=2d9a3053b8324a8e06abdb8713f8469bd5907d84;hb=12c863fc1bc5456a4b3aceacc88904d76bd1d8bb;hp=26bbb4e0e99b3d7bb896c6376e7e1d22f9fae827;hpb=ffbfe95f51058c4de3c898b1a02e2fadba2b8134;p=libs%2Fgame.git diff --git a/source/game/accessguard.h b/source/game/accessguard.h index 26bbb4e..2d9a305 100644 --- a/source/game/accessguard.h +++ b/source/game/accessguard.h @@ -7,17 +7,18 @@ #include #include #include +#include "mspgame_api.h" namespace Msp::Game { -class invalid_access: public std::logic_error +class MSPGAME_API invalid_access: public std::logic_error { public: invalid_access(const std::string &w): logic_error(w) { } }; -class AccessGuard +class MSPGAME_API AccessGuard { public: struct Create { static std::string describe() { return "create"; } }; @@ -69,7 +70,7 @@ public: void unblock() { get() = UNBLOCKED; } template - void check() { if(get()!=UNBLOCKED) throw invalid_access(T::describe()); } + void check(); }; @@ -97,6 +98,14 @@ template<> inline void AccessGuard::unblock() { unblock_all(); } +template +inline void AccessGuard::check() +{ + unsigned index = get_index(); + if((index inline std::string AccessGuard::Read::describe()