LUMIERA.clone/tests/core/steam/engine/buffer-proxy-provider-test.cpp
Ichthyostega 33c8f1c5b1 Invocation: investigate forwarding an output data block
This investigation started out as solving an already solved problem...
I'll continue this as a design exercise non the less.

__Some explanation__: To achieve the goal of invoking a Node end-to-end,
the gap between the `Port` API, the `ProcNode` API and the `RenderInvocation` must be closed.
This leads to questions of API design: ''what core operation should the `ProcNode` API expose?''
 * is `ProcNode` just a forwarding / delegating container and becoming redundant?
 * or does the API rather move in the direction of an ''Exit Node''?

This leads to the question how the opened `OutputSlot` can be exposed as a `BuffHandle`
to allow to set off the recursive Node invocation. As it turns out, the onerous for this step
lies on the actual `OutputSlot` implementation, since the API and output protocol already requires
to expose a `BuffHandle`. Yet there is no "real" implementation available, just a Mock setup based
on `DiagnosticBufferProvider`, which obviously can just be passed-through.

Which leaves me with mixed feelings. For one it is conveninent to skip this topic for now,
but on the other hand the design of `BufferProvider` does not seem well suited for such an proxying task.
Thus I decided to explore this aspect in the form of a prototyping test....
2024-12-23 02:31:29 +01:00

88 lines
2.7 KiB
C++
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
OutputProxyProvider(Test) - verify accessing an output sink via BufferProvider protocol
Copyright (C)
2024, 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 output-proxy-provider-test.cpp
** unit test \ref OutputProxyProvider_test
*/
#include "lib/test/run.hpp"
//#include "steam/play/diagnostic-output-slot.hpp"
#include "steam/engine/buffer-proxy-provider.hpp"
#include "steam/engine/test-rand-ontology.hpp"
namespace steam {
namespace engine{
namespace test {
/***************************************************************//**
* @test verify the OutputSlot interface and base implementation
* by performing full data exchange cycle. This is a
* kind of "dry run" for documentation purposes,
* both the actual OutputSlot implementation
* as the client using this slot are Mocks.
*/
class OutputProxyProvider_test : public Test
{
virtual void
run (Arg)
{
size_t seenID{0};
BufferState lastState{NIL};
auto listener = [&](size_t id, BufferState state)
{
seenID = id;
lastState = state;
};
// setup with notification callback
BufferProxyProvider proxPro{listener};
// Assuming some data block is »given«
seedRand();
TestFrame::reseed();
size_t frameNr = defaultGen.u64();
TestFrame dataBlock (frameNr);
CHECK ( dataBlock.isPristine());
BuffHandle handle = proxPro.lockBuffer (dataBlock);
// Now a »client« can do awful things to the buffer...
CHECK (handle.isValid());
auto& data = handle.accessAs<TestFrame>();
uint64_t param = defaultGen.u64();
manipulateFrame (&data, &data, param);
// »client« is done...
handle.emit();
// end usage cycle
handle.release();
CHECK (not handle.isValid());
CHECK (not dataBlock.isPristine());
CHECK ( dataBlock.isValid());
}
};
/** Register this test class... */
LAUNCHER (OutputProxyProvider_test, "unit play");
}}} // namespace steam::play::test