|
|
|||||||||||||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.lmu.ifi.dbs.elki.logging.AbstractLoggable
de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable
de.lmu.ifi.dbs.elki.algorithm.AbstractAlgorithm<O,R>
O
- the type of DatabaseObjects handled by this AlgorithmR
- the type of result to retrieve from this Algorithmpublic abstract class AbstractAlgorithm<O extends DatabaseObject,R extends Result>
AbstractAlgorithm sets the values for flags verbose and time.
This class serves also as a model of implementing an algorithm within this framework.
Any Algorithm that makes use of these flags may extend this class. Beware to make
correct use of parameter settings via the facilities provided within
AbstractParameterizable
as commented with
constructor and methods.
Field Summary | |
---|---|
private boolean |
time
Holds the value of TIME_FLAG . |
private Flag |
TIME_FLAG
Flag to request output of performance time. |
private boolean |
verbose
Holds the value of VERBOSE_FLAG . |
private Flag |
VERBOSE_FLAG
Flag to allow verbose messages while performing the algorithm. |
Fields inherited from class de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable |
---|
optionHandler |
Fields inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable |
---|
debug, logger |
Constructor Summary | |
---|---|
protected |
AbstractAlgorithm()
Adds the flags VERBOSE_FLAG and TIME_FLAG to the option handler. |
Method Summary | |
---|---|
boolean |
isTime()
Returns whether the performance time of the algorithm should be assessed. |
boolean |
isVerbose()
Returns whether verbose messages should be printed while executing the algorithm. |
R |
run(Database<O> database)
Calls the runInTime()-method of extending classes. |
protected abstract R |
runInTime(Database<O> database)
The run method encapsulated in measure of runtime. |
List<String> |
setParameters(List<String> args)
Calls the super method and sets additionally the values of the flags VERBOSE_FLAG and TIME_FLAG . |
void |
setTime(boolean time)
Sets whether whether the time should be assessed while executing the algorithm. |
void |
setVerbose(boolean verbose)
Sets whether verbose messages should be printed while executing the algorithm. |
Methods inherited from class de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable |
---|
addOption, addParameterizable, addParameterizable, checkGlobalParameterConstraints, collectOptions, getAttributeSettings, getParameters, rememberParametersExcept, removeOption, removeParameterizable, shortDescription |
Methods inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable |
---|
debugFine, debugFiner, debugFinest, exception, progress, verbose, warning |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface de.lmu.ifi.dbs.elki.algorithm.Algorithm |
---|
getDescription, getResult |
Methods inherited from interface de.lmu.ifi.dbs.elki.utilities.optionhandling.Parameterizable |
---|
checkGlobalParameterConstraints, collectOptions, getParameters, shortDescription |
Field Detail |
---|
private final Flag VERBOSE_FLAG
Key: -verbose
private boolean verbose
VERBOSE_FLAG
.
private final Flag TIME_FLAG
Key: -time
private boolean time
TIME_FLAG
.
Constructor Detail |
---|
protected AbstractAlgorithm()
VERBOSE_FLAG
and TIME_FLAG
to the option handler. Any extending
class should call this constructor, then add further parameters.
Subclasses can add further parameters using
AbstractParameterizable.addOption(de.lmu.ifi.dbs.elki.utilities.optionhandling.Option)
Method Detail |
---|
public List<String> setParameters(List<String> args) throws ParameterException
VERBOSE_FLAG
and TIME_FLAG
.
setParameters
in interface Parameterizable
setParameters
in class AbstractParameterizable
args
- parameters to set the attributes accordingly to
ParameterException
- in case of wrong parameter-settingpublic boolean isTime()
public boolean isVerbose()
public void setVerbose(boolean verbose)
Algorithm
setVerbose
in interface Algorithm<O extends DatabaseObject,R extends Result>
verbose
- the flag to allow verbose messages while performing the algorithmpublic void setTime(boolean time)
Algorithm
setTime
in interface Algorithm<O extends DatabaseObject,R extends Result>
time
- the flag to request output of performance timepublic final R run(Database<O> database) throws IllegalStateException
run
in interface Algorithm<O extends DatabaseObject,R extends Result>
database
- the database to run the algorithm on
IllegalStateException
- if the algorithm has not been initialized
properly (e.g. the setParameters(String[]) method has been failed
to be called).protected abstract R runInTime(Database<O> database) throws IllegalStateException
database
- the database to run the algorithm on
IllegalStateException
- if the algorithm has not been initialized
properly (e.g. the setParameters(String[]) method has been failed
to be called).
|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |