Home /Modules/philosophy/SLPhilosophyNode.sleela

SLPhilosophyNode.sleela

lib/philosophy/SLPhilosophyNode.sleela · 90 line(s) · sleela

<< lib/philosophy/SLPhilosophyNode.sleela
   SLeeLa Standard Library Definition.
   Definition: one Node of a philosophy Tree -- a branch with an ordering key,
   left/right child ids, a weight, and the Item it carries. >>
#sleela 2.5
material;
< Family: philosophy. A Node is the base structural unit of the Tree. It keys >
< on a unique id for ordering, points to left/right child ids (0 = none), >
< holds a weight in [1,9] matching the consistency tool, and carries one Item. >
< Nodes are assigned into a Tree; the Tree owns ordering and balance. >
class SLPhilosophyNode {
  int nodeId;
  int leftId;
  int rightId;
  int height;
  int weight;
  int itemId;

  void configure(int id, int w, int carriedItemId) {
    nodeId = id;
    leftId = 0;
    rightId = 0;
    height = 1;
    weight = w;
    itemId = carriedItemId;
  }

  int getNodeId() { return nodeId; }
  void setNodeId(int v) { nodeId = v; }
  int getLeftId() { return leftId; }
  void setLeftId(int v) { leftId = v; }
  int getRightId() { return rightId; }
  void setRightId(int v) { rightId = v; }
  int getHeight() { return height; }
  void setHeight(int v) { height = v; }
  int getWeight() { return weight; }
  void setWeight(int v) {
    < weight stays within the [1,9] band the consistency tool enforces >
    if (v < 1) { weight = 1; }
    if (v > 9) { weight = 9; }
    if (v >= 1 && v <= 9) { weight = v; }
  }
  int getItemId() { return itemId; }
  void setItemId(int v) { itemId = v; }

  boolean isLeaf() { return leftId == 0 && rightId == 0; }

  < ---- 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 real origin of the subject where publicly known. >>
  String metaVersion = "1.0.0";
  int metaId = 10421;
  String metaAuthor = "Kiro Agent";
  String metaDate = "2026-10-30";
  String metaCopyright = "SLeeLa project";
  String metaTrademark = "none";
  String metaCorporation = "none";
  < metaOrigin: National | <nation> | International | Galactic >
  String metaOrigin = "International";
  String metaBirthDate = "2026-10-30";
  < 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; }
}