Parameters: preliminary requirement analysis

In the current stage, a design-draft is required that is sufficiently adequate
to be used as code placeholder and to evolve into the full specification eventually.

 - we need a single parameter container type with value semantics
 - parameters must support a selection of basic value types, with conversions
 - the value range can be limited, and a parameter can be associated
   with a ''Scale'' (stepped, continuous, logarithmic)
 - a parameter can be linked to a functional source
 - parameters are (virtually) copyable
This commit is contained in:
Fischlurch 2026-07-03 19:55:55 +02:00
parent 36684ff092
commit 5df0252cc1
6 changed files with 1674 additions and 10 deletions

63
src/lib/par/domain.hpp Normal file
View file

@ -0,0 +1,63 @@
/*
DOMAIN.hpp - represent the value domain of parameters
Copyright (C)
2026 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 domain.hpp
** Specification of a base type and a value domain for parameters.
** A Domain descriptor implicitly also encodes the concrete value type
** and exposes a set of virtual functions to handle all supported value conversions.
** Implementing this interface creates a conversion matrix and allows to implement
** generic conversions by double-dispatch. Since virtual interfaces must be complete
** at compile time however, such an approach requires to define a finite set of
** supported parameter value types, which seems adequate, since the universe
** of possible values is limited anyway: elementary values in parameters
** must be primitive base types that can be created and destroyed
** without side effect. Relying on the further features of
** the parameter type system, compound types (vectors)
** and limited sub-scales can be defined.
**
** @todo WIP-WIP-WIP this is a draft and placeholder, as of 2026
*/
#ifndef LIB_PAR_DOMAIN_H
#define LIB_PAR_DOMAIN_H
namespace lib {
namespace par {
/**
* Interface: mark the allowed value domain of a parameter value.
* The identity of the actual implementation can be used as type descriptor,
* since all concrete full base domains are registered at compile time; the
* virtual Domain interface exposes the possible conversions.
* @todo 7/2026 not clear if we can support all conversions unconditionally,
* or if some notion of an _impossible conversion_ is required. It is
* clear however, that the access to an actual parameter **must fail**
* at compile time, if a sensible conversion can not be provided.
*/
class Domain
{
public:
virtual ~Domain(); ///< this is an interface
};
}} // namespace lib::par
#endif /*LIB_PAR_DOMAIN_H*/

View file

@ -0,0 +1,37 @@
/*
ParamType - parameter scale and type descriptor
Copyright (C)
2026 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 param-type.cpp
** Implementation of parameter type registration.
**
** @todo WIP-WIP-WIP can be considered an initial draft and placeholder, as of 2026
*/
#include "lib/error.hpp"
#include "lib/par/parameter.hpp"
#include "lib/par/param-type.hpp"
namespace lib {
namespace par {
/* emit VTables in this translation unit... */
ParamType::~ParamType() { }
Domain::~Domain() { }
}} // namespace lib::par

View file

@ -0,0 +1,52 @@
/*
PARAM-TYPE.hpp - parameter scale and type descriptor
Copyright (C)
2026 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 param-type.hpp
** Specification of the value domain and scale of a parameter.
** A ParamType descriptor implicitly also encodes the concrete value type, the
** allowed value range, clipping behaviour and specifics of the scale (discrete,
** stepping, continuous, logarithmic...).
**
** @todo WIP-WIP-WIP can be considered an initial draft and placeholder, as of 2026
*/
#ifndef LIB_PAR_PARAM_TYPE_H
#define LIB_PAR_PARAM_TYPE_H
#include "lib/par/domain.hpp"
namespace lib {
namespace par {
/**
* Interface: represent a specific configuration of parameter value type,
* range and scale. Every ParamType descriptor is also a _prototype_ and has
* an unique identity, ensured by registration, so that it acts as a type identifier.
* Furthermore, the interface exposes allowed conversion and conforming operations.
*/
class ParamType
{
public:
virtual ~ParamType(); ///< this is an interface
};
}} // namespace lib::par
#endif /*LIB_PAR_PARAM_TYPE_H*/

View file

@ -5,3 +5,8 @@ TESTING "Library Test Suite: parameters" ./test-suite --group=param
PLANNED "Parameter Values" Parameter_test <<END
return: 0
END
PLANNED "Parameter Domain Type" ParameterDomain_test << END
return: 0
END

View file

@ -0,0 +1,94 @@
/*
ParameterDomain(Test) - document the handling of parameter type domain
Copyright (C)
2026, 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 parameter-domain-test.cpp
** unit test \ref ParameterDomain_test
*/
#include "test/run.hpp"
//#include "test/test-helper.hpp"
#include "lib/par/domain.hpp"
//#include "lib/format-cout.hpp"
//#include <utility>
//#include <string>
//#include <vector>
//using std::string;
//using std::vector;
//using std::swap;
namespace lib {
namespace par {
namespace test{
// using lumiera::error::LUMIERA_ERROR_LOGIC;
namespace {//Test fixture....
class Thing
{ };
template<typename X>
struct Some
{
X x;
};
typedef Some<Thing> SomeThing;
}//(End)Test fixture
/**************************************************************************//**
* @test cover properties of generic parameter containers.
*/
class ParameterDomain_test : public Test
{
virtual void
run (Arg)
{
simpleUsage();
verify_typeMarker();
}
void
simpleUsage()
{
}
void
verify_typeMarker()
{
}
};
/** Register this test class... */
LAUNCHER (ParameterDomain_test, "unit lib");
}}} // namespace lib::par::test

File diff suppressed because it is too large Load diff