void CascadingDescriptor::cascade(GenericDescriptor *descriptor) { GenericDescriptor* preferredDescriptor; preferredDescriptor = (GenericDescriptor*) (descriptor->getDataEntity()); if ((preferredDescriptor == NULL) || preferredDescriptor->instanceOf("CascadingDescriptor")) return; if (isLastDescriptor(preferredDescriptor)) return; descriptors->push_back(preferredDescriptor); if (id == "") id = preferredDescriptor->getId(); else id = id + "+" + preferredDescriptor->getId(); if (preferredDescriptor->instanceOf("Descriptor") && unsolvedDescriptors->empty()) { cascadeDescriptor((Descriptor*)preferredDescriptor); } else { unsolvedDescriptors->push_back(preferredDescriptor); } }
string DescriptorBaseGenerator::generateCode() { string ret = "<descriptorBase"; if (id!="") { ret += " id= \"" + id + "\""; } ret += ">\n"; //generico para todas as bases vector<Base*>* bases = this->getBases(); vector<Base*>::iterator itBases; itBases = bases->begin(); while (itBases != bases->end()) { Base* base = *itBases; ret += "<importBase alias=\"" + this->getBaseAlias(base) + "\" documentURI=\"" + this->getBaseLocation(base) + "\"/>\n"; itBases++; } //generico para todas as bases vector<GenericDescriptor*>* descriptors = this->getDescriptors(); vector<GenericDescriptor*>::iterator it; it = descriptors->begin(); while (it != descriptors->end()) { GenericDescriptor* genericDescriptor = *it; string str; if (genericDescriptor->instanceOf("Descriptor")) { str = (static_cast<DescriptorGenerator*>(genericDescriptor))->generateCode() + "\n"; } else if (genericDescriptor->instanceOf("DescriptorSwitch")) { str = (static_cast<DescriptorSwitchGenerator*>(genericDescriptor))->generateCode() + "\n"; } ret += str; it++; } ret+= "</descriptorBase>\n"; return ret; }