qaengine/src/ClientInterface.cxx
//--------------------------------------------------------------------------------
// Client wants to get list of children
//--------------------------------------------------------------------------------
Client wants to get list of children
Client wants to get list of children
int ClientInterface::command_ListChildren(string& reply,int socket,int id,ScopeSet scope) {
	int hasDeviation = 0;
	reply = "";
    TaskDriver* task=m_Clients[socket]->getActiveProject();
	int ch = task->getFirstChild(id);
	while(ch>=0) {
		char buf[100];
		sprintf(buf,"%d",ch);
		reply+=buf;
	    reply+="\t";
		PropertiesMap map = task->getNodeProperties(ch,scope);
		PropertiesMap::iterator i;
		for(i=map.begin();i!=map.end();i++) {
			if(i->first.length()==0) reply+=" ";
			else reply+=i->first;
			reply+="\t";
			if(i->second.length()==0) reply+=" ";
			else reply+=i->second;
			reply+="\t";
		}
        int statistical = task->isStatistical(ch);
		if(!statistical) {
  		    reply+="Hits";
		    reply+="\t";
		    sprintf(buf,"%d",countHits(socket,ch,scope));
		    reply+=buf;
		} else {
            string kind = task->getNodeProperty(ch,scope,"Kind");
			if(kind=="Query") {
				HitsSet hits = task->getNodeHits(ch,scope);
				HitsSet::iterator i;
				int hitsCounter = 0;
				int globalTotal= 0;
				int globalMin = 100000000;
				int globalMax = 0;
				double globalAverage   = 0;
				double globalDeviation = 0;
				for(i=hits.begin();i!=hits.end();i++) {
					Hit* hit = *i;
					PropertiesMap* attributes = hit->getAttributes();
					PropertiesMap::iterator pos;
					pos = attributes->find("Minimum");
					if(pos!=attributes->end()) {
						int localMin = atoi(pos->second.c_str());
						if(globalMin>localMin) globalMin=localMin;
						globalTotal+=localMin;
					}
					pos = attributes->find("Maximum");
					if(pos!=attributes->end()) {
						int localMax = atoi(pos->second.c_str());
						if(globalMax<localMax) globalMax=localMax;
					}
					pos = attributes->find("Average");
					if(pos!=attributes->end()) {
						double localAverage = atof(pos->second.c_str());
						globalAverage+=localAverage;
					}
					pos = attributes->find("Deviation");
					if(pos!=attributes->end()) {
						hasDeviation = 1;
						double localDeviation = atof(pos->second.c_str());
						globalDeviation+=localDeviation;
					}
					hitsCounter++;
				}
				if(hitsCounter>0) {
					globalAverage/=hitsCounter;
					globalDeviation/=hitsCounter;
				}
				if(hasDeviation) {
   		            reply+="Minimum";
		            reply+="\t";
		            sprintf(buf,"%d",globalMin);
				    reply+=buf;
		            reply+="\t";
   		            reply+="Maximum";
		            reply+="\t";
		            sprintf(buf,"%d",globalMax);
				    reply+=buf;
		            reply+="\t";
   		            reply+="Average";
		            reply+="\t";
		            sprintf(buf,"%f",globalAverage);
				    reply+=buf;
		            reply+="\t";
   		            reply+="Deviation";
		            reply+="\t";
		            sprintf(buf,"%f",globalDeviation);
				    reply+=buf;
		            reply+="\t";
				} else {
   		            reply+="Total";
		            reply+="\t";
		            sprintf(buf,"%d",globalTotal);
				    reply+=buf;
		            reply+="\t";
				}
			}
			reply+="Statistical";
			reply+="\t";
			reply+="true";
		}
	    ch = task->getNextSibling(ch);
	    if(ch>=0) reply+="\n";
	}
	return 0;
}
int ClientInterface :: command_ListChildren ( string & reply , int socket , int id , ScopeSet scope ) { int hasDeviation = 0 ; reply = " " ; TaskDriver * task = m_Clients [ socket ] -> getActiveProject ( ) ; int ch = task -> getFirstChild ( id ) ; while ( ch >= 0 ) { char buf [ 100 ] ; sprintf ( buf , " " , ch ) ; reply += buf ; reply += " \t " ; PropertiesMap map = task -> getNodeProperties ( ch , scope ) ; PropertiesMap :: iterator i ; for ( i = map . begin ( ) ; i != map . end ( ) ; i ++ ) { if ( i -> first . length ( ) == 0 ) reply += " " ; else reply += i -> first ; reply += " \t " ; if ( i -> second . length ( ) == 0 ) reply += " " ; else reply += i -> second ; reply += " \t " ; } int statistical = task -> isStatistical ( ch ) ; if ( ! statistical ) { reply += " " ; reply += " \t " ; sprintf ( buf , " " , countHits ( socket , ch , scope ) ) ; reply += buf ; } else { string kind = task -> getNodeProperty ( ch , scope , " " ) ; if ( kind == " " ) { HitsSet hits = task -> getNodeHits ( ch , scope ) ; HitsSet :: iterator i ; int hitsCounter = 0 ; int globalTotal = 0 ; int globalMin = 100000000 ; int globalMax = 0 ; double globalAverage = 0 ; double globalDeviation = 0 ; for ( i = hits . begin ( ) ; i != hits . end ( ) ; i ++ ) { Hit * hit = * i ; PropertiesMap * attributes = hit -> getAttributes ( ) ; PropertiesMap :: iterator pos ; pos = attributes -> find ( " " ) ; if ( pos != attributes -> end ( ) ) { int localMin = atoi ( pos -> second . c_str ( ) ) ; if ( globalMin > localMin ) globalMin = localMin ; globalTotal += localMin ; } pos = attributes -> find ( " " ) ; if ( pos != attributes -> end ( ) ) { int localMax = atoi ( pos -> second . c_str ( ) ) ; if ( globalMax < localMax ) globalMax = localMax ; } pos = attributes -> find ( " " ) ; if ( pos != attributes -> end ( ) ) { double localAverage = atof ( pos -> second . c_str ( ) ) ; globalAverage += localAverage ; } pos = attributes -> find ( " " ) ; if ( pos != attributes -> end ( ) ) { hasDeviation = 1 ; double localDeviation = atof ( pos -> second . c_str ( ) ) ; globalDeviation += localDeviation ; } hitsCounter ++ ; } if ( hitsCounter > 0 ) { globalAverage /= hitsCounter ; globalDeviation /= hitsCounter ; } if ( hasDeviation ) { reply += " " ; reply += " \t " ; sprintf ( buf , " " , globalMin ) ; reply += buf ; reply += " \t " ; reply += " " ; reply += " \t " ; sprintf ( buf , " " , globalMax ) ; reply += buf ; reply += " \t " ; reply += " " ; reply += " \t " ; sprintf ( buf , " " , globalAverage ) ; reply += buf ; reply += " \t " ; reply += " " ; reply += " \t " ; sprintf ( buf , " " , globalDeviation ) ; reply += buf ; reply += " \t " ; } else { reply += " " ; reply += " \t " ; sprintf ( buf , " " , globalTotal ) ; reply += buf ; reply += " \t " ; } } reply += " " ; reply += " \t " ; reply += " " ; } ch = task -> getNextSibling ( ch ) ; if ( ch >= 0 ) reply += " \n " ; } return 0 ; }
Client wants to get list of children
Client wants to get list of children