Home /Modules/registry/SLRegistryValue.sleela

SLRegistryValue.sleela

lib/registry/SLRegistryValue.sleela · 83 line(s) · sleela

<< lib/registry/SLRegistryValue.sleela
   SLeeLa Standard Library Definition.
   Definition: Defines SLRegistryValue — the OOD equivalent of a native registry
     value (registry/sleela_registry.* : a name -> typed scalar). A value holds
     one setting or feature flag under a key: a string, an int, or a boolean,
     tagged by kind. It is the leaf the registry stores and the terminal review
     renders. Pure data + accessors; the native store owns persistence.
   
   Mirrors: enum sl_reg_kind (STRING/INT/BOOL) and the value cell.
   
   Family: registry. Composed by SLRegistryKey. >>
#sleela 3.0
material;
class SLRegistryValue {
  < ---- 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 = 11098;
  String metaAuthor = "Kiro Agent";
  String metaDate = "2026-10-16";
  String metaCopyright = "SLeeLa project";
  String metaTrademark = "none";
  String metaCorporation = "none";
  < metaOrigin: National | <nation> | International | Galactic >
  String metaOrigin = "International";
  String metaBirthDate = "2026-10-14";
  < metaScienceRating: maturity/robustness on a 1..10 scale >
  int metaScienceRating = 9;
  < 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; }
  static final int KIND_STRING = 0;
  static final int KIND_INT    = 1;
  static final int KIND_BOOL   = 2;

  String name;
  int    kind;
  < when KIND_STRING >
  String s;
  < when KIND_INT >
  int    i;
  < when KIND_BOOL (0/1) >
  int    b;

  void setString(String n, String value) { name = n; kind = KIND_STRING; s = value; }
  void setInt(String n, int value)        { name = n; kind = KIND_INT; i = value; }
  void setBool(String n, boolean value)   { name = n; kind = KIND_BOOL; b = value ? 1 : 0; }

  boolean isString() { return kind == KIND_STRING; }
  boolean isInt()    { return kind == KIND_INT; }
  boolean isBool()   { return kind == KIND_BOOL; }

  String render() {
    if (kind == KIND_STRING) { return name + " = \"" + s + "\""; }
    if (kind == KIND_INT)    { return name + " = " + i; }
    return name + " = " + (b == 1 ? "true" : "false");
  }
}