#include <CAlgorithm.h>

Public Member Functions | |
| virtual void | addChild (const string &, const char *const *const inAttributeList=0) |
| virtual void | addChild (CXMLElement *inChild) |
| bool | configure (CAlgorithmCollection &inBaseConfiguration) |
| void | mergeAttributes (const CAlgorithm &inAlgorithm) |
| void | mergeChildLists (const CAlgorithm &inAlgorithm) |
| string | getCollectionID () const |
| double | getWeight () const |
| string | getAlgorithmName () const |
| pair< bool, string > | getType () const |
| pair< bool, string > | getInheritsFrom () const |
| string | getBaseType () const |
| string | getID () const |
| string | toOldMRML () const |
| void | setDefault (CAlgorithm &inDefault) |
| CAlgorithm * | clone () const |
| CAlgorithm (const char *, const char *const *const inAttributeList=0) | |
| CAlgorithm (const string &, const list< pair< string, string > > &inList) | |
| CAlgorithm (const CXMLElement &inAlgorithm) | |
| CAlgorithm (const CAlgorithm &inAlgorithm) | |
: Wolfgang Müller
Definition at line 43 of file CAlgorithm.h.
| CAlgorithm::CAlgorithm | ( | const char * | inName, | |
| const char *const *const | inAttributeList = 0 | |||
| ) |
hand things through to the CXMLElement constructor
Definition at line 69 of file CAlgorithm.cc.
Referenced by addChild(), and clone().
00070 : 00071 CXMLElement(inName,inAttributeList){ 00072 };
| CAlgorithm::CAlgorithm | ( | const string & | inName, | |
| const list< pair< string, string > > & | inList | |||
| ) |
hand things through to the CXMLElement constructor
Definition at line 75 of file CAlgorithm.cc.
00076 : 00077 CXMLElement(inName,inAttributeList){ 00078 }; //----------------------------------------
| CAlgorithm::CAlgorithm | ( | const CXMLElement & | inAlgorithm | ) |
construct CAlgorithm from XML Element
clone this
Definition at line 42 of file CAlgorithm.cc.
00042 : 00043 CXMLElement(inAlgorithm){ 00044 00045 };
| CAlgorithm::CAlgorithm | ( | const CAlgorithm & | inAlgorithm | ) |
copy constructor
clone this
Definition at line 37 of file CAlgorithm.cc.
00037 : 00038 CXMLElement(inAlgorithm){ 00039 00040 };
| void CAlgorithm::addChild | ( | const string & | inName, | |
| const char *const *const | inAttributeList = 0 | |||
| ) | [virtual] |
Same as in CXMLElement, but making a CAlgorithm instead
Add a child with the given attributes to the current node, and MAKE THIS CHILD THE NEW CURRENT NODE.
Reimplemented from CXMLElement.
Definition at line 51 of file CAlgorithm.cc.
References CXMLElement::addChild(), and CAlgorithm().
Referenced by configure(), startAlgorithmCollectionElement(), and CCommunicationHandler::startAlgorithmElement().
00052 { 00053 //initialize new child 00054 CXMLElement::addChild(static_cast 00055 <CXMLElement*>(new CAlgorithm(inName.c_str(), 00056 inAttributeList))); 00057 }
| void CAlgorithm::addChild | ( | CXMLElement * | inChild | ) | [virtual] |
Same as in CXMLElement, but making a CAlgorithm instead
Add a child with the given attributes to the current node, and MAKE THIS CHILD THE NEW CURRENT NODE.
Reimplemented from CXMLElement.
Definition at line 63 of file CAlgorithm.cc.
References CXMLElement::addChild().
00063 { 00064 //initialize new child 00065 CXMLElement::addChild(inChild); 00066 }
| bool CAlgorithm::configure | ( | CAlgorithmCollection & | inBaseConfiguration | ) |
reading an attribute for strings
here we extend the inheritance mechanism. We do not only look at parents, but also at the default values provided by the configuration.
this is virtual in order to plug in other methods of inheritance
reading attributes with defaults Building a query tree out of the information we have gathered true indicates success...
Definition at line 179 of file CAlgorithm.cc.
References addChild(), mrml_const::algorithm, CXMLElement::child_list_begin(), CXMLElement::child_list_end(), configure(), CAlgorithmCollection::containsAlgorithmByType(), CAlgorithmCollection::getAlgorithmByType(), getBaseType(), CXMLElement::getFather(), CXMLElement::getName(), getType(), CXMLElement::mChildren, mergeAttributes(), and CXMLElement::moveUp().
Referenced by configure(), and CSession::setActiveAlgorithm().
00179 { 00180 // 00181 // merge this with the default algorithm of this type 00182 // 00183 cout << this << endl; 00184 cout << "1" << flush; 00185 if((this->getType().first) 00186 &&(inBaseConfiguration.containsAlgorithmByType(this->getType().second))){ 00187 mergeAttributes(inBaseConfiguration.getAlgorithmByType(this->getType().second)); 00188 00189 CAlgorithm& lDefault(inBaseConfiguration.getAlgorithmByType(this->getType().second)); 00190 00191 //HACK clone children from default if this childlist is empty or contains 00192 //only text nodes. 00193 int lSize=0; 00194 for(lCChildren::const_iterator i=mChildren.begin(); 00195 i!=mChildren.end(); 00196 i++){ 00197 if((*i)->getName()==mrml_const::algorithm){ 00198 lSize++; 00199 } 00200 } 00201 if(!lSize){ 00202 cout << "°°" 00203 << endl; 00204 00205 // mCurrentChild=this; 00206 for(lCChildren::const_iterator i=lDefault.child_list_begin(); 00207 i!=lDefault.child_list_end(); 00208 i++){ 00209 cout << " || " 00210 << mChildren.size() 00211 << ((CAlgorithm*)(*i))->getBaseType() 00212 << endl; 00213 addChild((*i)->clone(true)); 00214 moveUp(); 00215 } 00216 } 00217 cout << "NUMBER OF CHILDREN that are ALGORITHMS " 00218 << lSize 00219 << endl; 00220 //mergeChildLists(inBaseConfiguration.getAlgorithmByType(this->getType().second)); 00221 } 00222 cout << "2" << flush; 00223 // merge with the configuration of the father 00224 if(getFather()){ 00225 mergeAttributes(*(CAlgorithm*)(getFather())); 00226 } 00227 cout << "3" << flush; 00228 00229 00230 // 00231 // 3. Then build the query trees of the children and 00232 // add each child both to the query finding structure 00233 // as to the query tree. 00234 // 00235 for(CXMLElement::lCChildren::const_iterator i=child_list_begin(); 00236 i!=child_list_end(); 00237 i++){ 00238 CXMLElement* lDereferencedI=*i; 00239 00240 if(lDereferencedI->getName()==mrml_const::algorithm){ 00241 CAlgorithm* iAlgorithm=(CAlgorithm*)(lDereferencedI); 00242 cout << "." << flush; 00243 iAlgorithm->configure(inBaseConfiguration); 00244 } 00245 } 00246 if(getFather()){ 00247 //mergeChildLists(*(CAlgorithm*)(getFather())); 00248 } 00249 cout << "4" << flush; 00250 }
| void CAlgorithm::mergeAttributes | ( | const CAlgorithm & | inAlgorithm | ) |
merging the attributes of two algorithms. This is useful: 1. for the initial configuration 2. for changing the configuration.
At present this merges attribute lists givig priority to the values in *this.
FIXME: slow way of merging
merging two algorithms.
general rule: if something is contained already in *this the value of *this will be kept.
first: default values.
Definition at line 259 of file CAlgorithm.cc.
References CAttributeList::add(), CAttributeList::check(), CAttributeList::find(), and CXMLElement::mAttributes.
Referenced by configure().
00259 { 00260 if(&inAlgorithm){ 00261 //STOOPID way of merging, takes n log n time instead of n 00262 for(CAttributeList::const_iterator 00263 i=inAlgorithm.mAttributes.begin(); 00264 i!=inAlgorithm.mAttributes.end(); 00265 i++){ 00266 //add attributes which are not yet found 00267 if(mAttributes.find(i->first)==mAttributes.end()){ 00268 #ifdef SINGLE 00269 mAttributes.add(i->first,i->second); 00270 #else 00271 mAttributes.check(); 00272 mAttributes.add(i->first,i->second.first); 00273 #endif 00274 } 00275 } 00276 } 00277 }
| void CAlgorithm::mergeChildLists | ( | const CAlgorithm & | inAlgorithm | ) |
merging the child lists of two algorithms. This is useful: 1. for the initial configuration 2. for changing the configuration.
At present this merges attribute lists givig priority to the values in *this.
FIXME: slow way of merging
Definition at line 279 of file CAlgorithm.cc.
References CXMLElement::child_list_begin(), CXMLElement::child_list_end(), and CXMLElement::mChildren.
00279 { 00280 if(&inAlgorithm){ 00281 //merge child lists 00282 copy(inAlgorithm.child_list_begin(), 00283 inAlgorithm.child_list_end(), 00284 inserter(mChildren, 00285 child_list_end())); 00286 } 00287 }
| string CAlgorithm::getCollectionID | ( | ) | const |
get the name of the collection to be treated by this algorithm
Definition at line 81 of file CAlgorithm.cc.
References mrml_const::collection_id, and CXMLElement::stringReadAttribute().
Referenced by CQuery::CQuery(), CQMultiple::setAlgorithm(), CQInvertedFile::setAlgorithm(), and CQHierarchy::setAlgorithm().
00081 { 00082 return stringReadAttribute(mrml_const::collection_id).second; 00083 };
| double CAlgorithm::getWeight | ( | ) | const |
get the name of the algorithm
Definition at line 96 of file CAlgorithm.cc.
References mrml_const::cui_weight, and CXMLElement::doubleReadAttribute().
Referenced by CQueryTreeBuilder::buildQueryTree().
00096 { 00097 if(doubleReadAttribute(mrml_const::cui_weight).first){ 00098 return (doubleReadAttribute(mrml_const::cui_weight).second); 00099 }else{ 00100 return 1; 00101 } 00102 };
| string CAlgorithm::getAlgorithmName | ( | ) | const |
get the name of the algorithm
Definition at line 86 of file CAlgorithm.cc.
References mrml_const::algorithm_name, and CXMLElement::stringReadAttribute().
00086 { 00087 return stringReadAttribute(mrml_const::algorithm_name).second; 00088 };
| pair< bool, string > CAlgorithm::getType | ( | ) | const |
get the type of the algorithm
Definition at line 105 of file CAlgorithm.cc.
References mrml_const::algorithm_type, and CXMLElement::stringReadAttribute().
Referenced by CAlgorithmCollection::addAlgorithm(), and configure().
00105 { 00106 return stringReadAttribute(mrml_const::algorithm_type); 00107 };
| pair< bool, string > CAlgorithm::getInheritsFrom | ( | ) | const |
The father inside the configuration
Definition at line 110 of file CAlgorithm.cc.
References CXMLElement::stringReadAttribute().
00110 { 00111 return stringReadAttribute("cui-inherits-from"); 00112 };
| string CAlgorithm::getBaseType | ( | ) | const |
get the basetype of the algorithm
Definition at line 115 of file CAlgorithm.cc.
References mrml_const::cui_base_type, and CXMLElement::stringReadAttribute().
Referenced by CQueryTreeBuilder::buildQueryTree(), CQueryTreeNode::configure(), and configure().
00115 { 00116 return stringReadAttribute(mrml_const::cui_base_type).second; 00117 };
| string CAlgorithm::getID | ( | ) | const |
get the id of the algorithm
Definition at line 91 of file CAlgorithm.cc.
References mrml_const::algorithm_id, and CXMLElement::stringReadAttribute().
Referenced by CQueryTreeBuilder::buildQueryTree(), CSession::setActiveAlgorithm(), toOldMRML(), and CSession::toXML().
00091 { 00092 return stringReadAttribute(mrml_const::algorithm_id).second; 00093 };
| string CAlgorithm::toOldMRML | ( | ) | const |
puts out a flat algorithm tag with just ID and name
Definition at line 120 of file CAlgorithm.cc.
References mrml_const::algorithm, mrml_const::algorithm_id, mrml_const::algorithm_name, getID(), and CXMLElement::getName().
00120 { 00121 return string("<" 00122 + mrml_const::algorithm 00123 + " " 00124 + mrml_const::algorithm_name 00125 + "=\"") 00126 + getName() 00127 + "\" " 00128 + mrml_const::algorithm_id 00129 + "=\"" 00130 + getID() 00131 + "\"/>\n"; 00132 };
| void CAlgorithm::setDefault | ( | CAlgorithm & | inDefault | ) |
set the default we do not take any destroy responsability
| CAlgorithm * CAlgorithm::clone | ( | ) | const |
clone this
clone this
Definition at line 33 of file CAlgorithm.cc.
References CAlgorithm().
Referenced by CAlgorithmCollection::makeAlgorithmByType().
00033 { 00034 return new CAlgorithm(*this); 00035 };
1.5.6