#define MSP_GAME_COMPONENT_H_
#include <msp/time/timedelta.h>
+#include "accessguard.h"
#include "handle.h"
namespace Msp::Game {
BufferedComponent(Handle<Entity> e): Component(e) { }
- const T &read() const { return data[read_index]; }
+ const T &read() const;
T &write();
public:
virtual void commit_tick() { if(written) read_index = write_index; }
};
+template<typename T>
+const T &BufferedComponent<T>::read() const
+{
+#ifdef DEBUG
+ AccessGuard::get_instance().check<AccessGuard::Read<T>>();
+#endif
+ return data[read_index];
+}
+
template<typename T>
T &BufferedComponent<T>::write()
{
+#ifdef DEBUG
+ AccessGuard::get_instance().check<AccessGuard::Write<T>>();
+#endif
if(!written && write_index!=read_index)
{
data[write_index] = data[read_index];