Home /Modules/advantage/SLAdvantageDividend.sleela

SLAdvantageDividend.sleela

lib/advantage/SLAdvantageDividend.sleela · 131 line(s) · sleela

<< lib/advantage/SLAdvantageDividend.sleela
   SLeeLa Standard Library Definition.
   Definition: The unique dividend that the onion model advantages, held with
   respect to a named model. >>
#sleela 3.0
material;
artifact;
pure;
gasoline;
< The dividend is the value being advantaged. It is "unique" in that it carries >
< its own identity (a label) and is held "with respect to a model" (a named >
< frame of reference). The onion layers mutate the running value; the dividend >
< remembers its base, its current value, and the net advantage gained. >
class SLAdvantageDividend {
  < ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- >
  << Eleven catalogued attributes with getter/setter pairs, so a GUI, loader,
     or catalog can read and (where appropriate) override this record.
     Values are faithful to the subject's real origin where publicly known. >>
  String metaVersion = "1.0.0";
  int metaId = 10512;
  String metaAuthor = "Kiro Agent";
  String metaDate = "2026-11-08";
  String metaCopyright = "SLeeLa project";
  String metaTrademark = "none";
  String metaCorporation = "none";
  < metaOrigin: National | <nation> | International | Galactic >
  String metaOrigin = "International";
  String metaBirthDate = "2026-11-08";
  < metaScienceRating: maturity/robustness on a 1..10 scale >
  int metaScienceRating = 8;
  < metaNationalSchedule: a real, citable instrument or "none" >
  String metaNationalSchedule = "none";

  String getMetaVersion() { return metaVersion; }
  void setMetaVersion(String v) { metaVersion = v; }
  int getMetaId() { return metaId; }
  void setMetaId(int v) { metaId = v; }
  String getAuthor() { return metaAuthor; }
  void setAuthor(String v) { metaAuthor = v; }
  String getDate() { return metaDate; }
  void setDate(String v) { metaDate = v; }
  String getCopyright() { return metaCopyright; }
  void setCopyright(String v) { metaCopyright = v; }
  String getTrademark() { return metaTrademark; }
  void setTrademark(String v) { metaTrademark = v; }
  String getCorporation() { return metaCorporation; }
  void setCorporation(String v) { metaCorporation = v; }
  String getOrigin() { return metaOrigin; }
  void setOrigin(String v) { metaOrigin = v; }
  String getBirthDate() { return metaBirthDate; }
  void setBirthDate(String v) { metaBirthDate = v; }
  int getScienceRating() { return metaScienceRating; }
  void setScienceRating(int v) { metaScienceRating = v; }
  String getNationalSchedule() { return metaNationalSchedule; }
  void setNationalSchedule(String v) { metaNationalSchedule = v; }

  < ---- Dividend state ---- >
  < the unique identity of this dividend >
  String label;
  < the model (frame of reference) it is held with respect to >
  String model;
  < the party to whose advantage the model is tuned >
  String owner;
  < the starting value before any layer is applied >
  int base;
  < the running value as layers are applied >
  int current;

  < ---- Original snapshot, captured at configure() for full restitute ---- >
  String originalLabel;
  String originalModel;
  String originalOwner;
  int originalBase;

  void configure(String lbl, String mdl, int baseValue) {
    label = lbl;
    model = mdl;
    owner = "unknown";
    base = baseValue;
    current = baseValue;
    snapshot();
  }

  < Record the current identity as the restitution point. >
  void snapshot() {
    originalLabel = label;
    originalModel = model;
    originalOwner = owner;
    originalBase = base;
  }

  String getLabel() { return label; }
  String getModel() { return model; }
  String getOwner() { return owner; }
  void setOwner(String o) { owner = o; }
  int getBase() { return base; }
  int getCurrent() { return current; }
  void setCurrent(int v) { current = v; }

  < ---- Dynamic update: re-point the model without losing the snapshot. ---- >
  < Pass null for any field to leave it unchanged. The original snapshot is >
  < preserved so a later restitute() can undo every change at once. >
  void updateModel(String newModel, String newLabel, int newBase) {
    if (newModel != null) { model = newModel; }
    if (newLabel != null) { label = newLabel; }
    base = newBase;
    current = newBase;
  }

  < ---- Full restitute: restore the dividend to its original identity. ---- >
  void restitute() {
    label = originalLabel;
    model = originalModel;
    owner = originalOwner;
    base = originalBase;
    current = originalBase;
  }

  < The net advantage: how far the dividend has moved from its base. >
  int advantage() { return current - base; }

  < Reset the running value back to the base for a fresh pass. >
  void rebase() { current = base; }

  String describe() {
    return "dividend '" + label + "' wrt model '" + model + "' (owner '"
         + owner + "'): base=" + base + " current=" + current
         + " advantage=" + advantage();
  }
}