PhysiCell icon indicating copy to clipboard operation
PhysiCell copied to clipboard

Feature find missing parameter

Open drbergman opened this issue 2 years ago • 0 comments

This adds a new member function to the Parameters class. It is called find_variable_index. This function behaves exactly like the already-existing Parameters.find_index except it will return -1 when the input string is not in the user_parameters. For developers, such as PhysiPKPD, relying on user_parameters to make their code run, this gives the ability to protect their end users from missing parameters and typos.

By contrast, find_index would add the missing string to the keys of the unordered_map and assign it the default value of 0. That means the call to the missing parameter will actually return the value of the parameter (of the same type) with index 0 without warning.

There are two reasons for the similarity between the names find_variable_index and find_index.

  1. Autofill features of standard C++ editors will make both options easily findable.
  2. find_variable_index is analogous to the member function of Custom_Cell_Data class of the same name, which may help coders distinguish the two a little bit.

drbergman avatar Aug 13 '22 20:08 drbergman