예제 #1
0
	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);
		}
	}
예제 #2
0
    string DescriptorSwitchGenerator::generateCode() {
		string ret = "<descriptorSwitch id=\"" + this->getId() + "\" >";
		GenericDescriptor* defaultDescriptor = this->getDefaultDescriptor();
		if (defaultDescriptor != NULL) {
			ret +="\t<defaultDescriptor descriptor=\"" + defaultDescriptor->getId() + "\" />";
		}
		
		unsigned int numDescriptors = this->getNumDescriptors();
		if (numDescriptors > 0) {
			for (int index = 0; index < numDescriptors; index++) {
				GenericDescriptor* genDescriptor = this->getDescriptor(index);
				DescriptorGenerator* descriptorGenerator = static_cast<DescriptorGenerator*>((Descriptor*) genDescriptor);
				ret += descriptorGenerator->generateCode() + "\n";
			}
		}

		unsigned int numRules = this->getNumRules();
		if (numRules > 0) {
			for (int index = 0; index < numRules; index++) {
				Rule* rule = this->getRule(index);
				GenericDescriptor* descriptor = this->getDescriptor(rule);
				ret += "<bindRule rule=\"" + rule->getId() + "\" ";
				ret += "constituent=\"" + descriptor->getId() + "\" />\n"; 
			}
		}

        return ret;
    }
예제 #3
0
	string BindGenerator::generateCode() {
		string ret = "<bind ";
		string componentId =  this->getNode()->getId();
		ret += "component=\"" + componentId + "\" ";
		InterfacePoint* interface = this->getInterfacePoint();
		if (interface != NULL) {
			string interfaceId = interface->getId();
			if (interfaceId != componentId) {
				ret += "interface=\"" + interface->getId() + "\" ";
			}
		}
		ret += "role=\"" + this->getRole()->getLabel() + "\" ";
		GenericDescriptor* descriptor = this->getDescriptor();
		if (descriptor != NULL) {
			ret += "descriptor=\"" + descriptor->getId() + "\" ";
		}

		vector<Parameter*>* parameters = this->getParameters();
		
		if (parameters != NULL) {
			vector<Parameter*>::iterator itParam = parameters->begin();
			ret +=">\n";
			while (itParam != parameters->end()) {
				Parameter* parameter = *itParam;
				ret += static_cast<ParameterGenerator*>(parameter)->generateCode("bindParam", "value");
				itParam++;
			}
			ret+= "</bind>\n";
		} else {
			ret += "/>\n";
		}
		return ret;
	}