CSIM: Setting and getting field values of objects
At the Matlab level CSIM allows you to set and get values of fields of objects by means of the commands
o is the handle of the object returned by
We implemented this mechanism using four classes:
fieldname is a string identifying the field (i.e. the name of the field).
csimClass : the base classes of all classes in CSIM which implements the basic set and get methodes for accessable fields
csimClassInfo : which stores information (accessible fields, description) about a certain class
To make the set and get methodes of a class derived from csimFieldInfo : stores information about a certain field of a given class 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
can be made accessible fields.
Each field has the following associated information (see
It woul be a tedious work to code all the access : READWRITE or READONLY units lower and upper bound size : the number of elements if the field is of type
double *, or
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
public class member variables are registered as
protected class member variables are registered as
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
doxygen comment is used as descriptio of the field
If you want to register a class you just put the macro the brief
doxygen comment of a class is used as its description
somewhere in the class definition.
For each of the member variables where you want to change the default behaviour of
Make the float variable
reggen you have to put a
doxygen brief comment where you specify the relevant information.
S a read-writable field with units Volt and a lower and upper bound of -1 and +1 respectively:
Make the double variable //! A voltage scale factor [readwrite; units=Volt; range=(-1,1);]
*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);]
Currently reggen is maintained in
The relevant source file is
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