-
Notifications
You must be signed in to change notification settings - Fork 0
Parameters
This page describes how to use the module parameters feature in Lemming.
Applies to: 'parameters' branch
The purpose of this feature is to be able to set parameters for modules, queues, and workspaces in a standardized way.
Any public field of a module can be tagged by the @Parameter
annotation. This
tags the specified field to be accessible through methods from the Parameters
class.
This is how to tag a field as a parameter.
public class Module1 {
@Parameter
public long noFrames = 0;
}
Now, you you can read the field the usual way, as:
Module1 mod = new Module1();
long tmp = mod.noFrames;
or using the Parameters class:
Module1 mod = new Module1();
long tmp = Parameters.get("noFrames");
or:
Module1 mod = new Module1();
Map<String,Object> params = Parameters.getParameterMap(mod);
long tmp = (long) params.get("noFrames");
Notice that the params
map is an interface to the actual fields in mod
, so setting the values in the map, you set the values in the original mod
. If the values change after creating the map, the map reflects this. This allows not to deal with having the actual parameters and the map with a copy of the parameters.
Likewise, if you want to set the value of the parameter, you have the same options:
Module1 mod = new Module1();
mod.noFrames = 50;
or:
Module1 mod = new Module1();
Parameters.setParameter(mod,"noFrames",50);
or:
Module1 mod = new Module1();
Map<String,Object> params = Parameters.getParameterMap(mod);
params.put("noFrames",50);
Module1 mod = new Module1();
Map<String,Object> params = Parameters.getParameterMap(mod);
for (Entry<String, Object> e : parameters.entrySet())
System.out.println(e.getKey()+" = "+e.getValue());
Installation
Getting Started
Cookbook
Development