Beispiel #1
0
FeeScaleXML * procFeeScale(std::string &line)
{
	FeeScaleXML * xml = new FeeScaleXML();
	interval feeInterval;
	feeInterval.lowerLimit = "true";
	feeInterval.upperLimit = "true";
	std::string name(line, 50, 9);
	std::string firstPos(line, 32, 7);
	std::string secondPos(line, 32, 7);
	//std::cout << line.substr(10, 7) << std::endl;
	xml->name = name;
	xml->currency = "THB";
	xml->baseValue = "F";
	xml->calculationBase = "E";
	xml->calculationMethod = "L";
	xml->overlappingIntervals = "N";
	xml->FeeAggregationScheme = "Client Aggregation";
	xml->intervals.push_back(feeInterval);

	if (line.substr(10, 7) == "STOCKFT") { //Single Stock
		//std::cout << "Single Stock" << std::endl ;
		xml->orderEstimationMode = "S";
		return xml;
	}
	else if (line.substr(21, 1) == "2") {
		//std::cout << "NON SINGLE STOCK : NO TIER" << std::endl ;

		xml->orderEstimationMode = "F";
		return xml;

	}
	// In others cases,return NULL
	return NULL;
	
}
//
//-----------------------------------------------------------------------------
//
//    Class: CStifParser
//
//    Method: HandleSpecialMarks
//
//    Description: Handles special marks.( '\/' and '\*' ). This
//         		   is used when ECStyleComments comment type is used.
//
//    Parameters: TPtr& aBuf: inout: section to parsed
//
//    Return Values: None
//
//    Errors/Exceptions: None
//
//    Status: Proposal
//
//-----------------------------------------------------------------------------
//
void CStifParser::HandleSpecialMarks( TPtr& aBuf )
    {
    TLex lex( aBuf );
    TInt firstPos( 0 );
    
    //        Replace \/ with /
    //        Replace \* with *
    
    do
        {
        //RDebug::Print( _L("Print : %S"), &aBuf );
        firstPos = lex.Offset();
        TChar get = lex.Get();
        // Check is '\'
        if( get == '\\' ) 
            {
            firstPos = (lex.Offset()-1);
            // Peek next character( '/' or '*' )
            if( lex.Peek() == '/' || lex.Peek() == '*')
                {
                aBuf.Delete (firstPos,1);
                lex = aBuf;
                }
            }
           
        firstPos = 0;
        } while ( !lex.Eos() );

    }
Beispiel #3
0
	bool Collision::checkCollides(Object* _first, Object* _second, Game* _game)
	{
		sf::Vector2f depth(0, 0);
		sf::Vector2f normal(0, 0);

		sf::IntRect first  = _first->getAABB();
		sf::IntRect second = _second->getAABB();
		sf::Vector2i firstPos((int)_first->getX() + first.width, (int)_first->getY() + first.height);
		sf::Vector2i secondPos((int)_second->getX() + second.width, (int)_second->getY() + second.height);

		int dx  =  firstPos.x - secondPos.x;
		int dy  =  firstPos.y - secondPos.y;
		int adx =  abs(firstPos.x - secondPos.x);
		int ady =  abs(firstPos.y - secondPos.y);
		int sw  = (first.width  + second.width);
		int sh  = (first.height + second.height);

		if((adx < sw) && (ady < sh))
		{
			float invDist = 1.0f / (float)sqrt(dx * dx + dy * dy);
			normal = getNormal(sf::Vector2f(dx * invDist, dy * invDist));
			depth  = sf::Vector2f((float)abs(adx - sw), (float)abs(ady - sh));

			_first->collisionCallback(depth, normal, _second, _game);
			_second->collisionCallback(depth, normal, _first, _game);

			_first->collide();
			_second->collide();
			return true;
		}
		return false;
	}
