Пример #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;
}
Пример #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;
}
Пример #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
  }
Пример #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;
  }
Пример #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);
  }
Пример #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;
}
Пример #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;
}
Пример #8
0
	virtual void TearDown() {
		cell1->drop();
		cell2->drop();
	}
Пример #9
0
ICell * PhotoAutotroph::reproduce()
{
	ICell * daughter = new PhotoAutotroph(this);
	daughter->setColour(mutateColour());
	return daughter;
}