本文整理汇总了C++中ParentObject::lifeCycleCosts方法的典型用法代码示例。如果您正苦于以下问题:C++ ParentObject::lifeCycleCosts方法的具体用法?C++ ParentObject::lifeCycleCosts怎么用?C++ ParentObject::lifeCycleCosts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParentObject
的用法示例。
在下文中一共展示了ParentObject::lifeCycleCosts方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: currentParent
std::vector<ModelObject> getRecursiveChildren(const ParentObject& object, bool includeLifeCycleCosts) {
std::set<Handle> resultSet;
std::pair<HandleSet::const_iterator,bool> insertResult;
std::vector<ModelObject> result;
resultSet.insert(object.handle());
result.push_back(object);
if (includeLifeCycleCosts){
for (const LifeCycleCost& lifeCycleCost : object.lifeCycleCosts()){
result.push_back(lifeCycleCost);
}
}
std::deque<ParentObject> parents;
parents.push_back(object);
while (parents.size() > 0) {
ParentObject currentParent(parents[0]);
parents.pop_front();
// parent's costs have already been added
for (const ModelObject& child : currentParent.children()) {
insertResult = resultSet.insert(child.handle());
if (insertResult.second) {
result.push_back(child);
if (includeLifeCycleCosts){
for (const LifeCycleCost& lifeCycleCost : child.lifeCycleCosts()){
result.push_back(lifeCycleCost);
}
}
OptionalParentObject opo = child.optionalCast<ParentObject>();
if (opo) {
parents.push_back(*opo);
}
}
}
}
return result;
}