MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / evalAggregate

Method evalAggregate

src/App/Expression.cpp:1991–2056  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1989};
1990
1991Py::Object FunctionExpression::evalAggregate(
1992 const Expression *owner, int f, const std::vector<Expression*> &args)
1993{
1994 std::unique_ptr<Collector> c;
1995
1996 switch (f) {
1997 case SUM:
1998 c = std::make_unique<SumCollector>();
1999 break;
2000 case AVERAGE:
2001 c = std::make_unique<AverageCollector>();
2002 break;
2003 case STDDEV:
2004 c = std::make_unique<StdDevCollector>();
2005 break;
2006 case COUNT:
2007 c = std::make_unique<CountCollector>();
2008 break;
2009 case MIN:
2010 c = std::make_unique<MinCollector>();
2011 break;
2012 case MAX:
2013 c = std::make_unique<MaxCollector>();
2014 break;
2015 case AND:
2016 c = std::make_unique<AndCollector>();
2017 break;
2018 case OR:
2019 c = std::make_unique<OrCollector>();
2020 break;
2021 default:
2022 assert(false);
2023 }
2024
2025 for (auto &arg : args) {
2026 if (arg->isDerivedFrom<RangeExpression>()) {
2027 Range range(static_cast<const RangeExpression&>(*arg).getRange());
2028
2029 do {
2030 Property * p = owner->getOwner()->getPropertyByName(range.address().c_str());
2031 PropertyQuantity * qp;
2032 PropertyFloat * fp;
2033 PropertyInteger * ip;
2034
2035 if (!p)
2036 continue;
2037
2038 if ((qp = freecad_cast<PropertyQuantity*>(p)))
2039 c->collect(qp->getQuantityValue());
2040 else if ((fp = freecad_cast<PropertyFloat*>(p)))
2041 c->collect(Quantity(fp->getValue()));
2042 else if ((ip = freecad_cast<PropertyInteger*>(p)))
2043 c->collect(Quantity(ip->getValue()));
2044 else
2045 _EXPR_THROW("Invalid property type for aggregate.", owner);
2046 } while (range.next());
2047 }
2048 else {

Callers

nothing calls this directly

Calls 13

pyToQuantityFunction · 0.85
pyFromQuantityFunction · 0.85
getQuantityValueMethod · 0.80
QuantityClass · 0.70
getRangeMethod · 0.45
getPropertyByNameMethod · 0.45
getOwnerMethod · 0.45
c_strMethod · 0.45
collectMethod · 0.45
getValueMethod · 0.45
nextMethod · 0.45
getPyValueMethod · 0.45

Tested by

no test coverage detected