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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
|
/* -*- mode: c++ -*-
*/
/*
GIFT, a flexible content based image retrieval system.
Copyright (C) 1998, 1999, 2000, 2001, 2002, CUI University of Geneva
Copyright (C) 2003, 2004 Bayreuth University
2005 Bamberg University
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// -*- mode: c++ -*-
#ifndef _CALGORITHM
#define _CALGORITHM
#include "libMRML/include/uses-declarations.h"
#include "libMRML/include/CXMLElement.h"
#include "libMRML/include/CSelfDestroyPointer.h"
#include <map>
class CQuery;
class CAlgorithmCollection;
/**
An algorithm is a CXMLElement
which is linked to a CSessionManager
together they are able to build CQuery trees.
@Author: Wolfgang Müller
*/
class CAlgorithm:public CXMLElement{
protected:
public:
/**
Same as in CXMLElement, but making a CAlgorithm instead
*/
virtual void addChild(const string&,
const char* const* const inAttributeList=0);
/**
Same as in CXMLElement, but making a CAlgorithm instead
*/
virtual void addChild(CXMLElement* inChild);
// /** 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
// @see: CXMLElement.h#stringReadAttribute
// */
// virtual pair<bool,string> stringReadAttribute(const string& inAttribute)const;
/**
In the long run, we would like to get of build query
tree in this class and move it elsewhere.
The first step of this separation is the configure function,
which does nothing else but putting the inherited values and
the default values into the attribute list of this. After that
no inheritance is necessary, and we can get at all the attributes
using CXMLElement::createNamedValueList;
*/
bool configure(CAlgorithmCollection& inBaseConfiguration);
/** 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
*/
void mergeAttributes(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
*/
void mergeChildLists(const CAlgorithm& inAlgorithm);
/** get the name of the collection to be treated by this algorithm
*/
string getCollectionID()const;
/** get the name of the algorithm
*/
double getWeight()const;
/** get the name of the algorithm
*/
string getAlgorithmName()const;
/** get the type of the algorithm
*/
pair<bool,string> getType()const;
/**
The father inside the configuration
*/
pair<bool,string> getInheritsFrom()const;
/** get the basetype of the algorithm
*/
string getBaseType()const;
/** get the id of the algorithm
*/
string getID()const;
/** puts out a flat algorithm tag with just ID and name */
string toOldMRML()const;
/** set the default we do not take any
destroy responsability
*/
void setDefault(CAlgorithm& inDefault);
/** clone this */
CAlgorithm* clone()const;
/** hand things through to the CXMLElement constructor */
CAlgorithm(const char* ,
const char* const* const inAttributeList=0);
/** hand things through to the CXMLElement constructor */
CAlgorithm(const string& ,
const list< pair<string,string> >& inList);
/** construct CAlgorithm from XML Element */
CAlgorithm(const CXMLElement& inAlgorithm);
/** copy constructor */
CAlgorithm(const CAlgorithm& inAlgorithm);
};
//----------------------------------------
//probably obsolete
//----------------------------------------
class CSortByID_CA:public binary_function<const CAlgorithm&,const CAlgorithm&,bool>{
public:
bool operator()(const CAlgorithm& l,
const CAlgorithm& t)const;
};
//----------------------------------------
//probably obsolete
//----------------------------------------
class CSortByBase_CA:public binary_function<const CAlgorithm&,const CAlgorithm&,bool>{
public:
bool operator()(const CAlgorithm& l,
const CAlgorithm& t)const;
};
#endif
|