1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
#include "libMRML/include/CQueryTreeNode.h"
#include "libMRML/include/CAlgorithm.h"
#include "libMRML/include/mrml_const.h"
/** Construct this */
CQueryTreeNode::CQueryTreeNode():
mContent(0),
mAlgorithm(0),
mChildren(){
};
/** destruct this */
CQueryTreeNode::~CQueryTreeNode(){
cout << "DELETING THIS"
<< endl;
for(CChildren::iterator i=mChildren.begin();
i!=mChildren.end();
i++){
delete i->first;
cout << "DELETING"
<< endl;
}
delete mContent;
delete mAlgorithm;
};
/** Configure this */
void CQueryTreeNode::configure(CXMLElement& inAttributes,
CAccessorAdminCollection& inAccessors,
CStaticQueryFactory& inFactory){
mAlgorithm=new CAlgorithm(inAttributes);
cout << "Deleting mContent";
mContent=0;
cout << "done";
mContent=inFactory.makeQuery(mAlgorithm->getBaseType(),
inAccessors,
*mAlgorithm);
cout << "MAKING " << this << "." << static_cast<CQuery*>(mContent) << endl;
mContent->checkNPrint();
// Build a local query tree
for(CChildren::iterator i=mChildren.begin();
i!=mChildren.end();
i++){
cout << "ADDING " << this << "." << static_cast<CQuery*>(mContent) << " <- " << i->first << "." << static_cast<CQuery*>(i->first->mContent) << ", " << i->second << endl;
cout << "i->first: " << flush ;i->first->checkNPrint();
cout << "i->first->Content: " << flush ;i->first->mContent->checkNPrint();
mContent->addChild(i->first->mContent,
i->second);
}
};
/** add a child to this */
void CQueryTreeNode::addChild(CQueryTreeNode* inChild,
double inWeight){
cout << "this " << flush ;checkNPrint();
cout << " CQueryTreeNode::addChild(inChild,1) " << inChild << flush ; inChild->checkNPrint();
mChildren.push_back(make_pair(inChild,inWeight));
cout << "AFTER CQueryTreeNode::addChild(inChild,1) " << inChild << flush ; mChildren.back().first->checkNPrint();
};
/**
*
* do a query
*
*/
CXMLElement* CQueryTreeNode::query(const CXMLElement& inQuery){
if(mContent)
return mContent->query(inQuery);
return 0;
};
/**
*
* @short a query which returns ID/RelevanceLevel pairs instead of
* instead of URL/RelevanceLevel pairs
*
*/
CIDRelevanceLevelPairList* CQueryTreeNode::fastQuery(const CXMLElement& inQuery,
int inNumberOfInterestingImages,
double inDifferenceToBest){
if(mContent)
return mContent->fastQuery(inQuery,
inNumberOfInterestingImages,
inDifferenceToBest);
return 0;
}
|