public Extract(Module module, ModuleSubscribe sub, ITree node) { if (node.Type != SpicaMLLexer.EXTRACT) { throw new CException("Annotations.Extract: Unable to create extract request, wrong node type! ({0})", module.Details); } if (node.ChildCount < 2) { throw new CException("Annotations.Extract: Unable to create extract request, wrong number of children! ({0})", module.Details); } this.module = module; this.sub = sub; this.field = new List<string>(); this.annotations = new List<Annotations.Annotation>(); // Set default values this.dmc = module.subExtractDefaultDMC; this.ttl = module.subExtractDefaultTTL; for (int i = 0; i < node.ChildCount; i++) { ITree n = node.GetChild(i); switch (n.Type) { case SpicaMLLexer.FIELDSPEC: for (int j = 0; j < n.ChildCount; j++) { this.field.Add(n.GetChild(j).Text); } break; case SpicaMLLexer.TYPE: if (n.ChildCount < 1) { throw new CException("Annotations.Extract: Unable to create extract request, wrong number of children for the type name! ({0})", module.Details); } this.typename = n.GetChild(0).Text; break; case SpicaMLLexer.DMC: this.dmc = module.GetDMC(n); break; case SpicaMLLexer.TTL: this.ttl = module.GetTTL(n); break; } } }
public Module(ITree node, string filename, string package, IList<string> ns) : base(node, filename, package, ns) { if ((node == null) || (node.Type != SpicaMLLexer.MODULE)) { throw new CException("Module: Unable to create module, {0}!", (node == null ? "no node passed" : "no struct node passed")); } this.subs = new List<ModuleSubscribe>(); this.pubs = new List<ModulePublish>(); // Scan the children of this structure and extract all relevant data for (int j = 0; j < node.ChildCount; j++) { switch (node.GetChild(j).Type) { // Extract name of this structure case SpicaMLLexer.TYPENAME: Name = GetTypeName(node.GetChild(j)); break; // Extract publication defaults case SpicaMLLexer.PUBDEF: switch (node.GetChild(j).Type) { case SpicaMLLexer.DMC: this.pubDefaultDMC = GetDMC(node.GetChild(j)); break; case SpicaMLLexer.PERIOD: this.pubDefaultPeriod = GetPeriod(node.GetChild(j)); break; case SpicaMLLexer.DST: this.pubDefaultDst = GetSource(node.GetChild(j)); break; case SpicaMLLexer.TTL: this.pubDefaultTTL = GetTTL(node.GetChild(j)); break; } break; // Extract publications case SpicaMLLexer.PUB: this.pubs.Add(new ModulePublish(this, node.GetChild(j), Filename, Package, Namespace)); break; // Extract subscription defaults case SpicaMLLexer.SUBDEF: switch (node.GetChild(j).Type) { case SpicaMLLexer.DMC: this.subDefaultDMC = GetDMC(node.GetChild(j)); break; case SpicaMLLexer.PERIOD: this.subDefaultPeriod = GetPeriod(node.GetChild(j)); break; case SpicaMLLexer.SRC: this.subDefaultSrc = GetSource(node.GetChild(j)); break; case SpicaMLLexer.TYPE: this.subDefaultType = GetType(node.GetChild(j)); break; case SpicaMLLexer.TTL: this.subDefaultTTL = GetTTL(node.GetChild(j)); break; } break; // Extract subscription extraction defaults case SpicaMLLexer.SUBEXDEF: switch (node.GetChild(j).Type) { case SpicaMLLexer.DMC: this.subExtractDefaultDMC = GetDMC(node.GetChild(j)); break; case SpicaMLLexer.TTL: this.subExtractDefaultTTL = GetTTL(node.GetChild(j)); break; } break; // Extract subscriptions case SpicaMLLexer.SUB: this.subs.Add(new ModuleSubscribe(this, node.GetChild(j), Filename, Package, Namespace)); break; } } if (Name == null) { throw new CException("Module: Unable to create module, no name given!"); } }
public ModuleSubscribe(Module module, ITree node, string filename, string package, IList<string> ns) : base(node, filename, package, ns) { if (node.Type != SpicaMLLexer.SUB) { throw new CException("Module: Unable to create subscription request, wrong node type! ({0})", module.Details); } if (node.ChildCount < 1) { throw new CException("Module: Unable to create subscription request, wrong number of children! ({0})", module.Details); } this.module = module; Name = node.GetChild(0).Text; this.annDMC = this.module.subDefaultDMC; this.annSrc = this.module.subDefaultSrc; this.annPeriod = this.module.subDefaultPeriod; this.annType = this.module.subDefaultType; this.annTTL = this.module.subDefaultTTL; this.extract = new List<Annotations.Extract>(); for (int i = 1; i < node.ChildCount; i++) { switch (node.GetChild(i).Type) { case SpicaMLLexer.DMC: this.annDMC = this.module.GetDMC(node.GetChild(i)); break; case SpicaMLLexer.PERIOD: this.annPeriod = this.module.GetPeriod(node.GetChild(i)); break; case SpicaMLLexer.SRC: this.annSrc = this.module.GetSource(node.GetChild(i)); break; case SpicaMLLexer.TYPE: this.annType = this.module.GetType(node.GetChild(i)); break; case SpicaMLLexer.TTL: this.annTTL = this.module.GetTTL(node.GetChild(i)); break; case SpicaMLLexer.EXTRACT: this.extract.Add(new Annotations.Extract(this.module, this, node.GetChild(i))); break; } } }
public ModulePublish(Module module, ITree node, string filename, string package, IList<string> ns) : base(node, filename, package, ns) { if (node.Type != SpicaMLLexer.PUB) { throw new CException("Module: Unable to create publication request, wrong node type! ({0})", module.Details); } if (node.ChildCount < 1) { throw new CException("Module: Unable to create publication request, wrong number of children! ({0})", module.Details); } this.module = module; Name = node.GetChild(0).Text; this.annDMC = this.module.pubDefaultDMC; this.annDst = this.module.pubDefaultDst; this.annPeriod = this.module.pubDefaultPeriod; this.annTTL = this.module.pubDefaultTTL; for (int i = 1; i < node.ChildCount; i++) { switch (node.GetChild(i).Type) { case SpicaMLLexer.DMC: this.annDMC = this.module.GetDMC(node.GetChild(i)); break; case SpicaMLLexer.PERIOD: this.annPeriod = this.module.GetPeriod(node.GetChild(i)); break; case SpicaMLLexer.DST: this.annDst = this.module.GetSource(node.GetChild(i)); break; case SpicaMLLexer.TTL: this.annTTL = this.module.GetTTL(node.GetChild(i)); break; } } }