Skip to content
This repository has been archived by the owner on Jan 17, 2020. It is now read-only.

Parameters

Thomas Pengo edited this page May 17, 2014 · 7 revisions

This page describes how to use the module parameters feature in Lemming.

Applies to: 'parameters' branch

Goal

The purpose of this feature is to be able to set parameters for modules, queues, and workspaces in a standardized way.

Use

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.

Example

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);

Printing all parameters

    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());

Home

Installation

Getting Started

Cookbook

Development

Clone this wiki locally