bool CreateVariableProperties(UdmDesertMap& des_map, DesertUdmMap &inv_des_map, UdmElementSet& elements) { UdmElementSet::iterator i; //progress bar indication CDesertStatusDlg * st_dlg = GetStatusDlg(NULL); int pos = 0; for (i = elements.begin(); i != elements.end(); i++) { Element e= *i; std::string ename = e.name(); set<VariableProperty> vp_set = e.VariableProperty_kind_children(); set<VariableProperty>::iterator vp_i; for (vp_i = vp_set.begin(); vp_i != vp_set.end(); vp_i++) { VariableProperty vp = *vp_i; std::string nnvp = vp.name(); long owner_id = GetID(e, des_map); if(!vp.parametric()) { Domain vp_d = vp.domain(); long domain_id = GetID(vp_d, des_map); CString cpfn; if ( strcmp(((string)vp.PCM_STR()).c_str() , "PCM_CUST") ) { //no match cpfn = ((string)vp.PCM_STR()).c_str(); } else cpfn = ((string)vp.CUSTName()).c_str(); long vp_id = CreateVariableProperty( utf82cstring((string)vp.name()), //const char *name, (LPCTSTR)cpfn, //const char *cpfn owner_id, //long owner, domain_id ); //long domain); /* long vp_id = CreateVariableProperty( ((string)vp.name()).c_str(), //const char *name, (LPCTSTR)cpfn, //const char *cpfn owner_id, //long owner, domain_id, //long domain); vp.id(), vp.externalID()); */ DoMap(vp, des_map, inv_des_map, vp_id); TRACE("Added VariableProperty: (name %s, owner: %d, domain: %d) :%d\n", ((string)vp.name()).c_str(), owner_id, domain_id, long(vp_id)); } else //parametric { set<Formula> fs = vp.formula_end(); for(set<Formula>::iterator fit = fs.begin();fit!=fs.end();++fit) { Formula currf = *fit; if(currf.type()==CustomFormula::meta) { CustomFormula customf = CustomFormula::Cast(currf); long pvp_id = createParametricVariableProperty(utf82cstring((string)vp.name()), owner_id, utf82cstring((string)customf.expression())); DoMap(vp, des_map, inv_des_map, pvp_id); TRACE("Added VariableProperty: (name %s, owner: %d, domain: %d) :%d\n", ((string)vp.name()).c_str(), owner_id, long(pvp_id)); } else { SimpleFormula simplef = SimpleFormula::Cast(currf); CString cpfn = ((string)simplef.ComputationType()).c_str(); long vp_id = CreateVariableProperty( utf82cstring((string)vp.name()), //const char *name, (LPCTSTR)cpfn, //const char *cpfn owner_id //long owner, ); DoMap(vp, des_map, inv_des_map, vp_id); TRACE("Added VariableProperty: (name %s, owner: %d) :%d\n", ((string)vp.name()).c_str(), owner_id,long(vp_id)); } } } };//eo for(vp_i) //progress bar status update pos++; //st_dlg->StepInState((short) (float)pos *100.00 /(float)elements.size()); };//end for(i) return true; };
std::wstring Writer::operator ()(const Formula &formula, const Dictionary &dictionary, SymbolType *symbolType) const { SymbolType localSymbolType; SymbolType &type = symbolType ? *symbolType : localSymbolType; std::wstring result; type = formula.type(); switch (type) { case NONE_SYMBOL: return symbolic.noneSymbol; break; case FALSE_SYMBOL: return symbolic.falseSymbol; break; case TRUE_SYMBOL: return symbolic.trueSymbol; break; case EQUALITY: if (formula.terms().size()<=1) { return symbolic.trueSymbol; } result += operator ()(formula.terms()[0], dictionary); for (size_t i = 1; i < formula.terms().size(); ++i) { result += symbolic.equalitySymbol; result += operator ()(formula.terms()[i], dictionary); } break; case NONEQUALITY: if (formula.terms().size()<=1) { return symbolic.trueSymbol; } if (formula.terms().size()==2) { result += (*this)(formula.terms()[0], dictionary); result += symbolic.nonequalitySymbol; result += (*this)(formula.terms()[1], dictionary); } else { result += symbolic.nonequalitySymbol+symbolic.leftRelationBracket; for (size_t i = 0; i<formula.terms().size(); ++i) { if (i!=0) { result += symbolic.relationSeparatorSymbol; result += (*this)(formula.terms()[i], dictionary); } } result += symbolic.rightRelationBracket; } break; case RELATION: result = dictionary(formula.symbol()); if (result.empty()) { result = relationName(formula.symbol().id); } result += symbolic.leftRelationBracket; if (formula.terms().empty() == false) { result += operator ()(formula.terms()[0], dictionary); for (size_t i = 1; i < formula.terms().size(); ++i) { result += symbolic.relationSeparatorSymbol; result += operator ()(formula.terms()[i], dictionary); } } result += symbolic.rightRelationBracket; break; case NEGATION: result = operator ()(formula.formulas()[0], dictionary, &type); insertBracketsIfNeeded(formula.type(), type, result); type = formula.type(); result = symbolic.negationSymbol+result; break; case CONJUNCTION: case DISJUNCTION: switch (formula.formulas().size()) { case 0: if (type == CONJUNCTION) { result = symbolic.trueSymbol; type = TRUE_SYMBOL; } else { result = symbolic.falseSymbol; type = FALSE_SYMBOL; } break; case 1: result = operator ()(formula.formulas()[0], dictionary); break; default: result = operator ()(formula.formulas()[0], dictionary, &type); insertBracketsIfNeeded(formula.type(), type, result); for (size_t i = 1; i < formula.formulas().size(); ++i) { result += formula.type() == CONJUNCTION ? symbolic.conjunctionSymbol : symbolic.disjunctionSymbol; std::wstring tmp = operator ()(formula.formulas()[i], dictionary, &type); insertBracketsIfNeeded(formula.type(), type, tmp); result += tmp; } break; } type = formula.type(); break; case IMPLICATION: case EQUIVALENCE: if (formula.formulas().size() <= 1) { result = symbolic.trueSymbol; } else { result = operator ()(formula.formulas()[0], dictionary, &type); insertBracketsIfNeeded(formula.type(), type, result); for (size_t i = 1; i < formula.formulas().size(); ++i) { result += formula.type() == IMPLICATION ? symbolic.implicationSymbol : symbolic.equivalenceSymbol; std::wstring tmp = operator ()(formula.formulas()[i], dictionary, &type); insertBracketsIfNeeded(formula.type(), type, tmp); result += tmp; } } type = formula.type(); break; case UNIVERSAL: case EXISTENTIAL: if (formula.variables().empty()) { result = operator ()(formula.formulas()[0], dictionary, &type); } else { result = symbolic.leftQuantifierBracket; result += type == UNIVERSAL ? symbolic.universalQuantifier : symbolic.existentialQuantifier; result += operator ()(formula.variables()[0], dictionary); for (size_t i = 1; i < formula.variables().size(); ++i) { result += symbolic.variableSeparatorSymbol; result += operator ()(formula.variables()[i], dictionary); } result += symbolic.rightQuantifierBracket; std::wstring tmp = operator ()(formula.formulas()[0], dictionary, &type); insertBracketsIfNeeded(formula.type(), type, tmp); result += tmp; } type = formula.type(); break; default: throw(1); break; } return result; }