The prototype implementations of BuferProvider and OutputSlot are confusing; in-depth analysis shows that this is related to intermingling use of test instrumentation and features of a prototypical default. To get anywhere with the existing code, it seems we'd need to split off the test instrumentation (i.e. `DiagnosticBufferProvider`) altogether, even if this causes duplication of implementation code. Many years ago, when first implementing this prototype, I had no clear idea what the usage in the Render Engine entails, yet I noticed that some basic buffer »tracking« could be used as implementation primitive to simplify the prototyping work. This might be one of the reasons, why the "code behind" in the protocol implementations both in `BufferProvider` and `OutputSlot` became so strongly tangled, so that I way unable to make both protocols orthogonally composable.
109 lines
2.5 KiB
C++
109 lines
2.5 KiB
C++
/*
|
||
DiagnosticBufferProvider - helper for testing against the BufferProvider interface
|
||
|
||
Copyright (C)
|
||
2011, Hermann Vosseler <Ichthyostega@web.de>
|
||
|
||
**Lumiera** is free software; you can redistribute it and/or modify it
|
||
under the terms of the GNU General Public License as published by the
|
||
Free Software Foundation; either version 2 of the License, or (at your
|
||
option) any later version. See the file COPYING for further details.
|
||
|
||
* *****************************************************************/
|
||
|
||
|
||
/** @file diagnostic-buffer-provider.cpp
|
||
** Implementation details of unit test support regarding internals of the render engine.
|
||
**
|
||
** @todo WIP from 2013, half finished, stalled
|
||
** @see buffer-provider-protocol-test.cpp
|
||
*/
|
||
|
||
|
||
#include "lib/error.hpp"
|
||
#include "lib/meta/function.hpp"
|
||
|
||
#include "steam/engine/diagnostic-buffer-provider.hpp"
|
||
#include "steam/engine/heap-mem-provider.hpp"
|
||
|
||
|
||
namespace steam {
|
||
namespace engine {
|
||
|
||
|
||
/** Storage for the diagnostics frontend */
|
||
lib::Depend<DiagnosticBufferProvider> DiagnosticBufferProvider::diagnostics;
|
||
|
||
|
||
|
||
|
||
DiagnosticBufferProvider::DiagnosticBufferProvider()
|
||
: pImpl_()
|
||
{ }
|
||
|
||
DiagnosticBufferProvider::~DiagnosticBufferProvider() { }
|
||
|
||
|
||
BufferProvider&
|
||
DiagnosticBufferProvider::build()
|
||
{
|
||
return diagnostics().reset();
|
||
}
|
||
|
||
|
||
DiagnosticBufferProvider&
|
||
DiagnosticBufferProvider::access (BufferProvider const& provider)
|
||
{
|
||
if (!diagnostics().isCurrent (provider))
|
||
throw error::Invalid("given Provider doesn't match (current) diagnostic data record."
|
||
"This might be an lifecycle error. Did you build() this instance beforehand?");
|
||
|
||
return diagnostics();
|
||
}
|
||
|
||
|
||
|
||
|
||
HeapMemProvider&
|
||
DiagnosticBufferProvider::reset()
|
||
{
|
||
if (pImpl_)
|
||
pImpl_->markAllEmitted();
|
||
pImpl_.reset(new HeapMemProvider());
|
||
return *pImpl_;
|
||
}
|
||
|
||
bool
|
||
DiagnosticBufferProvider::isCurrent (BufferProvider const& implInstance)
|
||
{
|
||
return &implInstance == pImpl_.get();
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/* === diagnostic API === */
|
||
|
||
bool
|
||
DiagnosticBufferProvider::buffer_was_used (uint bufferID) const
|
||
{
|
||
return pImpl_->access_emitted(bufferID).was_used();
|
||
}
|
||
|
||
|
||
bool
|
||
DiagnosticBufferProvider::buffer_was_closed (uint bufferID) const
|
||
{
|
||
return pImpl_->access_emitted(bufferID).was_closed();
|
||
}
|
||
|
||
|
||
void*
|
||
DiagnosticBufferProvider::accessMemory (uint bufferID) const
|
||
{
|
||
return pImpl_->access_emitted(bufferID).accessMemory();
|
||
}
|
||
|
||
|
||
}} // namespace engine
|