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 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!"); } }