Example #1
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;
	}
Example #2
0
	void CascadingDescriptor::cascadeUnsolvedDescriptor() {
		if (unsolvedDescriptors->empty())
			return;

		GenericDescriptor* genericDescriptor, *descriptor;
		DescriptorSwitch* descAlternatives;
		GenericDescriptor* auxDescriptor;

		genericDescriptor = (GenericDescriptor*)
			    ((*unsolvedDescriptors)[0]);

		if (genericDescriptor->instanceOf("DescriptorSwitch")) {
			descAlternatives = (DescriptorSwitch*)genericDescriptor;
			auxDescriptor = descAlternatives->getSelectedDescriptor();
			descriptor = (GenericDescriptor*)
				    auxDescriptor->getDataEntity();

		} else {
			descriptor = (Descriptor*)genericDescriptor;
		}

		unsolvedDescriptors->erase(unsolvedDescriptors->begin());

		if (isLastDescriptor(descriptor)) {
			return;
		}

		cascadeDescriptor((Descriptor*)descriptor);
	}
Example #3
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);
		}
	}
    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;
    }
    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;
    }
Example #6
0
void AvidInfo::GetPhysicalPackageInfo(HeaderMetadata *header_metadata)
{
    vector<GenericPackage*> packages = header_metadata->getPreface()->getContentStorage()->getPackages();
    size_t i;
    for (i = 0; i < packages.size(); i++) {
        SourcePackage *sp = dynamic_cast<SourcePackage*>(packages[i]);
        if (!sp || !sp->haveDescriptor())
            continue;

        GenericDescriptor *descriptor = sp->getDescriptorLight();
        if (!descriptor || !mxf_set_is_subclass_of(descriptor->getCMetadataSet(), &MXF_SET_K(PhysicalDescriptor)))
            continue;
        have_phys_package = true;

        if (mxf_set_is_subclass_of(descriptor->getCMetadataSet(), &MXF_SET_K(TapeDescriptor)))
            phys_package_type = TAPE_PACKAGE_TYPE;
        else if (mxf_set_is_subclass_of(descriptor->getCMetadataSet(), &MXF_SET_K(ImportDescriptor)))
            phys_package_type = IMPORT_PACKAGE_TYPE;
        else if (mxf_set_is_subclass_of(descriptor->getCMetadataSet(), &MXF_SET_K(RecordingDescriptor)))
            phys_package_type = RECORDING_PACKAGE_TYPE;
        else
            phys_package_type = UNKNOWN_PACKAGE_TYPE;

        phys_package_uid = sp->getPackageUID();
        if (sp->haveName())
            phys_package_name = sp->getName();

        if (descriptor->haveLocators()) {
            vector<Locator*> locators = descriptor->getLocators();
            size_t j;
            for (j = 0; j < locators.size(); j++) {
                NetworkLocator *network_locator = dynamic_cast<NetworkLocator*>(locators[j]);
                if (network_locator) {
                    phys_package_locator = network_locator->getURLString();
                    break;
                }
            }
        }
    }
}