Esempio n. 1
0
numeric_t Column::getTotalData() const
{
  numeric_t total = 0.0;

  ICell* pCell = nullptr;
  foreach(pCell, m_cells)
    total += pCell->getData().toDouble();

  return total;
}
Esempio n. 2
0
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;
}
Esempio n. 3
0
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
  }
Esempio n. 4
0
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;
  }
Esempio n. 5
0
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);
  }
Esempio n. 6
0
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;
}
Esempio n. 7
0
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;
}
Esempio n. 8
0
	virtual void TearDown() {
		cell1->drop();
		cell2->drop();
	}
Esempio n. 9
0
ICell * PhotoAutotroph::reproduce()
{
	ICell * daughter = new PhotoAutotroph(this);
	daughter->setColour(mutateColour());
	return daughter;
}