|
|||||||||||
Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages
Setting and getting field values of objectsAt the Matlab level CSIM allows you to set and get values of fields of objects by means of the commands
v=csim('get',o,fieldname) csim('set',o,fieldname,value)
where
o=csim('create',classname)
and ImplementaionWe implemented this mechanism using four classes:
Registering classes and fieldsTo 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
can be made accessible fields. Each field has the following associated information (see csimFieldInfo )
reggenIt 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 namedreggen (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 \c reggen
Specifying information for use by reggenIf you want to register a class you just put the macroDO_REGISTERING somewhere in the class definition.
For each of the member variables where you want to change the default behaviour of Example 1Make the float variableS 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 2Make the double variable*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
cd lsm/develop/reggen; ./configure; make
cd lsm/develop/reggen; make.bat msvc | |||||||||||
(C) 2003, Thomas Natschläger | last modified 07/10/2006 |