本文整理汇总了C++中Formula::type方法的典型用法代码示例。如果您正苦于以下问题:C++ Formula::type方法的具体用法?C++ Formula::type怎么用?C++ Formula::type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Formula
的用法示例。
在下文中一共展示了Formula::type方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateVariableProperties
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;
};
示例2: operator
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;
//.........这里部分代码省略.........