Home /Modules/slrtp/SLRTPAspect.sleela

SLRTPAspect.sleela

lib/slrtp/SLRTPAspect.sleela · 83 line(s) · sleela

<< lib/slrtp/SLRTPAspect.sleela
   SLeeLa Standard Library Definition.
   Definition: An SLRTP aspect -- a named bundle of advice that address one
   cross-cutting concern (tracing, metering, access control), akin to a
   Java/AspectJ @Aspect. An aspect collects its advice, then installs them all
   into an SLRTPProcessor in one call, so a concern is enabled or disabled as a
   unit. >>
#sleela 3.0
material;
class SLRTPAspect {
  < ---- 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 = 0;
  String metaAuthor = "Max Rupplin";
  String metaDate = "2026-11-06";
  String metaCopyright = "SLeeLa project";
  String metaTrademark = "none";
  String metaCorporation = "MEARVK LLC";
  < metaOrigin: National | <nation> | International | Galactic >
  String metaOrigin = "International";
  String metaBirthDate = "2026-11-06";
  < metaScienceRating: maturity/robustness on a 1..10 scale >
  int metaScienceRating = 7;
  < 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; }

  String name = "aspect";
  int MAX_ADVICE = 32;
  SLRTPAdvice[] advice = new SLRTPAdvice[32];
  int adviceCount = 0;

  void named(String aspectName) { name = aspectName; }
  String getName() { return name; }
  int getAdviceCount() { return adviceCount; }

  << Add one advice to this aspect. Returns false when the aspect is full. >>
  boolean add(SLRTPAdvice a) {
    if (adviceCount >= MAX_ADVICE) { return false; }
    advice[adviceCount] = a;
    adviceCount = adviceCount + 1;
    return true;
  }

  << Install every advice this aspect holds into a processor, in order. Returns
     the number installed. >>
  int installInto(SLRTPProcessor p) {
    int installed = 0;
    int i = 0;
    while (i < adviceCount) {
      SLRTPAdvice a = advice[i];
      if (p.register(a) >= 0) { installed = installed + 1; }
      i = i + 1;
    }
    return installed;
  }
}