Programming Reference:Parameters

From BCI2000 Wiki
Jump to: navigation, search

Individual parameters are represented by instances of the Param class. A collection of Param objects, such as the set of parameters present in a BCI2000 data file, is represented by a ParamList object.

Contents

Param Class

Methods

Param( string name, string section, string type, string value, string defaultvalue, string lowrange, string highrange, string comment )

Constructs a Param object with the properties given as parameters.

Param( string paramDefinition )

Constructs a Param object from a BCI2000 Parameter Definition string.

Param operator=( Param )

Assigns from the given Param object.

Param AssignValues( Param )

Assigns the matrix of parameter values from the given Param object.

Param Unchanged()

Resets the Changed property to false.

Param SetDimensions( int rows, int cols )

Sets the number of rows and columns in the matrix of parameter values.

ostream WriteToStream( ostream ), istream ReadFromStream( istream )

Writes/reads the Param object to/from a stream in human readable format.

ostream WriteBinary( ostream ), istream ReadBinary( istream )

Writes/reads the Param object to/from a BCI2000 binary stream (such as the streams connecting BCI2000 modules).

Properties

This section gives a formal description of a Param object's set of properties. For a full discussion of parameters and their properties, see the BCI2000 Parameter Definition page.

HierarchicalLabel Sections (rw)

The parameter's hierarchy of sections, wrapped into a HierarchicalLabel object.

string Section (rw)

The parameter's top level section, corresponding to tabs in the operator's parameter configuration dialog.

string Type (rw)

The parameter's type.

string Name (r)

The parameter's name. This property is read-only to ensure consistency with the parameter's name index in a ParamList object.

string DefaultValue (rw)

The parameter's default value.

string LowRange (rw)

The lower bound on parameter values.

string HighRange (rw)

The upper bound on parameter values.

string Comment (rw)

The parameter's comment.

bool Changed (r)

The parameter's changed flag is set to true when the parameter is modified. The flag may be reset to false by using the its Unchanged() method.

int NumValues (rw)

For list-valued parameters, the number of entries in the list.

int NumRows (rw)

For matrix-valued parameters, the number of rows in the matrix.

int NumColumns (rw)

For matrix-valued parameters, the number of columns in the matrix.

ParamValue Value( index = 0 ), ParamValue Value( row, col ) (rw)

The parameter's values, indexed by either numeric indices, or strings representing labels. A ParamValue object may either contain a string to represent an individual value, or a Param object to represent a sub-parameter (in case of nested parameters).

LabelIndex Labels (rw)

For a list-valued parameter, the associated labels as a LabelIndex object.

LabelIndex RowLabels (rw)

For a matrix-valued parameter, its row labels as a LabelIndex object.

LabelIndex ColumnLabels (rw)

For a matrix-valued parameter, its column labels as a LabelIndex object.

ParamList Class

Methods

Param operator[]( string name )

Access to an individual Param object by its name.

Param operator[]( int index )

Access to an individual Param object by its index.

Clear()

Removes all Param objects from the list.

bool Exists( string name )

Returns true if a Param object with the given name exists in the list.

int Index( string name )

Returns the index of the Param object with the given name, or the list's size if there is no such Param object.

Add( Param, number sortingHint = 0.0 )

Adds the given Param object to the list. When specified, the sorting hint is used to determine the relative order of Param objects in the list; a smaller value of the sorting hint corresponds to a position closer to the beginning of the list.

Add( string paramDefinition )

Creates a Param object from the specified Parameter Definition, and adds it to the list.

Delete( string name )

Deletes the Param object with the specified name from the list.

bool Save( string filename )

Saves the list as a BCI2000 Parameter File with the specified file name.

bool Load( string filename, bool importNonexisting = true )

Loads parameters from a BCI2000 Parameter File specified in the first argument. For parameters already present in the list, their values are updated from the file. If the importNonexisting flag is set, parameters not present in the list will be added from the file; otherwise, such parameters will be ignored. Parameters from the "System" section will always be ignored.

Sort()

Sorts the list according to their associated sorting hints. Smaller sorting hints will be located closer to the top of the list.

ostream WriteToStream( ostream ), istream ReadFromStream( istream )

Writes/reads the entire parameter list to/from a stream in human readable format.

ostream WriteBinary( ostream ), istream ReadBinary( istream )

Writes/reads the entire parameter list to/from a BCI2000 binary stream (such as used for communication between modules).

Properties

int Size (r)

The number of Param objects in the list.

bool Empty (r)

True if the list is empty, false otherwise.

See also

Technical Reference:Parameter Definition, Programming Reference:Accessing Parameters and States