From 1da5d5709895d7e0ad7797b665006151f249f74a Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sun, 1 Jun 2025 02:44:40 +0200 Subject: [PATCH] clean-up: `RefArray` is gone (closes: #473) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After the leftovers of the first Render-Engine implementation attempt were removed, only one further usage of `RefArray` remains to be sorted out: the ''Session Element Tracker''. Luckily, this one did not actually make any use of the abstraction abilities of the `RefArray` — rather it basically stated that ''the interface is a data structure...'' After considering ''what kind of data'' can be expected to live in this structure, it became clear that ''this will be a symbolic representation'' And thus the container can be simply switched to a `std::vector`. This change allows to retain the existing placeholder-implementation unaffected, while it would be possible to maintain algebraic terms here, in future. __As an asside__: in order to decide about a suitable replacement in the Session, I had to consier a first draft regarding the intended usage and the prospective way of content representation --- src/lib/element-tracker.hpp | 4 +- src/lib/ref-array-impl.hpp | 168 -------------- src/lib/ref-array.hpp | 54 ----- src/steam/mobject/session.hpp | 10 +- tests/15library.tests | 5 - tests/library/ref-array-test.cpp | 238 -------------------- wiki/thinkPad.ichthyo.mm | 367 ++++++++++++++++++++++++++++++- 7 files changed, 366 insertions(+), 480 deletions(-) delete mode 100644 src/lib/ref-array-impl.hpp delete mode 100644 src/lib/ref-array.hpp delete mode 100644 tests/library/ref-array-test.cpp diff --git a/src/lib/element-tracker.hpp b/src/lib/element-tracker.hpp index 6c865cd5a..d38658094 100644 --- a/src/lib/element-tracker.hpp +++ b/src/lib/element-tracker.hpp @@ -55,8 +55,8 @@ #include "lib/p.hpp" #include "lib/optional-ref.hpp" #include "lib/util-foreach.hpp" -#include "lib/ref-array-impl.hpp" +#include namespace lib { @@ -79,7 +79,7 @@ namespace lib { */ template class ElementTracker - : public lib::RefArrayVector> + : public std::vector> { using _Vec = std::vector>; using Iter = typename _Vec::iterator; diff --git a/src/lib/ref-array-impl.hpp b/src/lib/ref-array-impl.hpp deleted file mode 100644 index e42dd04d5..000000000 --- a/src/lib/ref-array-impl.hpp +++ /dev/null @@ -1,168 +0,0 @@ -/* - REF-ARRAY-IMPL.hpp - some implementations of the ref-array interface - - Copyright (C) - 2008, Hermann Vosseler - -  **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 ref-array-impl.hpp - ** Some (library-) implementations of the RefArray interface. - ** - ** Being an array-like object exposing just a const ref, it is typically used - ** on interfaces, and the type of the array "elements" usually is a ABC or interface. - ** The actual implementation typically holds a subclass, and is either based on a vector, - ** or a fixed storage contained within the implementation. The only price to pay is - ** a virtual call on element access. - ** - ** For advanced uses it would be possible to have a pointer-array or even an embedded - ** storage of variant-records, able to hold a mixture of subclasses. (the latter cases - ** will be implemented when needed). - ** - ** @deprecated 5/2025 to be reworked and obsoleted — do not use further - ** @see several-builder.hpp - ** @see ref-array-test.cpp - ** - */ - - -#ifndef LIB_REF_ARRAY_IMPL_H -#define LIB_REF_ARRAY_IMPL_H - - -#include "lib/ref-array.hpp" -#include "include/logging.h" - -#include -using std::vector; - - - -namespace lib { - - /** - * Wrap a vector holding objects of a subtype and - * provide array-like access using the interface type. - */ - template - class RefArrayVectorWrapper - : public RefArray - { - typedef vector const& Tab; - Tab table_; - - public: - - RefArrayVectorWrapper (Tab toWrap) - : table_(toWrap) - { } - - virtual size_t size() const - { - return table_.size(); - } - - virtual B const& operator[] (size_t i) const - { - REQUIRE (i < size()); - return table_[i]; - } - }; - - - /** - * This variation of the wrapper actually - * \em is a vector, but can act as a RefArray - */ - template - class RefArrayVector - : public vector, - public RefArrayVectorWrapper - { - typedef RefArrayVectorWrapper Wrap; - typedef vector Vect; - typedef typename Vect::size_type Size_t; - typedef typename Vect::value_type Val_t; - - public: - RefArrayVector() : Vect(), Wrap((Vect&)*this) {} - RefArrayVector(Size_t n, Val_t const& v = Val_t()) : Vect(n,v), Wrap((Vect&)*this) {} - RefArrayVector(Vect const& ref) : Vect(ref), Wrap((Vect&)*this) {} - - using Vect::size; - using Wrap::operator[]; - }; - - - - /** - * RefArray implementation based on a fixed size array, - * i.e. the storage is embedded. Embedded subclass obj - * either need to be default constructible or be - * placed directly by a factory - */ - template - class RefArrayTable - : public RefArray - { - char storage_[n*sizeof(IM)]; - IM* array_; - - public: - RefArrayTable() ///< objects created in-place by default ctor - : array_ (reinterpret_cast (&storage_)) - { - size_t i=0; - try - { - while (i - RefArrayTable(FAC& factory) ///< objects created in-place by factory - : array_ (reinterpret_cast (&storage_)) - { - size_t i=0; - try - { - while (i - -  **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 ref-array.hpp - ** Abstraction interface: array-like access by subscript - ** @todo as of 2016, this concept seems very questionable: do we _really_ want - ** to abstract over random access, or do we _actually_ want for-iteration?? - ** @deprecated 5/2025 to be obsoleted by a similar design - ** @see several.hpp - */ - - -#ifndef LIB_REF_ARRAY_H -#define LIB_REF_ARRAY_H - - -#include "lib/nocopy.hpp" - - -namespace lib { - - /** - * Abstraction: Array of const references. - * Typically the return type is an interface, - * and the Implementation wraps some datastructure - * holding subclasses. - * @todo ouch -- a collection that isn't iterable... ///////////////////////TICKET #1040 - * @warning in rework 5/2025 - */ - template - class RefArray - : util::NonCopyable - { - public: - virtual ~RefArray() {} ///< this is an interface - - virtual T const& operator[] (size_t i) const =0; - virtual size_t size() const =0; - }; - - -} // namespace lib -#endif diff --git a/src/steam/mobject/session.hpp b/src/steam/mobject/session.hpp index 62e007a99..011b2c889 100644 --- a/src/steam/mobject/session.hpp +++ b/src/steam/mobject/session.hpp @@ -44,12 +44,12 @@ #include "steam/mobject/placement.hpp" #include "steam/mobject/mobject-ref.hpp" #include "common/query/defs-manager.hpp" ////////////////////////////TICKET #643 forward declare this? -#include "lib/ref-array.hpp" #include "lib/depend.hpp" #include "lib/symbol.hpp" #include "lib/p.hpp" #include +#include @@ -101,10 +101,10 @@ namespace mobject { : util::NonCopyable { protected: - typedef lumiera::query::DefsManager& DefaultsAccess; - typedef session::ElementQuery& ElementsAccess; - typedef lib::RefArray& TimelineAccess; - typedef lib::RefArray& SequenceAccess; + typedef lumiera::query::DefsManager& DefaultsAccess; + typedef session::ElementQuery& ElementsAccess; + typedef std::vector const& TimelineAccess; + typedef std::vector const& SequenceAccess; Session (DefaultsAccess, diff --git a/tests/15library.tests b/tests/15library.tests index f5932dbbc..262d6d227 100644 --- a/tests/15library.tests +++ b/tests/15library.tests @@ -552,11 +552,6 @@ return: 0 END -TEST "RefArray_test" RefArray_test < [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ] out-lit: removed 0 ---> [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ] diff --git a/tests/library/ref-array-test.cpp b/tests/library/ref-array-test.cpp deleted file mode 100644 index db7472e12..000000000 --- a/tests/library/ref-array-test.cpp +++ /dev/null @@ -1,238 +0,0 @@ -/* - RefArray(Test) - unittest for wrapping with array-of-refs access - - Copyright (C) - 2008, Hermann Vosseler - -  **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 ref-array-test.cpp - ** unit test \ref RefArray_test - ** @deprecated 5/2024 rework underway - ** @see several-buider-test.cpp - */ - - -#include "lib/test/run.hpp" -#include "lib/util.hpp" - -#include "lib/ref-array-impl.hpp" - -#include - -using ::test::Test; -using std::vector; - - -namespace lib { -namespace test{ - - namespace { // test types - - struct I - { - virtual int op(int i) const =0; - virtual ~I() {} - }; - - struct Sub1 : I - { - int offs_; - - Sub1 (int o=1) : offs_(o) {} - - int op (int i) const { return i+offs_; } - }; - - struct Sub2 : I - { - const char* letterz_; - Sub2() : letterz_("ABCDEFGHIJKLMNOPQRSTUVWXYZ") {} - - int op (int i) const { return (int)letterz_[i % 26]; } - }; - - struct Sub3 : I - { - int id_; - static long sum; - static long trigger; - - Sub3(int id) : id_(id) - { - sum +=id_; - if ( id_ == trigger ) - throw trigger; // fail while in construction - } - ~Sub3() - { - sum -=id_; - } - - int op (int i) const { return i + id_; } - }; - - long Sub3::sum = 0; - long Sub3::trigger = -1; - - - } // (END) test types - - - - - - - - /***************************************************************//** - * @test build several wrappers, each based on a different storage, - * all providing RefArray access to a given vector. The rationale - * for RefArray is to expose just the interface: the data structure - * within the actual implementation holds subclass instances of - * the specified interface. - * - RefArrayVectorWrapper is a ref to an existing vector - * - RefArrayVector subclasses std::vector - * - RefArrayTable holds a fix sized table, i.e. embedded storage - * - * @see ref-array-impl.hpp - */ - class RefArray_test : public Test - { - - virtual void - run (Arg) - { - seedRand(); - - checkWrapper(); - checkVector(); - checkTable(); - checkTable_inplaceCreation(); - checkTable_errorHandling(); - } - - - - void - checkWrapper() - { - vector subz(10); - RefArrayVectorWrapper subWrap (subz); - - RefArray & rArr (subWrap); - - CHECK (subWrap.size()==subz.size()); - CHECK (INSTANCEOF(I, &rArr[0])); - for (size_t i=0; i subz(10); - - vector & vect (subz); - RefArray & rArr (subz); - - CHECK (vect.size()==subz.size()); - CHECK (INSTANCEOF(I, &rArr[0])); - for (size_t i=0; i tab; - // creates 20 Sub1-objects in-place - // which are indeed located within the object - CHECK (sizeof(tab) >= 20 * sizeof(Sub1)); - CHECK (ADR(tab) < ADR(tab[19]) && ADR(tab[19]) < ADR(tab) + sizeof(tab)); - - RefArray & rArr (tab); - - CHECK (20 == tab.size()); - CHECK (INSTANCEOF(I, &rArr[0])); - for (size_t i=0; i - struct Fac ///< fabricating a series of subclass instances with varying ctor parameter - { - int offset_; - Fac ( ) : offset_ (0) {} - - void operator() (void* place) - { - CHECK (place); - new(place) SUB (offset_++); // note: varying ctor parameter - } - }; - - - void - checkTable_inplaceCreation() - { - Fac theFact; - RefArrayTable tab (theFact); - RefArray & rArr (tab); - CHECK (30 == tab.size()); - for (size_t i=0; i factory; - RefArrayTable table (factory); - CHECK (Sub3::sum == (29+1)*29/2); - } - CHECK (Sub3::sum == 0); - } - - catch(long id) - { - CHECK (id == Sub3::trigger); - CHECK (Sub3::sum == id); - // meaning: all objects have been cleaned up, - // with the exception of the one hitting the trigger - } } - } - }; - - - - /** Register this test class... */ - LAUNCHER (RefArray_test, "unit common"); - - - -}} // namespace lib::test diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 8907af842..5987a1712 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -75156,6 +75156,7 @@ + @@ -75362,6 +75363,10 @@ + + + + @@ -159241,6 +159246,234 @@ unsigned int ThreadIdAsInt = *static_cast<unsigned int*>(static_cast<vo + + + + +

+ Lumiera verarbeitet vor allem Metadaten +

+ +
+ + + + +

+ High-Level: die Session ist ein Syntax-Baum mit Attribution +

+ +
+ + + + + +

+ Auf konzeptioneller Ebene +

+

+ und für das UI : klar gegeben +

+ +
+ + + + + + + + + + + + + + + + + + +

+ das Command steht für einen Satz, +

+

+ der einen Auftrag erteilt +

+ +
+
+ + + + + +

+ diese Forderung kann in doppelter Hinsicht verstanden werden... +

+
    +
  • + wenn ich schon eine Instruktion habe, muß ich vom Subjekt alle weiteren Beteiligten erreichen können; im Besonderen einen Kontext, in dem sich das Subjekt befindet, und welcher eigentlich eine koordinierte Aktion vollziehen muß, um die Instruktion zu verwirklichen +
  • +
  • + das Command und damit die Instruktion ist so anzuordnen, daß das Subjekt der Instruktion die notwendige Souveränität hat, um die Instruktion vollumfänglich zu verwirklichen +
  • +
+ +
+
+ + + + + + +

+ ....denn andernfalls werden mit hoher Wahrscheinlichkeit fehlerhaft bzw. unvollständig definierte Commands auftreten +

+ +
+
+
+
+ + + + +

+ auf welcher Art Repräsentation +

+

+ wird in der Session gearbeitet? +

+ +
+ + + + + + + +
    +
  • + Wobei unter Business-Logik verstanden wird, daß gewisse Verarbeitungs-Schemata, die sich an der Target-Domain orientieren, direkt in Code zur Datenverarbeitung übersetzt worden sind. Man kann dann „im Code sehen was das System macht“. +
  • +
  • + Das andere Extrem wäre, wenn ein System lediglich eine Meta-Verarbeitung implementiert, wähend Logik und Inhalt der Verarbeitung in Parametern und Arbeitsdaten steckt. +
  • +
  • + Ein Zwischending wäre die »Pinball-Machine«: bei dieser steckt die Verarbeitungs-Struktur in der Verschaltung, über welche Ereignisse weitergeleitet und beantwortet werden +
  • +
+ +
+ + + + +

+ überwiegend geht es darum, verbundene oder betroffene weitere Objekte zu finden, oder einen Kontext zu erlangen +

+ +
+
+ + + + +

+ denn das Command bestimmt was getan werden soll — ob das dann tatsächlich passiert, oder gar weitere Konsequenzen hat, stellt sich in der Verarbeitung heraus und wird als Ergebnis-Feedback asynchron zurückgemeldet +

+ +
+
+
+ + + + + + + + + + +

+ und zwar „natürlich“ aus Sicht dessen, was hier geschieht, also aus Sicht der Implementierung. Dem würde eine technische / Meta-Schnittstelle entsprechen, auf der man eine Art »instruction code« absetzt +

+ +
+
+ + + + +

+ Es wird also definitiv nicht »der Clip« den Code enthalten, wie er sich selber rendert, oder »der Track« den Code enhalten, mit dem Mediendaten kombiniert und verarbeitet werden. +

+ +
+
+ + + + +

+ und zwar muß das einzelne Objekt im Stande sein, beliebige, lokal opaque aber stukturierte Daten zu transportieren +

+ +
+
+ + + + + + + + + + + + + + + + +

+ Und nicht mit Referenz-Semantik, wie ursprünglich beabsichtigt. All die smart-Pointer mit angebundenem Memory-Management fallen weg; stattdessen arbeiten wir pervasiv mit EntryIDs. Placements liegen nur noch im Placement-Index, werden aber extern ausschließlich als ID-basierte Referenzen gehandhabt +

+ +
+
+ + + + +

+ Objekte sind stets vergleichsweise klein. Wo das schwierig wird, arbeiten wir mit Proxies (z.B. lib::Literal oder lib::Symbol für Strings). Zu einer gegebenen EntryID kann man stets eine Objekt-Kopie bekommen; auch ein Command bezieht solche Kopien, um darauf eine Methode aufzurufen, welche intern, über Session-Services die entsprechenden Events auslösen. Auch der nachfolgende Builder-Lauf zieht sich eine Kopie des Session-Inhalts +

+ +
+
+ + + + +
+ + + + +

+ Low-Level: die Nodes sind ein funktionaler Aufruf-Plan +

+ +
+
+
@@ -163455,13 +163688,14 @@ Since then others have made contributions, see the log for the history.
- + - + + @@ -163804,7 +164038,7 @@ Since then others have made contributions, see the log for the history. - + @@ -163813,9 +164047,7 @@ Since then others have made contributions, see the log for the history. - - - +

ein Müll-Header mit einem Dummy-Test, der seit > 10 Jahren herumliegt, und alle wichtigen Probleme nicht löst ... @@ -163824,8 +164056,7 @@ Since then others have made contributions, see the log for the history.dann kann man auch gleich von Null anfangen

- - + @@ -163834,6 +164065,126 @@ Since then others have made contributions, see the log for the history. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ der nächste »Vertical Slice« wird das entscheiden müssen +

+ +
+ + + +

+ denn im nächsten Slice wird das Agens festgelegt, auf dem der Builder arbeitet.... +

+

+ Daran wird sich dann anmessen, was für eine Repräsentation in der Session liegt  +

+ +
+
+
+ + + + + + + + + +

+ man könnte also RefArray durch eine const vector&  ersetzen +

+ +
+ + + + + + + + +
+
+
+
+ + + + + + + +

+ weil zum Glück +

+

+ die Abstraktions-Eigenschaft +

+

+ gar nicht verwendet wurde +

+ +
+ +
+