We implemented this mechanism using four classes:

  • csimClass : the base classes of all classes in CSIM which implements the basic set and get methodes for accessable fields

  • csimClassInfoDB : a container (of csimClassInfo objects) where information about all the (at the matlab level) available classes is stored

  • csimClassInfo : which stores information (accessible fields, description) about a certain class

  • csimFieldInfo : stores information about a certain field of a given class

Registering classes and fields

To make the set and get methodes of a class derived from csimClass work one has to register this class via csimClassInfoDB::registerCsimClass() and then to register each member variable which we want to be an accessable field via csimClassInfo::registerField() .

Class member variable of the types

  • double and double $\ast$
  • float and float $\ast$
  • int and int $\ast$

can be made accessible fields.

Each field has the following associated information (see csimFieldInfo )

  • access : READWRITE or READONLY
  • units
  • lower and upper bound
  • size : the number of elements if the field is of type float $\ast$, double $\ast$, or int $\ast$


It woul be a tedious work to code all the csimClassInfoDB::registerCsimClass() and csimClassInfo::registerField() function calls by hand. So we decided to generate it automatically from the source code. We use a tool named reggen (a quick and dirty hack based on doxygen) to gather the infomation from the source code and its doxygen style documentation. reggen writes all relevant function calls to register fields an classes to registerclass.i

Default behaviour of $\backslash$c reggen

  • public class member variables are registered as READWRITE fields

  • protected class member variables are registered as READONLY

  • private class member variables are not registered.

  • no units are assumed (i.e. a dimensionless field)

  • lower and upper bound are set to -Inf and +Inf respectively

  • an warning is issued if no size information is given for arrays

  • the brief doxygen comment is used as descriptio of the field

  • the brief doxygen comment of a class is used as its description

Specifying information for use by reggen

If you want to register a class you just put the macro DO_REGISTERING somewhere in the class definition.

For each of the member variables where you want to change the default behaviour of reggen you have to put a doxygen brief comment where you specify the relevant information.

Example 1
Make the float variable S a read-writable field with units Volt and a lower and upper bound of -1 and +1 respectively:

  //! A voltage scale factor [readwrite; units=Volt; range=(-1,1);]
  float S;
Example 2
Make the double variable $\ast$A a read-only field with 20 elements, units Ohm, and a lower and upper bound of -100 and +100 respectively:

  //! A voltage scale factor [readonly; size=20; units=Ohm; range=(-100,100);]
  double *A;

Source code of reggen

  • Currently reggen is maintained in lsm/develop/reggen .
  • The relevant source file is lsm/develop/reggen/src/defgen.cpp .
  • The binaries are lsm/develop/reggen/bin/reggen for Linux and lsm/develop/reggen/bin/reggen.exe for windows.
  • To compile reggen under Linux type

  cd lsm/develop/reggen; ./configure; make

  • To compile reggen under Windows XP with MS Visual C++ type

  cd lsm/develop/reggen; make.bat msvc

(C) 2003, Thomas Natschläger last modified 07/10/2006