2024-06-29 04:23:55 +02:00
|
|
|
|
/*
|
|
|
|
|
|
TEST-RAND-ONTOLOGY.hpp - placeholder for a domain-ontology working on dummy data frames
|
|
|
|
|
|
|
Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
Copyright (C)
|
|
|
|
|
|
2024, Hermann Vosseler <Ichthyostega@web.de>
|
2024-06-29 04:23:55 +02:00
|
|
|
|
|
Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
**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.
|
2024-06-29 04:23:55 +02:00
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2024-10-31 23:50:59 +01:00
|
|
|
|
/** @file test-rand-ontology.hpp
|
2024-06-29 04:23:55 +02:00
|
|
|
|
** A faked »media calculation« environment to validate the render node network.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef STEAM_ENGINE_TEST_RAND_ONTOLOGY_H
|
|
|
|
|
|
#define STEAM_ENGINE_TEST_RAND_ONTOLOGY_H
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-10-31 23:50:59 +01:00
|
|
|
|
#include "lib/error.hpp"
|
2024-11-28 23:41:56 +01:00
|
|
|
|
#include "lib/symbol.hpp"
|
2024-11-05 21:23:13 +01:00
|
|
|
|
#include "lib/depend.hpp"
|
2024-11-28 23:41:56 +01:00
|
|
|
|
#include "lib/nocopy.hpp"
|
2025-01-06 19:47:51 +01:00
|
|
|
|
#include "lib/format-obj.hpp"
|
2024-11-28 23:41:56 +01:00
|
|
|
|
#include "lib/format-string.hpp"
|
2024-06-29 04:23:55 +02:00
|
|
|
|
#include "steam/engine/testframe.hpp"
|
|
|
|
|
|
|
2024-10-13 03:49:01 +02:00
|
|
|
|
#include <array>
|
2025-01-06 19:47:51 +01:00
|
|
|
|
#include <tuple>
|
2024-11-03 22:55:06 +01:00
|
|
|
|
#include <string>
|
2025-01-06 19:47:51 +01:00
|
|
|
|
#include <memory>
|
|
|
|
|
|
#include <utility>
|
2024-10-13 03:49:01 +02:00
|
|
|
|
|
2024-06-29 04:23:55 +02:00
|
|
|
|
|
|
|
|
|
|
namespace steam {
|
|
|
|
|
|
namespace engine{
|
|
|
|
|
|
namespace test {
|
|
|
|
|
|
|
2025-01-06 19:47:51 +01:00
|
|
|
|
using std::tuple;
|
2024-11-03 22:55:06 +01:00
|
|
|
|
using std::string;
|
2024-11-28 23:41:56 +01:00
|
|
|
|
using lib::Literal;
|
2025-01-06 19:47:51 +01:00
|
|
|
|
using std::shared_ptr;
|
|
|
|
|
|
using std::make_shared;
|
|
|
|
|
|
using std::forward;
|
|
|
|
|
|
using std::move;
|
2024-11-28 23:41:56 +01:00
|
|
|
|
using util::_Fmt;
|
2025-01-06 19:47:51 +01:00
|
|
|
|
using util::toString;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Test-Rand-Ontology : definition structures similar to a media-library
|
|
|
|
|
|
*/
|
|
|
|
|
|
namespace ont {
|
|
|
|
|
|
|
|
|
|
|
|
using FraNo = size_t;
|
|
|
|
|
|
using ChaNo = uint;
|
|
|
|
|
|
using Flavr = uint;
|
|
|
|
|
|
using Factr = double;
|
|
|
|
|
|
using Param = uint64_t;
|
|
|
|
|
|
|
2025-01-06 22:00:29 +01:00
|
|
|
|
const Literal OID{"Test"}; ///< classificatory prefix for functionality provided by this „library“
|
2025-01-06 19:47:51 +01:00
|
|
|
|
const Literal TYPE_TESTFRAME{"TestFrame"}; ///< a stream implementation type with a frame of reproducible random data
|
|
|
|
|
|
|
2025-01-06 22:00:29 +01:00
|
|
|
|
/** a dummy value */
|
|
|
|
|
|
extern int dummyNum;
|
|
|
|
|
|
|
|
|
|
|
|
/** the simplest possible function,
|
|
|
|
|
|
* which can be bound as Render Node */
|
|
|
|
|
|
inline void
|
|
|
|
|
|
dummyOp (int* num_in_buff)
|
|
|
|
|
|
{
|
|
|
|
|
|
CHECK (num_in_buff != nullptr);
|
|
|
|
|
|
*num_in_buff = dummyNum++;
|
|
|
|
|
|
}
|
|
|
|
|
|
const Literal DUMMY_NODE_ID{"Test:dummy"};
|
|
|
|
|
|
const Literal DUMMY_PROC_ID{"op(int)"};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** produce sequences of frames with (reproducible) random data */
|
|
|
|
|
|
void generateFrame (TestFrame* buff, FraNo frameNr =0, Flavr flavour =0);
|
|
|
|
|
|
|
|
|
|
|
|
/** produce planar multi channel output of random data frames */
|
|
|
|
|
|
void generateMultichan (TestFrame* buffArry, ChaNo chanCnt, FraNo frameNr =0, Flavr flavour =0);
|
|
|
|
|
|
|
|
|
|
|
|
/** create an identical clone copy of the planar multi channel frame array */
|
|
|
|
|
|
void duplicateMultichan (TestFrame* outArry, TestFrame* inArry, ChaNo chanCnt);
|
|
|
|
|
|
|
|
|
|
|
|
/** »process« a planar multi channel array of data frames in-place */
|
|
|
|
|
|
void manipulateMultichan (TestFrame* buffArry, ChaNo chanCnt, Param param);
|
|
|
|
|
|
|
|
|
|
|
|
/** »process« random frame date by hash-chaining with a parameter */
|
|
|
|
|
|
void manipulateFrame (TestFrame* out, TestFrame const* in, Param param);
|
|
|
|
|
|
|
|
|
|
|
|
/** mix two random data frames by a parameter-controlled proportion */
|
|
|
|
|
|
void combineFrames (TestFrame* out, TestFrame const* srcA, TestFrame const* srcB, Factr mix);
|
|
|
|
|
|
|
|
|
|
|
|
}//(End)namespace ont
|
2024-11-05 21:23:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
2024-10-31 23:50:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
2025-01-06 19:47:51 +01:00
|
|
|
|
|
2024-06-29 04:23:55 +02:00
|
|
|
|
/**
|
2025-01-06 22:00:29 +01:00
|
|
|
|
* A fake **Domain Ontology** to describe mocked »render operations« on dummy data frames
|
|
|
|
|
|
* filled with random numbers. It provides a _builder notation_ to configure a _processing-functor_
|
|
|
|
|
|
* for some operations working on such data frames.
|
2024-06-29 04:23:55 +02:00
|
|
|
|
* @see TestFrame_test
|
|
|
|
|
|
* @see NodeDevel_test
|
2024-12-06 23:43:18 +01:00
|
|
|
|
* @see NodeLink_test
|
2024-06-29 04:23:55 +02:00
|
|
|
|
*/
|
|
|
|
|
|
class TestRandOntology
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
2024-11-28 23:41:56 +01:00
|
|
|
|
struct Spec;
|
|
|
|
|
|
|
2025-01-06 19:47:51 +01:00
|
|
|
|
template<class CONF>
|
|
|
|
|
|
class Builder;
|
|
|
|
|
|
|
2024-06-29 04:23:55 +02:00
|
|
|
|
~TestRandOntology() = default;
|
|
|
|
|
|
TestRandOntology() = default;
|
|
|
|
|
|
|
2025-01-06 22:00:29 +01:00
|
|
|
|
auto setupGenerator();
|
2025-02-09 18:04:39 +01:00
|
|
|
|
auto setupManipulator();
|
2025-02-10 22:48:31 +01:00
|
|
|
|
auto setupCombinator();
|
2024-06-29 04:23:55 +02:00
|
|
|
|
private:
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-06 22:00:29 +01:00
|
|
|
|
|
|
|
|
|
|
|
2024-11-28 23:41:56 +01:00
|
|
|
|
struct TestRandOntology::Spec
|
|
|
|
|
|
: util::Cloneable
|
|
|
|
|
|
{
|
|
|
|
|
|
const string PROTO;
|
2025-01-06 22:00:29 +01:00
|
|
|
|
const string FUNC_ID;
|
2025-01-06 19:47:51 +01:00
|
|
|
|
const string BASE_TYPE;
|
2024-11-28 23:41:56 +01:00
|
|
|
|
|
|
|
|
|
|
Spec (Literal kind
|
|
|
|
|
|
,Literal type
|
|
|
|
|
|
)
|
|
|
|
|
|
: PROTO{_Fmt{"%s-%s"} % kind % type}
|
2025-01-06 22:00:29 +01:00
|
|
|
|
, FUNC_ID{kind}
|
2025-01-06 19:47:51 +01:00
|
|
|
|
, BASE_TYPE{type}
|
|
|
|
|
|
{ }
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template<class CONF>
|
|
|
|
|
|
class TestRandOntology::Builder
|
|
|
|
|
|
: public Spec
|
|
|
|
|
|
{
|
|
|
|
|
|
shared_ptr<CONF> conf_;
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
template<typename...INIT>
|
|
|
|
|
|
Builder (Spec spec, INIT&& ...init)
|
|
|
|
|
|
: Spec{move(spec)}
|
|
|
|
|
|
, conf_{make_shared<CONF> (spec, forward<INIT> (init)...)}
|
2024-11-28 23:41:56 +01:00
|
|
|
|
{ }
|
2025-01-06 19:47:51 +01:00
|
|
|
|
|
2025-01-06 22:00:29 +01:00
|
|
|
|
auto makeFun() { return conf_->binding(); }
|
|
|
|
|
|
string procID() { return conf_->procSpec(); }
|
|
|
|
|
|
string nodeID() { return string{ont::OID}+":"+FUNC_ID; }
|
2024-11-28 23:41:56 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
2025-01-06 19:47:51 +01:00
|
|
|
|
|
|
|
|
|
|
namespace ont {
|
|
|
|
|
|
using Spec = TestRandOntology::Spec;
|
|
|
|
|
|
|
|
|
|
|
|
/** extended config for Generator operations */
|
|
|
|
|
|
struct ConfGen
|
|
|
|
|
|
{
|
2025-02-09 18:04:39 +01:00
|
|
|
|
using Param = tuple<FraNo, Flavr>;
|
2025-01-06 19:47:51 +01:00
|
|
|
|
|
2025-02-09 18:04:39 +01:00
|
|
|
|
Flavr fOff = 0;
|
2025-01-06 19:47:51 +01:00
|
|
|
|
string streamType;
|
|
|
|
|
|
|
|
|
|
|
|
ConfGen(Spec const& spec)
|
|
|
|
|
|
: streamType{spec.BASE_TYPE}
|
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
auto
|
|
|
|
|
|
binding()
|
|
|
|
|
|
{
|
|
|
|
|
|
return [offset = fOff]
|
|
|
|
|
|
(Param par, TestFrame* out)
|
|
|
|
|
|
{
|
|
|
|
|
|
auto [frameNr,flavour] = par;
|
|
|
|
|
|
generateFrame (out, frameNr, flavour+offset);
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string
|
|
|
|
|
|
procSpec()
|
|
|
|
|
|
{
|
|
|
|
|
|
return _Fmt{"%s(%s)"}
|
|
|
|
|
|
% (fOff? toString(fOff):"")
|
|
|
|
|
|
% streamType;
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
2025-02-09 18:04:39 +01:00
|
|
|
|
|
|
|
|
|
|
/** extended config for Manipulator/Filter operations */
|
|
|
|
|
|
struct ConfMan
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
Param filter = 0;
|
|
|
|
|
|
string streamType;
|
|
|
|
|
|
|
|
|
|
|
|
ConfMan(Spec const& spec)
|
|
|
|
|
|
: streamType{spec.BASE_TYPE}
|
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
auto
|
|
|
|
|
|
binding()
|
|
|
|
|
|
{
|
|
|
|
|
|
return [offset = filter]
|
|
|
|
|
|
(Param par, TestFrame const* in, TestFrame* out)
|
|
|
|
|
|
{
|
|
|
|
|
|
manipulateFrame (out, in, par);
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string
|
|
|
|
|
|
procSpec()
|
|
|
|
|
|
{
|
2025-02-19 19:37:55 +01:00
|
|
|
|
return _Fmt{"%s(%s)(%s)"}
|
2025-02-09 18:04:39 +01:00
|
|
|
|
% (filter? util::showHash(filter):"")
|
2025-02-19 19:37:55 +01:00
|
|
|
|
% streamType
|
2025-02-09 18:04:39 +01:00
|
|
|
|
% streamType;
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
2025-02-10 22:48:31 +01:00
|
|
|
|
|
|
|
|
|
|
/** extended config for combining/mixing operations */
|
|
|
|
|
|
struct ConfMix
|
|
|
|
|
|
{
|
|
|
|
|
|
using InFeed = std::array<TestFrame const*, 2>;
|
|
|
|
|
|
string streamType;
|
|
|
|
|
|
|
|
|
|
|
|
ConfMix(Spec const& spec)
|
|
|
|
|
|
: streamType{spec.BASE_TYPE}
|
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
auto
|
|
|
|
|
|
binding()
|
|
|
|
|
|
{
|
|
|
|
|
|
return []
|
|
|
|
|
|
(Factr mix, InFeed inChan, TestFrame* out)
|
|
|
|
|
|
{
|
|
|
|
|
|
combineFrames (out, inChan[0],inChan[1], mix);
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string
|
|
|
|
|
|
procSpec()
|
|
|
|
|
|
{
|
2025-02-19 19:37:55 +01:00
|
|
|
|
return _Fmt{"(%s/2)(%s)"}
|
|
|
|
|
|
% streamType
|
2025-02-10 22:48:31 +01:00
|
|
|
|
% streamType;
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
2025-01-06 22:00:29 +01:00
|
|
|
|
}//(End)namespace ont
|
2025-01-06 19:47:51 +01:00
|
|
|
|
|
2025-01-06 22:00:29 +01:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Initiate configuration of a generator-node to produce TestFrame(s)
|
|
|
|
|
|
*/
|
2025-01-06 19:47:51 +01:00
|
|
|
|
inline auto
|
2025-01-06 22:00:29 +01:00
|
|
|
|
TestRandOntology::setupGenerator()
|
2024-11-28 23:41:56 +01:00
|
|
|
|
{
|
2025-01-06 19:47:51 +01:00
|
|
|
|
Spec spec{"generate", ont::TYPE_TESTFRAME};
|
|
|
|
|
|
Builder<ont::ConfGen> builder{spec};
|
|
|
|
|
|
return builder;
|
2024-11-28 23:41:56 +01:00
|
|
|
|
}
|
2024-06-29 04:23:55 +02:00
|
|
|
|
|
2025-02-09 18:04:39 +01:00
|
|
|
|
/**
|
2025-02-10 22:48:31 +01:00
|
|
|
|
* Initiate configuration of a filter-node to manipulate TestFrame(s)
|
2025-02-09 18:04:39 +01:00
|
|
|
|
*/
|
|
|
|
|
|
inline auto
|
|
|
|
|
|
TestRandOntology::setupManipulator()
|
|
|
|
|
|
{
|
|
|
|
|
|
Spec spec{"manipulate", ont::TYPE_TESTFRAME};
|
|
|
|
|
|
Builder<ont::ConfMan> builder{spec};
|
|
|
|
|
|
return builder;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-02-10 22:48:31 +01:00
|
|
|
|
/**
|
|
|
|
|
|
* Initiate configuration for a mixing-node to combine TestFrame(s)
|
|
|
|
|
|
*/
|
|
|
|
|
|
inline auto
|
|
|
|
|
|
TestRandOntology::setupCombinator()
|
|
|
|
|
|
{
|
|
|
|
|
|
Spec spec{"combine", ont::TYPE_TESTFRAME};
|
|
|
|
|
|
Builder<ont::ConfMix> builder{spec};
|
|
|
|
|
|
return builder;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-28 23:41:56 +01:00
|
|
|
|
/** Singleton accessor */
|
|
|
|
|
|
extern lib::Depend<TestRandOntology> testRand;
|
2024-06-29 04:23:55 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}}} // namespace steam::engine::test
|
|
|
|
|
|
#endif
|