Beispiel #4
0
void procFeeScaleFromTier(std::string &line,std::vector<FeeScaleXML*> &FeeSclaeList)
{
	FeeScaleXML * xml = new FeeScaleXML();
	
	
	std::string name(line, 0, 10);
	std::string firstPos(line, 32, 7);
	std::string secondPos(line, 32, 7);
	std::string lowerLimit(line, 10, 5);
	std::string upperLimit(line, 15, 5);

	std::string FirstValue(line, 20, 8);
	std::string SecondValue(line, 28, 8);

	std::string val="0";

	if (FirstValue != "0000.00") {
		val = FirstValue;
	}
	else if (SecondValue != "0000.00"){
		val = SecondValue;
	}



	if (FeeSclaeList.size() != 0){

		interval feeInterval;
		feeInterval.value = val;
		feeInterval.upperLimit = upperLimit;

		std::vector<FeeScaleXML*>::iterator it = FeeSclaeList.end();
		--it;
		if (name.compare((*it)->name) != 0) { //New Fee tier ,set upper limit of last fee as "true"
			std::vector<interval>::iterator feeIt = (*it)->intervals.end();
			--feeIt;
			
			feeIt->upperLimit = "true";
			feeInterval.lowerLimit = "true";

			xml->name = name;
			xml->description = "description";
			xml->currency = "THB";
			xml->baseValue = "F";
			xml->calculationBase = "A";
			xml->calculationMethod = "L";
			xml->orderEstimationMode = "F";
			xml->overlappingIntervals = "N";
			xml->intervals.push_back(feeInterval);
			xml->FeeAggregationScheme="Client Aggregation";
		

			FeeSclaeList.push_back(xml);
		}
		else { // Fee existed ,adds more tier
			std::vector<interval>::iterator feeIt = (*it)->intervals.end();
			--feeIt;
			feeInterval.lowerLimit = lowerLimit;
			(*it)->intervals.push_back(feeInterval);


		}

	}
	/*
	
	*/
	
}
Beispiel #5
0
// fill matrix values; return true on success. Matrix must have only default values when passed in.
int CalculateGlobalMatrixGeneric(Matrix& matrix,
    const DP_BlockInfo *blocks, DP_BlockScoreFunction BlockScore, DP_LoopPenaltyFunction LoopScore,
    unsigned int queryFrom, unsigned int queryTo)
{
    unsigned int block, residue, prevResidue, lastBlock = blocks->nBlocks - 1;
    int blockScore = 0, sum;
    unsigned int loopPenalty;

    // find possible block positions, based purely on block lengths
    vector < unsigned int > firstPos(blocks->nBlocks), lastPos(blocks->nBlocks);
    for (block=0; block<=lastBlock; ++block) {
        if (block == 0) {
            firstPos[0] = queryFrom;
            lastPos[lastBlock] = queryTo - blocks->blockSizes[lastBlock] + 1;
        } else {
            firstPos[block] = firstPos[block - 1] + blocks->blockSizes[block - 1];
            lastPos[lastBlock - block] =
                lastPos[lastBlock - block + 1] - blocks->blockSizes[lastBlock - block];
        }
    }

    // further restrict the search if blocks are frozen
    for (block=0; block<=lastBlock; ++block) {
        if (blocks->freezeBlocks[block] != DP_UNFROZEN_BLOCK) {
            if (blocks->freezeBlocks[block] < firstPos[block] ||
                blocks->freezeBlocks[block] > lastPos[block])
            {
                ERROR_MESSAGE("CalculateGlobalMatrix() - frozen block "
                    << (block+1) << " does not leave room for unfrozen blocks");
                return STRUCT_DP_PARAMETER_ERROR;
            }
            firstPos[block] = lastPos[block] = blocks->freezeBlocks[block];
        }
    }

    // fill in first row with scores of first block at all possible positions
    for (residue=firstPos[0]; residue<=lastPos[0]; ++residue)
        matrix[0][residue - queryFrom].score = BlockScore(0, residue);

    // for each successive block, find the best allowed pairing of the block with the previous block
    bool blockScoreCalculated;
    for (block=1; block<=lastBlock; ++block) {
        for (residue=firstPos[block]; residue<=lastPos[block]; ++residue) {
            blockScoreCalculated = false;

            for (prevResidue=firstPos[block - 1]; prevResidue<=lastPos[block - 1]; ++prevResidue) {

                // current block must come after the previous block
                if (residue < prevResidue + blocks->blockSizes[block - 1])
                    break;

                // make sure previous block is at an allowed position
                if (matrix[block - 1][prevResidue - queryFrom].score == DP_NEGATIVE_INFINITY)
                    continue;

                // get loop score at this position; assume loop score zero if both frozen
                if (blocks->freezeBlocks[block] != DP_UNFROZEN_BLOCK &&
                    blocks->freezeBlocks[block - 1] != DP_UNFROZEN_BLOCK)
                {
                    loopPenalty = 0;
                } else {
                    loopPenalty = LoopScore(block - 1, residue - prevResidue - blocks->blockSizes[block - 1]);
                    if (loopPenalty == DP_POSITIVE_INFINITY)
                        continue;
                }

                // get score at this position
                if (!blockScoreCalculated) {
                    blockScore = BlockScore(block, residue);
                    if (blockScore == DP_NEGATIVE_INFINITY)
                        break;
                    blockScoreCalculated = true;
                }

                // find highest sum of scores + loop score for allowed pairing of this block with previous
                sum = blockScore + matrix[block - 1][prevResidue - queryFrom].score - loopPenalty;
                if (sum > matrix[block][residue - queryFrom].score) {
                    matrix[block][residue - queryFrom].score = sum;
                    matrix[block][residue - queryFrom].tracebackResidue = prevResidue;
                }
            }
        }
    }

    return STRUCT_DP_OKAY;
}