numeric_t Column::getTotalData() const { numeric_t total = 0.0; ICell* pCell = nullptr; foreach(pCell, m_cells) total += pCell->getData().toDouble(); return total; }
numeric_t Column::getTotalValue(const CellValueRetriever* pColumn) const { numeric_t total = 0.0; ICell* pCell = nullptr; foreach(pCell, m_cells) total += pCell->getValue(pColumn); return total; }
numeric_t Sheet::totalRowValue(const RowId& rowId) const { numeric_t rowTotal = 0.0; Column* pColumn = NULL; foreach(pColumn, m_columns) { ICell* pCell = pColumn->cellAt(rowId); if (pCell && pCell->isNumeric() && pCell->isPartOfTotal()) rowTotal += pCell->getValue(NULL); //pass here the total column? useless }
int Column::findRow(const RowId& rowId) const { int row = -1; ICell* pCell = nullptr; foreach(pCell, m_cells) { ++row; if (pCell && pCell->rowId() == rowId) return row; }
numeric_t SplitComponent::getRowInputUnits(const RowId& rowId) const { numeric_t units = 0.0; const InputColumn* pInputCol = NULL; foreach(pInputCol, m_inputs) { ICell* pCell = pInputCol->cellAt(rowId); Q_ASSERT(pCell); if (pCell) units += pCell->getValue(this); }
numeric_t SplitComponent::setAmount(const numeric_t & amount) { doSetAmount(amount); m_pricePerUnit = getAmount() / getInputsUnitsTotal(); //notify that our cells were 'recomputed' ICell* pCell = NULL; foreach(pCell, m_cells) pCell->notify(); const numeric_t & myAmount = getAmount(); Q_ASSERT(compareNumeric(getTotalValue(this), myAmount)); //cells sum should match return myAmount; }
numeric_t SplitComponent::getCellValue(const ICell & cell, const numeric_t & value) const { // //1 - handle custom inputs // //TODO move here code from InputColumn::getInputValue, InputColumn::setCustomInputValue // //2 - handle implicit inter-split dependencies: // //if 'counted' is null, don't consider 'divided' if (getTitle() == SplitDivided) { SplitComponent* pSplitCounted = m_ownerCol.getSplitComponent(SplitCounted); if (pSplitCounted) if (!pSplitCounted->getRowInputUnits(cell.rowId())) return 0; } return value; }
virtual void TearDown() { cell1->drop(); cell2->drop(); }
ICell * PhotoAutotroph::reproduce() { ICell * daughter = new PhotoAutotroph(this); daughter->setColour(mutateColour()); return daughter; }