示例#1
0
	void MultiSymbolCache::addPriceData(CppUtils::String const& symbol, PriceData const& pdata)
	{
	
		SymbolDescriptor sdescr(symbol, ST_Physical);

		if (symbols_m.find(sdescr) == symbols_m.end())
			 THROW(CppUtils::OperationFailed, "exc_SymbolNotRegistered", "ctx_addPriceData", symbol);

		if (!pdata.isValid())
			THROW(CppUtils::OperationFailed, "exc_InvalidPriceData", "ctx_addPriceData", "");

		

		// we have only milliseconds
		Math::DoubleLongHolder<3> lholder( pdata.time_m);
			
		if (maxSize_m != 0) {

			bool inserted = false;
			map<CppUtils::Int64, RowType >::iterator itr = cache_m.find(lholder.getLongInternalValue());
			if (itr == cache_m.end()) {
				// not found
	
				pair< map<CppUtils::Int64, RowType >::iterator, bool> ins_res = 
					cache_m.insert( pair<CppUtils::Int64, RowType >(lholder.getLongInternalValue(), RowType()));

				HTASSERT(ins_res.second);
				map<CppUtils::Int64, RowType >::iterator& inserted_it= ins_res.first;
				RowType &new_row = inserted_it->second;

				new_row[symbol] = pdata;
				inserted = true;

				// notify
				propagate_onUpdateCaclulatedField(lholder.getLongInternalValue(), pdata.time_m, new_row);

			}
			else {
				// already found
				RowType& row = itr->second;
				row[symbol] = pdata;

				// notify
				propagate_onUpdateCaclulatedField(lholder.getLongInternalValue(), pdata.time_m, row);
			}

			
			if (inserted) {
				if (cache_m.size() <= maxSize_m || maxSize_m < 0)
					return;

				map<CppUtils::Int64, RowType >::iterator it_first = cache_m.begin();
				map<CppUtils::Int64, RowType >::iterator it_last = cache_m.end();
				it_last--;

				// actual insert
				if (removeLatest_m) {
					cache_m.erase(it_last);		
				}
				else {
					cache_m.erase(it_first);	
				}
			}
		}
		else {
			// do nothing
		}

	}
示例#2
0
Game_Actor::RowType Game_Actor::GetBattleRow() const {
	return RowType(GetData().row);
}