BufferProvider: now able to push down BufferMetadata

This is clearly implementation code and can now be removed from the interfaces;
`SimpleBufferStateRegistry` can thus delegated to a private metadata registry
This commit is contained in:
Fischlurch 2026-02-16 22:38:23 +01:00
parent 3d6e2fea75
commit 6de1837042
5 changed files with 27 additions and 31 deletions

View file

@ -38,6 +38,7 @@ namespace engine {
using lib::Literal;
using std::unique_ptr;
using std::make_unique;
// using std::forward;
using std::move;
@ -68,19 +69,17 @@ namespace engine {
bufferStage_ = move (confRec.buildStage());
bufferStore_ = move (confRec.buildStore());
}
/* ======== Extension points ======== */
class Stage
: public BufferStage
{
public:
using BufferStage::BufferStage; ///////////////////////////////////////////////////////////TICKET #1410 : actual implementation structures should move down into this classes implementation
};
{ };
class Store
: public BufferStore
{
};
{ };
protected:

View file

@ -29,9 +29,11 @@
#include "lib/error.hpp"
#include "steam/engine/buffer-provider.hpp"
#include "steam/engine/buffer-metadata.hpp" /////////////////////////OOO must be removed from here
#include "steam/engine/simple-buffer-state-registry.hpp" /////////////OOO better use constexpr for hash-chaining?
#include "lib/util.hpp"
#include <utility>
using std::move;
using util::isSameAdr;
namespace steam {
@ -63,7 +65,7 @@ namespace engine {
bool
BufferProvider::isAccessible (HashVal id) const
{
return bufferStage_->isUsageAllowed (id);
return bufferStage_->isAccessible (id);
}
size_t

View file

@ -118,7 +118,6 @@
#include "steam/engine/buffhandle.hpp"
#include "steam/engine/type-handler.hpp"
#include "steam/engine/buffer-local-tag.hpp"
#include "steam/engine/buffer-metadata.hpp" /////////////////////////OOO must be removed from here
#include "lib/nocopy.hpp"
#include <utility>
@ -194,13 +193,12 @@ namespace engine {
class BufferStage
: public BufferMetadata /////////////////////////////////////////////////////////////////////TICKET #1410 : mix-in exiting old implementation -- for sake of refactoring only!
: util::NonCopyable
{
protected:
using ID = metadata::Key const&;
public:
virtual ~BufferStage() { } ///< this is an interface
using BufferMetadata::BufferMetadata; ///////////////////////////////////////////////////////////TICKET #1410 : actual implementation structures should move down into this classes implementation
virtual ID defineBufferType (size_t, TypeHandler) =0;
virtual ID lookup (HashVal) =0;
@ -209,7 +207,7 @@ namespace engine {
virtual ID mark_released (HashVal stateKey) =0;
virtual ID abandon (HashVal, bool destroy=false) =0;
virtual void discard (HashVal stateKey) =0;
virtual bool isUsageAllowed (HashVal stateKey) const =0;
virtual bool isAccessible (HashVal stateKey) const =0;
};
class BufferStore

View file

@ -60,7 +60,7 @@ namespace engine {
{ }
auto buildStage() { return std::make_unique<SimpleBufferStateRegistry> ("Naive_HeapAllocated"); }
auto buildStore() { return std::make_unique<HeapMemBufferStore>(); } /////////////////////////////////TICKET #1410 : turn into a subclass of BufferSetup::Store and push down implementation
auto buildStore() { return std::make_unique<HeapMemBufferStore>(); }
};

View file

@ -25,7 +25,6 @@
#include "lib/error.hpp"
//#include "lib/hash-value.h"
#include "steam/engine/buffer-provider-setup.hpp"
#include "steam/engine/buffer-metadata.hpp"
@ -38,8 +37,6 @@ namespace engine {
namespace error = lumiera::error;
using metadata::Buff;
// using std::unique_ptr;
// using lib::HashVal;
/**
@ -49,39 +46,39 @@ namespace engine {
class SimpleBufferStateRegistry
: public BufferProviderSetup::Stage
{
///////////////////////////////////////////////////////////////////////////////////////////////////////TICKET 1410 : rather hold BufferMetatdata object here
BufferMetadata metadata_;
/* === BufferStage interface === */
ID
lookup (HashVal key) override
{
return this->isKnown(key)? this->get (key)
: metadata::Key::INVALID;
return metadata_.isKnown(key)? metadata_.get (key)
: metadata::Key::INVALID;
}
bool
isUsageAllowed (HashVal stateKey) const override
isAccessible (HashVal stateKey) const override
{
return this->isAccessible (stateKey);
return metadata_.isAccessible (stateKey);
}
ID
defineBufferType (size_t buffSiz, TypeHandler handlerFunctions)
{
return lookup (this->key (buffSiz, move (handlerFunctions)));
return lookup (metadata_.key (buffSiz, move (handlerFunctions)));
} // deliberately: create storage, and return reference to it
ID
mark_locked (ID typeKey, Buff* storage, LocalTag implMark) override
{
return this->markLocked (typeKey, storage, implMark);
return metadata_.markLocked (typeKey, storage, implMark);
}
ID
mark_emitted (HashVal stateKey) override
{
metadata::Entry& metaEntry = this->get (stateKey);
metadata::Entry& metaEntry = metadata_.get (stateKey);
metaEntry.mark(EMITTED);
return metaEntry; // contains also the key
}
@ -89,7 +86,7 @@ namespace engine {
ID
mark_released (HashVal stateKey) override
{
metadata::Entry& metaEntry = this->get (stateKey);
metadata::Entry& metaEntry = metadata_.get (stateKey);
metaEntry.mark(FREE); // might invoke embedded dtor function
return metaEntry;
}
@ -97,7 +94,7 @@ namespace engine {
ID
abandon (HashVal stateKey, bool invokeDtor) override
{
metadata::Entry& metaEntry = this->get (stateKey);
metadata::Entry& metaEntry = metadata_.get (stateKey);
metaEntry.invalidate (invokeDtor);
return metaEntry;
}
@ -105,13 +102,13 @@ namespace engine {
void
discard (HashVal stateKey) override
{
this->release (stateKey);
metadata_.release (stateKey);
}
public:
SimpleBufferStateRegistry (Literal implementationID)
: BufferProviderSetup::Stage{implementationID} //////////////////////////////////////////////////TICKET 1410 : rather init BufferMetatdata
: metadata_{implementationID}
{ }
private: