Formatted EVERYTHING
This commit is contained in:
@@ -1,25 +1,13 @@
|
||||
#pragma once
|
||||
#include <entt/entt.hpp>
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
template<typename T>
|
||||
struct Event
|
||||
{
|
||||
};
|
||||
class EventManager
|
||||
{
|
||||
public:
|
||||
template<typename T>
|
||||
void pushEvent(Event<T> event)
|
||||
{
|
||||
namespace Seele {
|
||||
template <typename T> struct Event {};
|
||||
class EventManager {
|
||||
public:
|
||||
template <typename T> void pushEvent(Event<T> event) {}
|
||||
template <typename T> void subscribe() {}
|
||||
|
||||
}
|
||||
template<typename T>
|
||||
void subscribe()
|
||||
{
|
||||
|
||||
}
|
||||
private:
|
||||
private:
|
||||
};
|
||||
} // namespace Seele
|
||||
|
||||
@@ -3,122 +3,102 @@
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
LightEnvironment::LightEnvironment(Gfx::PGraphics graphics)
|
||||
: graphics(graphics)
|
||||
{
|
||||
LightEnvironment::LightEnvironment(Gfx::PGraphics graphics) : graphics(graphics) {
|
||||
layout = graphics->createDescriptorLayout("pLightEnv");
|
||||
layout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 0, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER,});
|
||||
layout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 1, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,});
|
||||
layout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 2, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,});
|
||||
layout->addDescriptorBinding(Gfx::DescriptorBinding{
|
||||
.binding = 0,
|
||||
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
|
||||
});
|
||||
layout->addDescriptorBinding(Gfx::DescriptorBinding{
|
||||
.binding = 1,
|
||||
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
||||
});
|
||||
layout->addDescriptorBinding(Gfx::DescriptorBinding{
|
||||
.binding = 2,
|
||||
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
||||
});
|
||||
layout->create();
|
||||
lightEnvBuffer = graphics->createUniformBuffer(UniformBufferCreateInfo{
|
||||
.sourceData = {
|
||||
.size = sizeof(LightEnv),
|
||||
.data = (uint8*) &lightEnv,
|
||||
},
|
||||
.sourceData =
|
||||
{
|
||||
.size = sizeof(LightEnv),
|
||||
.data = (uint8*)&lightEnv,
|
||||
},
|
||||
.dynamic = true,
|
||||
});
|
||||
directionalLights = graphics->createShaderBuffer(ShaderBufferCreateInfo{
|
||||
.sourceData = {
|
||||
.size = sizeof(Component::DirectionalLight) * INIT_DIRECTIONAL_LIGHTS,
|
||||
.data = nullptr,
|
||||
},
|
||||
.sourceData =
|
||||
{
|
||||
.size = sizeof(Component::DirectionalLight) * INIT_DIRECTIONAL_LIGHTS,
|
||||
.data = nullptr,
|
||||
},
|
||||
.numElements = INIT_DIRECTIONAL_LIGHTS,
|
||||
.dynamic = true,
|
||||
});
|
||||
pointLights = graphics->createShaderBuffer(ShaderBufferCreateInfo{
|
||||
.sourceData = {
|
||||
.size = sizeof(Component::PointLight) * INIT_POINT_LIGHTS,
|
||||
.data = nullptr,
|
||||
},
|
||||
.sourceData =
|
||||
{
|
||||
.size = sizeof(Component::PointLight) * INIT_POINT_LIGHTS,
|
||||
.data = nullptr,
|
||||
},
|
||||
.numElements = INIT_POINT_LIGHTS,
|
||||
.dynamic = true,
|
||||
});
|
||||
}
|
||||
|
||||
LightEnvironment::~LightEnvironment()
|
||||
{
|
||||
}
|
||||
LightEnvironment::~LightEnvironment() {}
|
||||
|
||||
void LightEnvironment::reset()
|
||||
{
|
||||
void LightEnvironment::reset() {
|
||||
layout->reset();
|
||||
set = layout->allocateDescriptorSet();
|
||||
dirs.clear();
|
||||
points.clear();
|
||||
}
|
||||
|
||||
void LightEnvironment::addDirectionalLight(Component::DirectionalLight dirLight)
|
||||
{
|
||||
dirs.add(dirLight);
|
||||
}
|
||||
void LightEnvironment::addDirectionalLight(Component::DirectionalLight dirLight) { dirs.add(dirLight); }
|
||||
|
||||
void LightEnvironment::addPointLight(Component::PointLight pointLight)
|
||||
{
|
||||
points.add(pointLight);
|
||||
}
|
||||
void LightEnvironment::addPointLight(Component::PointLight pointLight) { points.add(pointLight); }
|
||||
|
||||
void LightEnvironment::commit()
|
||||
{
|
||||
lightEnvBuffer->pipelineBarrier(
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_ALL_COMMANDS_BIT,
|
||||
Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT
|
||||
);
|
||||
pointLights->pipelineBarrier(
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_ALL_COMMANDS_BIT,
|
||||
Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT
|
||||
);
|
||||
directionalLights->pipelineBarrier(
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_ALL_COMMANDS_BIT,
|
||||
Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT
|
||||
);
|
||||
void LightEnvironment::commit() {
|
||||
lightEnvBuffer->pipelineBarrier(Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_ALL_COMMANDS_BIT,
|
||||
Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT);
|
||||
pointLights->pipelineBarrier(Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_ALL_COMMANDS_BIT, Gfx::SE_ACCESS_TRANSFER_WRITE_BIT,
|
||||
Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT);
|
||||
directionalLights->pipelineBarrier(Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_ALL_COMMANDS_BIT,
|
||||
Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT);
|
||||
lightEnv.numDirectionalLights = dirs.size();
|
||||
lightEnv.numPointLights = points.size();
|
||||
lightEnvBuffer->updateContents(DataSource{
|
||||
.size = sizeof(LightEnv),
|
||||
.data = (uint8*) & lightEnv,
|
||||
});
|
||||
.data = (uint8*)&lightEnv,
|
||||
});
|
||||
directionalLights->rotateBuffer(sizeof(Component::DirectionalLight) * dirs.size());
|
||||
directionalLights->updateContents({
|
||||
.sourceData = {
|
||||
.size = sizeof(Component::DirectionalLight) * dirs.size(),
|
||||
.data = (uint8*)dirs.data(),
|
||||
},
|
||||
.sourceData =
|
||||
{
|
||||
.size = sizeof(Component::DirectionalLight) * dirs.size(),
|
||||
.data = (uint8*)dirs.data(),
|
||||
},
|
||||
.numElements = dirs.size(),
|
||||
});
|
||||
pointLights->rotateBuffer(sizeof(Component::PointLight) * points.size());
|
||||
pointLights->updateContents({
|
||||
.sourceData = {
|
||||
.size = sizeof(Component::PointLight) * points.size(),
|
||||
.data = (uint8*)points.data()
|
||||
},
|
||||
.sourceData = {.size = sizeof(Component::PointLight) * points.size(), .data = (uint8*)points.data()},
|
||||
.numElements = points.size(),
|
||||
});
|
||||
|
||||
lightEnvBuffer->pipelineBarrier(
|
||||
Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_ALL_COMMANDS_BIT
|
||||
);
|
||||
pointLights->pipelineBarrier(
|
||||
Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_ALL_COMMANDS_BIT
|
||||
);
|
||||
directionalLights->pipelineBarrier(
|
||||
Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_ALL_COMMANDS_BIT
|
||||
);
|
||||
|
||||
lightEnvBuffer->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT, Gfx::SE_ACCESS_SHADER_READ_BIT,
|
||||
Gfx::SE_PIPELINE_STAGE_ALL_COMMANDS_BIT);
|
||||
pointLights->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT, Gfx::SE_ACCESS_SHADER_READ_BIT,
|
||||
Gfx::SE_PIPELINE_STAGE_ALL_COMMANDS_BIT);
|
||||
directionalLights->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_ALL_COMMANDS_BIT);
|
||||
set->updateBuffer(0, lightEnvBuffer);
|
||||
set->updateBuffer(1, directionalLights);
|
||||
set->updateBuffer(2, pointLights);
|
||||
set->writeChanges();
|
||||
}
|
||||
|
||||
const Gfx::PDescriptorLayout LightEnvironment::getDescriptorLayout() const
|
||||
{
|
||||
return layout;
|
||||
}
|
||||
const Gfx::PDescriptorLayout LightEnvironment::getDescriptorLayout() const { return layout; }
|
||||
|
||||
Gfx::PDescriptorSet LightEnvironment::getDescriptorSet()
|
||||
{
|
||||
return set;
|
||||
}
|
||||
Gfx::PDescriptorSet LightEnvironment::getDescriptorSet() { return set; }
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
#pragma once
|
||||
#include "Graphics/Descriptor.h"
|
||||
#include "Graphics/Buffer.h"
|
||||
#include "Component/DirectionalLight.h"
|
||||
#include "Component/PointLight.h"
|
||||
#include "Graphics/Buffer.h"
|
||||
#include "Graphics/Descriptor.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
class LightEnvironment
|
||||
{
|
||||
public:
|
||||
|
||||
namespace Seele {
|
||||
class LightEnvironment {
|
||||
public:
|
||||
LightEnvironment(Gfx::PGraphics graphics);
|
||||
~LightEnvironment();
|
||||
void reset();
|
||||
@@ -17,11 +16,11 @@ public:
|
||||
void commit();
|
||||
const Gfx::PDescriptorLayout getDescriptorLayout() const;
|
||||
Gfx::PDescriptorSet getDescriptorSet();
|
||||
private:
|
||||
#define INIT_DIRECTIONAL_LIGHTS 4
|
||||
#define INIT_POINT_LIGHTS 256
|
||||
struct LightEnv
|
||||
{
|
||||
|
||||
private:
|
||||
#define INIT_DIRECTIONAL_LIGHTS 4
|
||||
#define INIT_POINT_LIGHTS 256
|
||||
struct LightEnv {
|
||||
uint32 numDirectionalLights;
|
||||
uint32 numPointLights;
|
||||
} lightEnv;
|
||||
@@ -35,4 +34,4 @@ private:
|
||||
Gfx::PGraphics graphics;
|
||||
};
|
||||
DEFINE_REF(LightEnvironment)
|
||||
}
|
||||
} // namespace Seele
|
||||
+12
-22
@@ -1,30 +1,20 @@
|
||||
#include "Scene.h"
|
||||
#include "Actor/PointLightActor.h"
|
||||
#include "Asset/AssetRegistry.h"
|
||||
#include "Asset/MaterialAsset.h"
|
||||
#include "Asset/TextureAsset.h"
|
||||
#include "Component/DirectionalLight.h"
|
||||
#include "Component/Mesh.h"
|
||||
#include "Component/PointLight.h"
|
||||
#include "Component/Transform.h"
|
||||
#include "Graphics/Graphics.h"
|
||||
#include "Graphics/Mesh.h"
|
||||
#include "Component/Mesh.h"
|
||||
#include "Component/Transform.h"
|
||||
#include "Asset/AssetRegistry.h"
|
||||
#include "Asset/TextureAsset.h"
|
||||
#include "Asset/MaterialAsset.h"
|
||||
#include "Component/PointLight.h"
|
||||
#include "Component/DirectionalLight.h"
|
||||
#include "Actor/PointLightActor.h"
|
||||
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
Scene::Scene(Gfx::PGraphics graphics)
|
||||
: graphics(graphics)
|
||||
, lightEnv(new LightEnvironment(graphics))
|
||||
, physics(registry)
|
||||
{
|
||||
}
|
||||
Scene::Scene(Gfx::PGraphics graphics) : graphics(graphics), lightEnv(new LightEnvironment(graphics)), physics(registry) {}
|
||||
|
||||
Scene::~Scene()
|
||||
{
|
||||
}
|
||||
|
||||
void Scene::update(float deltaTime)
|
||||
{
|
||||
physics.update(deltaTime);
|
||||
}
|
||||
Scene::~Scene() {}
|
||||
|
||||
void Scene::update(float deltaTime) { physics.update(deltaTime); }
|
||||
|
||||
+20
-43
@@ -1,64 +1,41 @@
|
||||
#pragma once
|
||||
#include <entt/entt.hpp>
|
||||
#include "MinimalEngine.h"
|
||||
#include "Graphics/Graphics.h"
|
||||
#include "Physics/PhysicsSystem.h"
|
||||
#include "Component/Skybox.h"
|
||||
#include "Graphics/Graphics.h"
|
||||
#include "LightEnvironment.h"
|
||||
#include "MinimalEngine.h"
|
||||
#include "Physics/PhysicsSystem.h"
|
||||
#include <entt/entt.hpp>
|
||||
#include <iostream>
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
|
||||
namespace Seele {
|
||||
DECLARE_REF(Material)
|
||||
DECLARE_REF(Entity)
|
||||
class Scene
|
||||
{
|
||||
public:
|
||||
class Scene {
|
||||
public:
|
||||
Scene(Gfx::PGraphics graphics);
|
||||
~Scene();
|
||||
void update(float deltaTime);
|
||||
entt::entity createEntity()
|
||||
{
|
||||
return registry.create();
|
||||
}
|
||||
void destroyEntity(entt::entity identifier)
|
||||
{
|
||||
registry.destroy(identifier);
|
||||
}
|
||||
template<typename Component, typename... Args>
|
||||
Component& attachComponent(entt::entity entity, Args&&... args)
|
||||
{
|
||||
entt::entity createEntity() { return registry.create(); }
|
||||
void destroyEntity(entt::entity identifier) { registry.destroy(identifier); }
|
||||
template <typename Component, typename... Args> Component& attachComponent(entt::entity entity, Args&&... args) {
|
||||
return registry.emplace<Component>(entity, std::forward<Args>(args)...);
|
||||
}
|
||||
template<typename Component>
|
||||
Component& accessComponent(entt::entity entity)
|
||||
{
|
||||
return registry.get<Component>(entity);
|
||||
}
|
||||
template<typename Component>
|
||||
const Component& accessComponent(entt::entity entity) const
|
||||
{
|
||||
return registry.get<Component>(entity);
|
||||
}
|
||||
template<typename... Component, typename Func>
|
||||
void view(Func func) requires std::is_invocable_v<Func, Component&...> || std::is_invocable_v<Func, entt::entity, Component&...>
|
||||
template <typename Component> Component& accessComponent(entt::entity entity) { return registry.get<Component>(entity); }
|
||||
template <typename Component> const Component& accessComponent(entt::entity entity) const { return registry.get<Component>(entity); }
|
||||
template <typename... Component, typename Func>
|
||||
void view(Func func)
|
||||
requires std::is_invocable_v<Func, Component&...> || std::is_invocable_v<Func, entt::entity, Component&...>
|
||||
{
|
||||
registry.view<Component...>().each(func);
|
||||
}
|
||||
template<typename Component>
|
||||
auto constructCallback()
|
||||
{
|
||||
return registry.on_construct<Component>();
|
||||
}
|
||||
template<typename Component>
|
||||
auto destroyCallback()
|
||||
{
|
||||
return registry.on_destroy<Component>();
|
||||
}
|
||||
template <typename Component> auto constructCallback() { return registry.on_construct<Component>(); }
|
||||
template <typename Component> auto destroyCallback() { return registry.on_destroy<Component>(); }
|
||||
PLightEnvironment getLightEnvironment() { return lightEnv; }
|
||||
Gfx::PGraphics getGraphics() const { return graphics; }
|
||||
entt::registry registry;
|
||||
private:
|
||||
|
||||
private:
|
||||
Gfx::PGraphics graphics;
|
||||
OLightEnvironment lightEnv;
|
||||
PhysicsSystem physics;
|
||||
|
||||
+33
-84
@@ -1,136 +1,88 @@
|
||||
#pragma once
|
||||
#include "MinimalEngine.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
template<typename T>
|
||||
class Writable
|
||||
{
|
||||
public:
|
||||
Writable()
|
||||
{}
|
||||
Writable(T initialData)
|
||||
: toBeWritten(initialData)
|
||||
, data(initialData)
|
||||
{}
|
||||
namespace Seele {
|
||||
template <typename T> class Writable {
|
||||
public:
|
||||
Writable() {}
|
||||
Writable(T initialData) : toBeWritten(initialData), data(initialData) {}
|
||||
Writable(const Writable& other) = delete;
|
||||
Writable(Writable&& other) = default;
|
||||
~Writable() = default;
|
||||
Writable& operator=(const Writable& other) const = delete;
|
||||
Writable& operator=(Writable&& other) const = delete;
|
||||
const Writable& operator=(const T& other) const
|
||||
{
|
||||
const Writable& operator=(const T& other) const {
|
||||
deferWrite(other);
|
||||
return *this;
|
||||
}
|
||||
const Writable& operator=(T&& other) const
|
||||
{
|
||||
const Writable& operator=(T&& other) const {
|
||||
deferWrite(std::move(other));
|
||||
return *this;
|
||||
}
|
||||
template<typename Other>
|
||||
const Writable& operator+(Other&& other) const
|
||||
{
|
||||
template <typename Other> const Writable& operator+(Other&& other) const {
|
||||
deferWrite(data + std::forward<Other>(other));
|
||||
return *this;
|
||||
}
|
||||
template<typename Other>
|
||||
const Writable& operator-(Other&& other) const
|
||||
{
|
||||
template <typename Other> const Writable& operator-(Other&& other) const {
|
||||
deferWrite(data - std::forward<Other>(other));
|
||||
return *this;
|
||||
}
|
||||
template<typename Other>
|
||||
const Writable& operator*(Other&& other) const
|
||||
{
|
||||
template <typename Other> const Writable& operator*(Other&& other) const {
|
||||
deferWrite(data * std::forward<Other>(other));
|
||||
return *this;
|
||||
}
|
||||
template<typename Other>
|
||||
const Writable& operator/(Other&& other) const
|
||||
{
|
||||
template <typename Other> const Writable& operator/(Other&& other) const {
|
||||
deferWrite(data / std::forward<Other>(other));
|
||||
return *this;
|
||||
}
|
||||
template<typename Other>
|
||||
const Writable& operator%(Other&& other) const
|
||||
{
|
||||
template <typename Other> const Writable& operator%(Other&& other) const {
|
||||
deferWrite(data % std::forward<Other>(other));
|
||||
return *this;
|
||||
}
|
||||
template<typename Other>
|
||||
const Writable& operator^(Other&& other) const
|
||||
{
|
||||
template <typename Other> const Writable& operator^(Other&& other) const {
|
||||
deferWrite(data ^ std::forward<Other>(other));
|
||||
return *this;
|
||||
}
|
||||
template<typename Other>
|
||||
const Writable& operator&(Other&& other) const
|
||||
{
|
||||
template <typename Other> const Writable& operator&(Other&& other) const {
|
||||
deferWrite(data & std::forward<Other>(other));
|
||||
return *this;
|
||||
}
|
||||
template<typename Other>
|
||||
const Writable& operator|(Other&& other) const
|
||||
{
|
||||
template <typename Other> const Writable& operator|(Other&& other) const {
|
||||
deferWrite(data | std::forward<Other>(other));
|
||||
return *this;
|
||||
}
|
||||
template<typename Type>
|
||||
bool operator==(Type other) const
|
||||
{
|
||||
return data == other.data;
|
||||
}
|
||||
template<typename Type>
|
||||
bool operator<=>(Type other) const
|
||||
{
|
||||
return data <=> other.data;
|
||||
}
|
||||
const Writable& operator++() const
|
||||
{
|
||||
deferWrite(data+1);
|
||||
template <typename Type> bool operator==(Type other) const { return data == other.data; }
|
||||
template <typename Type> bool operator<=>(Type other) const { return data <=> other.data; }
|
||||
const Writable& operator++() const {
|
||||
deferWrite(data + 1);
|
||||
return *this;
|
||||
}
|
||||
const Writable& operator--() const
|
||||
{
|
||||
deferWrite(data-1);
|
||||
const Writable& operator--() const {
|
||||
deferWrite(data - 1);
|
||||
return *this;
|
||||
}
|
||||
Writable&& operator++(int) const
|
||||
{
|
||||
Writable&& operator++(int) const {
|
||||
Writable tmp(data);
|
||||
++*this;
|
||||
return std::move(tmp);
|
||||
}
|
||||
Writable&& operator--(int) const
|
||||
{
|
||||
Writable&& operator--(int) const {
|
||||
Writable tmp(data);
|
||||
--*this;
|
||||
return std::move(tmp);
|
||||
}
|
||||
const T& operator*() const
|
||||
{
|
||||
return data;
|
||||
}
|
||||
const T& get() const
|
||||
{
|
||||
return data;
|
||||
}
|
||||
const T& operator->() const
|
||||
{
|
||||
return data;
|
||||
}
|
||||
void update()
|
||||
{
|
||||
const T& operator*() const { return data; }
|
||||
const T& get() const { return data; }
|
||||
const T& operator->() const { return data; }
|
||||
void update() {
|
||||
// lock should not be necessary, but lets keep it for now
|
||||
//std::scoped_lock lock(dataLock);
|
||||
// std::scoped_lock lock(dataLock);
|
||||
data = toBeWritten;
|
||||
dirty = false;
|
||||
}
|
||||
private:
|
||||
template<typename Type>
|
||||
void deferWrite(Type&& newValue) const
|
||||
{
|
||||
|
||||
private:
|
||||
template <typename Type> void deferWrite(Type&& newValue) const {
|
||||
std::scoped_lock lock(dataLock);
|
||||
assert(!dirty);
|
||||
toBeWritten = std::forward<Type>(newValue);
|
||||
@@ -141,9 +93,6 @@ private:
|
||||
mutable T toBeWritten;
|
||||
T data;
|
||||
};
|
||||
template<typename A>
|
||||
concept writable = requires(A&& a)
|
||||
{
|
||||
a.update();
|
||||
};
|
||||
template <typename A>
|
||||
concept writable = requires(A&& a) { a.update(); };
|
||||
} // namespace Seele
|
||||
|
||||
Reference in New Issue
Block a user