de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization
Class TrackParameters

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.TrackParameters
All Implemented Interfaces:
Parameterization

public class TrackParameters
extends Object
implements Parameterization

Utility wrapper to track parameters for a configuration session. All actual Parameterization operations are forwarded to the inner class.


Field Summary
(package private)  Map<Object,List<Object>> children
          Tree information: child links
(package private)  Object cur
          Current parent for nested parameterization
(package private)  Parameterization inner
          Inner parameterization
(package private)  Vector<Pair<Object,Parameter<?,?>>> options
          Tracking storage
(package private)  Map<Object,Object> parents
          Tree information: parent links
 
Constructor Summary
  TrackParameters(Parameterization inner)
          Constructor.
private TrackParameters(Parameterization inner, Object option, Vector<Pair<Object,Parameter<?,?>>> options, Map<Object,Object> parents, Map<Object,List<Object>> children)
          Internal constructor, for nested tracking.
 
Method Summary
 boolean checkConstraint(GlobalParameterConstraint constraint)
          Check a parameter constraint.
 Parameterization descend(Object option)
          Descend parameterization tree into sub-option.
 Collection<Pair<Object,Parameter<?,?>>> getAllParameters()
          Get all seen parameters, set or unset, along with their owner objects.
 Collection<ParameterException> getErrors()
          Get the configuration errors thrown in Parameterization.grab(de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters.Parameter)
 Collection<Pair<OptionID,Object>> getGivenParameters()
          Get the tracked parameters that were actually set.
 Object getParent(Object pos)
          Traverse the tree upwards.
 boolean grab(Parameter<?,?> opt)
          Get the option value from the Parameterization.
 boolean hasErrors()
          Return true when there have been errors.
 boolean hasUnusedParameters()
          Check for unused parameters
private  void registerChild(Object opt)
           
 void reportError(ParameterException e)
          Report a configuration error.
 boolean setValueForOption(Parameter<?,?> opt)
          Assign a value for an option, but not using default values and throwing exceptions on error.
<C> C
tryInstantiate(Class<C> c)
          Try to instantiate a particular class.
<C> C
tryInstantiate(Class<C> r, Class<?> c)
          Try to instantiate a particular class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inner

Parameterization inner
Inner parameterization


options

Vector<Pair<Object,Parameter<?,?>>> options
Tracking storage


parents

Map<Object,Object> parents
Tree information: parent links


children

Map<Object,List<Object>> children
Tree information: child links


cur

Object cur
Current parent for nested parameterization

Constructor Detail

TrackParameters

public TrackParameters(Parameterization inner)
Constructor.

Parameters:
inner - Inner parameterization to wrap.

TrackParameters

private TrackParameters(Parameterization inner,
                        Object option,
                        Vector<Pair<Object,Parameter<?,?>>> options,
                        Map<Object,Object> parents,
                        Map<Object,List<Object>> children)
Internal constructor, for nested tracking.

Parameters:
inner -
option -
options -
parents -
children -
Method Detail

getErrors

public Collection<ParameterException> getErrors()
Description copied from interface: Parameterization
Get the configuration errors thrown in Parameterization.grab(de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters.Parameter)

Specified by:
getErrors in interface Parameterization
Returns:
Configuration errors encountered

hasErrors

public boolean hasErrors()
Description copied from interface: Parameterization
Return true when there have been errors.

Specified by:
hasErrors in interface Parameterization
Returns:
Success code

grab

public boolean grab(Parameter<?,?> opt)
Description copied from interface: Parameterization
Get the option value from the Parameterization. Note: this method returns success; the actual value can be obtained from opt itself! In particular Parameterization.grab(de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters.Parameter) can return true when Flag.getValue() returns false! Instead the semantics of grab are those of Parameter#isDefined(). This method will catch ParameterExceptions and store them to be retrieved by Parameterization.getErrors().

Specified by:
grab in interface Parameterization
Parameters:
opt - Option to add
Returns:
if the value is available (= readable)

hasUnusedParameters

public boolean hasUnusedParameters()
Description copied from interface: Parameterization
Check for unused parameters

Specified by:
hasUnusedParameters in interface Parameterization
Returns:
true if at least one parameter was not consumed

reportError

public void reportError(ParameterException e)
Description copied from interface: Parameterization
Report a configuration error.

Specified by:
reportError in interface Parameterization
Parameters:
e - Destination to report errors to

setValueForOption

public boolean setValueForOption(Parameter<?,?> opt)
                          throws ParameterException
Description copied from interface: Parameterization
Assign a value for an option, but not using default values and throwing exceptions on error.

Specified by:
setValueForOption in interface Parameterization
Parameters:
opt - Parameter to set
Returns:
Success code
Throws:
ParameterException - on assignment errors.

getAllParameters

public Collection<Pair<Object,Parameter<?,?>>> getAllParameters()
Get all seen parameters, set or unset, along with their owner objects.

Returns:
Parameters seen

getGivenParameters

public Collection<Pair<OptionID,Object>> getGivenParameters()
Get the tracked parameters that were actually set.

Returns:
Parameters given

checkConstraint

public boolean checkConstraint(GlobalParameterConstraint constraint)
Check a parameter constraint.

Specified by:
checkConstraint in interface Parameterization
Parameters:
constraint - Parameter constraint
Returns:
test result

descend

public Parameterization descend(Object option)
Descend parameterization tree into sub-option. Note: this is done automatically by a ClassParameter.instantiateClass(de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.Parameterization). You only need to call this when you want to expose the tree structure without offering a class choice as parameter. Track parameters using a shared options list with parent tracker.

Specified by:
descend in interface Parameterization
Parameters:
option - Option subtree
Returns:
Parameterization

registerChild

private void registerChild(Object opt)

getParent

public Object getParent(Object pos)
Traverse the tree upwards.

Parameters:
pos - Current object
Returns:
Parent object

tryInstantiate

public <C> C tryInstantiate(Class<C> r,
                            Class<?> c)
Description copied from interface: Parameterization
Try to instantiate a particular class.

Specified by:
tryInstantiate in interface Parameterization
Type Parameters:
C - return type
Parameters:
r - Restriction class
c - Base class
Returns:
class instance or null

tryInstantiate

public <C> C tryInstantiate(Class<C> c)
Description copied from interface: Parameterization
Try to instantiate a particular class.

Specified by:
tryInstantiate in interface Parameterization
Type Parameters:
C - return type
Parameters:
c - Base class
Returns:
class instance or null

Release 0.4.0 (2011-09-20_1324)