本文整理汇总了C++中ExprNode::isDimensionRestriction方法的典型用法代码示例。如果您正苦于以下问题:C++ ExprNode::isDimensionRestriction方法的具体用法?C++ ExprNode::isDimensionRestriction怎么用?C++ ExprNode::isDimensionRestriction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExprNode
的用法示例。
在下文中一共展示了ExprNode::isDimensionRestriction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkStetRule
void RuleOptimizer::checkStetRule(ExprNode *node, const Area *area)
{
Logger::trace << "checking for STET rule " << rule2string(db, cube, node) << endl;
if (!node->isValid()) {
Logger::trace << "rule is invalid, stopping STET rule check" << endl;
return;
}
// the rule should be "[] = IF(...,STET(),...)" or "[] = IF(...,...,STET())"
Node::NodeType t = node->getNodeType();
if (t != Node::NODE_FUNCTION_IF) {
Logger::trace << "no IF clause, stopping STET rule check" << endl;
return;
}
FunctionNode * ifNode = dynamic_cast<FunctionNode*>(node);
ExprNode* clause = dynamic_cast<ExprNode*>(ifNode->getParameters()->at(0));
if (clause == 0) {
Logger::warning << "something is wrong, corrupted rule " << rule2string(db, cube, node) << endl;
return;
}
Node* trueNode = ifNode->getParameters()->at(1);
Node* falseNode = ifNode->getParameters()->at(2);
// either true or false node must be STET
Node* nonStetNode = 0;
bool isInclusive = false;
if (trueNode->getNodeType() == Node::NODE_FUNCTION_STET) {
nonStetNode = falseNode;
isInclusive = false; // use complementary clause-set
} else if (falseNode->getNodeType() == Node::NODE_FUNCTION_STET) {
nonStetNode = trueNode;
isInclusive = true; // use clause-set
} else {
Logger::trace << "no STET as true or false value, stopping STET rule check" << endl;
return;
}
// check if clause is a dimension restriction
Logger::trace << "checking if-clause " << rule2string(db, cube, clause) << endl;
IdentifierType dimensionId;
bool restriction = clause->isDimensionRestriction(cube, &dimensionId);
if (!restriction) {
Logger::trace << "if-clause is no dimension restriction, stopping STET rule check" << endl;
return;
}
CPDimension dimension = db->lookupDimension(dimensionId, false);
if (dimension == 0) {
Logger::trace << "restricted dimension cannot be found, id: " << dimensionId << endl;
return;
}
// ok find the dimension restriction
set<Element*> elements = clause->computeDimensionRestriction(db, cube);
// find dimension position
int pos = 0;
const IdentifiersType *dimensionIds = cube->getDimensions();
for (IdentifiersType::const_iterator iter = dimensionIds->begin(); iter != dimensionIds->end(); ++iter, pos++) {
if (*iter == dimensionId) {
break;
}
}
Logger::trace << "dimension restriction for dimension '" << dimensionId << "', position " << pos << endl;
// find existing restriction
set<IdentifierType> computedRestriction;
// intersect with computed restriction
if (isInclusive) {
// no given restriction
if (!area->elemCount(pos)) {
for (set<Element*>::iterator iter = elements.begin(); iter != elements.end(); ++iter) {
Element* element = *iter;
IdentifierType id = element->getIdentifier();
computedRestriction.insert(id);
Logger::trace << "dimension element " << element->getName(dimension->getElemNamesVector()) << endl;
}
} else {
// restriction given in rule
for (set<Element*>::iterator iter = elements.begin(); iter != elements.end(); ++iter) {
Element* element = *iter;
IdentifierType id = element->getIdentifier();
if (area->find(pos, id) != area->elemEnd(pos)) {
computedRestriction.insert(id);
Logger::trace << "dimension element " << element->getName(dimension->getElemNamesVector()) << endl;
}
//.........这里部分代码省略.........