void GenericCashFlow::SetFlow(const GenericCashFlow& a) { Q_D(GenericCashFlow); Clear(); d->m_Stocks = a.d_func()->m_Stocks; d->m_CashFlowLabels = a.d_func()->m_CashFlowLabels; if (!a.d_func()->m_CashFlows.isEmpty()) { for (auto i = a.d_func()->m_CashFlows.constEnd() - 1; ; --i) { if (i.value()->isEmpty()) SetFlow(i.key(), 0.0, 0); for (auto j = i.value()->constBegin(); j != i.value()->constEnd(); ++j) { SetFlow(i.key(), j.value(), j.key()); } if (i == a.d_func()->m_CashFlows.constBegin()) break; } } }
GenericCashFlow& GenericCashFlow::operator=(const GenericCashFlow& other) { BackwardInterface::operator=(other); Aggregate(other.d_func()->m_AggregationLevel); SetFlow(other); return *this; }
void LSetFlow(Layer *l, bool flow) { for (Canvas *cv = l->l_cvlist; cv; cv = cv->c_lnext) { display = cv->c_display; if (cv != D_forecv) continue; SetFlow(flow); } }
void ParamElement::ReadAttributes(const DOMNode* node) { _ASSERTE(node != NULL); DOMNamedNodeMap* attr = node->getAttributes(); if( attr == NULL ) { return; } SetStringValue( attrId, Get_id_Attribute( attr ) ); SetStringValue( attrName, Get_name_Attribute( attr ) ); SetFlow( Get_flow_Attribute( attr ) ); SetStringValue( attrSemantic, Get_semantic_Attribute( attr ) ); SetType( Get_type_Attribute( attr ) ); SetStringValue( attrSubId, Get_sid_Attribute( attr ) ); }
void GenericCashFlow::AddFlow(const GenericCashFlow& a) { Q_D(GenericCashFlow); QSet<qint32> StocksToCalculate; QHash<qint32,QSet<QDate> >DatesOfStockChange; d->m_Stocks.unite(a.d_func()->m_Stocks); qint32 FakeFlow = 0; while (d->m_Stocks.contains(FakeFlow)) ++FakeFlow; //Aggregate Flows for (auto i = a.d_func()->m_CashFlows.constBegin(); i != a.d_func()->m_CashFlows.constEnd(); ++i) { if (i.value()->isEmpty()) AddFlow(i.key(), 0.0, FakeFlow); else { for (QHash<qint32, double>::const_iterator j = i.value()->constBegin(); j != i.value()->constEnd(); ++j) { if (d->m_Stocks.contains(j.key())) { //Save stocks types to calculate later AddFlow(i.key(), 0.0, FakeFlow); StocksToCalculate.insert(j.key()); DatesOfStockChange[j.key()].insert(i.key()); } else AddFlow(i.key(), j.value(), j.key()); } } } for (auto i = d->m_CashFlows.constBegin(); i != d->m_CashFlows.constEnd(); ++i) { for (auto j = i.value()->constBegin(); j != i.value()->constEnd(); ++j) { if (d->m_Stocks.contains(j.key())) { //Add stocks types already in cash flows StocksToCalculate.insert(j.key()); DatesOfStockChange[j.key()].insert(i.key()); } } } //Aggregate Stocks for (auto SingleStock = StocksToCalculate.constBegin(); SingleStock != StocksToCalculate.constEnd(); ++SingleStock) { auto CurrDates = DatesOfStockChange.value(*SingleStock, QSet<QDate>()).toList(); std::sort(CurrDates.begin(), CurrDates.end(), std::greater<QDate>()); for (auto i = CurrDates.constBegin(); i != CurrDates.constEnd(); ++i) { SetFlow(*i, GetFlow(*i, *SingleStock) + a.GetFlow(*i, *SingleStock), *SingleStock); } } //Aggregate Labels for (auto i = a.d_func()->m_CashFlowLabels.constBegin(); i != a.d_func()->m_CashFlowLabels.constEnd(); ++i) { if (!d->m_CashFlowLabels.contains(i.key())) d->m_CashFlowLabels.insert(i.key(), i.value()); } }
GenericCashFlow::GenericCashFlow(GenericCashFlowPrivate *d, const GenericCashFlow& other) :BackwardInterface(d,other) { SetFlow(other); }