rbmatlab  1.13.10
 All Classes Namespaces Files Functions Variables Groups Pages
gen_detailed_model.m
Go to the documentation of this file.
1 function dmodel = gen_detailed_model(descr)
2 % function dmodel = gen_detailed_model(descr)
3 % generates an IDetailedModel instance from a description structure.
4 %
5 % This function constructs the correct IDetailedModel instance for a ModelDescr
6 % structure. The field 'rb_problem_type' should contain the package name of the
7 % 'DetailedModel' class. If e.g. 'descr.rb_problem_type' equals the string
8 % 'LinEvol', an object of type LinEvol.DetailedModel is returned.
9 %
10 % The class type of the returned object can also be chosen explictly by
11 % specifying the field 'descr.dmodel_constructor'.
12 %
13 % Parameters:
14 % descr: a Matlab structure of type ModelDescr.
15 
16 if ~isfield(descr, 'rb_problem_type')
17  error('ModelDescr does not have the required field ''rb_problem_type''');
18 end
19 
20 if ~isfield(descr, 'dmodel_constructor') || isempty(descr.dmodel_constructor)
21  descr.dmodel_constructor = eval(['@', descr.rb_problem_type, '.DetailedModel']);
22 end
23 
24 dmodel = descr.dmodel_constructor(descr);
25 
26 end