mttCheckInterfaceDeclarations.m 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. function mttCheckInterfaceDeclarations(model)
  2. for i = 1:length(model.sympar)
  3. mttAssert(~ismember(model.sympar{i},model.numpar),...
  4. ['Same name (',model.sympar{i},') used for "numpar" and "abg[...]" parameters']) ;
  5. mttAssert(~ismember(model.sympar{i},model.input),...
  6. ['Same name (',model.sympar{i},') used for "input" and "abg[...]" parameters']) ;
  7. end
  8. for i = 1:length(model.numpar)
  9. mttAssert(~ismember(model.numpar{i},model.input),...
  10. ['Same name (',model.numpar{i},') used for "numpar" and "input" parameters']) ;
  11. mttAssert(~ismember(model.numpar{i},model.sympar),...
  12. ['Same name (',model.numpar{i},') used for "numpar" and "abg[...]" parameters']) ;
  13. end
  14. for i = 1:length(model.input)
  15. mttAssert(~ismember(model.input{i},model.sympar),...
  16. ['Same name (',model.input{i},') used for "input" and "abg[...]" parameters']) ;
  17. mttAssert(~ismember(model.input{i},model.numpar),...
  18. ['Same name (',model.input{i},') used for "numpar" and "input" parameters']) ;
  19. end
  20. all_parameters = [] ;
  21. if ~isempty(model.sympar)
  22. all_parameters = model.sympar ;
  23. end
  24. if ~isempty(model.numpar)
  25. if isempty(all_parameters)
  26. all_parameters = model.numpar ;
  27. else
  28. all_parameters = [all_parameters, model.numpar] ;
  29. end
  30. end
  31. if ~isempty(model.input)
  32. if isempty(all_parameters)
  33. all_parameters = model.input ;
  34. else
  35. all_parameters = [all_parameters, model.input] ;
  36. end
  37. end
  38. object_names = mttGetFieldNames(model,'obj') ;
  39. if ~isempty(all_parameters)
  40. for i = 1:length(object_names)
  41. object_name = object_names{i} ;
  42. object = getfield(model,'obj',object_name) ;
  43. for j = 1:length(object.parameter)
  44. object_parameter = object.parameter{j} ;
  45. if ~isnumeric(object_parameter)
  46. mttAssert(ismember(object_parameter,all_parameters),...
  47. ['Object parameter "',object.parameter{j},'" not previously declared']) ;
  48. end
  49. end
  50. end
  51. for j = 1:length(all_parameters)
  52. current_parameter = all_parameters{j} ;
  53. other_parameters = all_parameters ;
  54. other_parameters(j) = [] ;
  55. mttAssert(~ismember(current_parameter,other_parameters),...
  56. ['Repeated parameter/input name "',current_parameter,'"']) ;
  57. end
  58. end