Skip to content

Commit

Permalink
fix typos and improve Parameters.exists
Browse files Browse the repository at this point in the history
  • Loading branch information
drbergman committed Jun 20, 2024
1 parent cd4a81e commit a3e9898
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
19 changes: 8 additions & 11 deletions modules/PhysiCell_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,11 +465,7 @@ void Parameters<T>::add_parameter( std::string my_name , T my_value )
template <class T>
void Parameters<T>::add_parameter( std::string my_name , T my_value , std::string my_units )
{
if (exists(my_name))
{
std::cout << "ERROR: Parameter " << my_name << " already exists. Make sure all parameters (of a given type) have unique names." << std::endl;
exit(-1);
}
assert_exists(my_name);

Parameter<T>* pNew;
pNew = new Parameter<T> ;
Expand All @@ -488,8 +484,7 @@ void Parameters<T>::add_parameter( std::string my_name , T my_value , std::strin
template <class T>
void Parameters<T>::add_parameter( Parameter<T> param )
{
if (exists(param.name))
{ exit(-1);}
assert_exists(param.name);

int n = parameters.size();
parameters.push_back( param);
Expand All @@ -498,12 +493,14 @@ void Parameters<T>::add_parameter( Parameter<T> param )
}

template <class T>
bool Parameters<T>::exists( std::string search_name )
void Parameters<T>::assert_exists( std::string search_name )
{
if( find_index( search_name ) == -1 )
{ return false; }
std::cout << "ERROR: Parameter " << search_name << " already exists. Make sure all parameters (of a given type) have unique names." << std::endl;
return true;
{
std::cout << "ERROR: Parameter " << search_name << " already exists. Make sure all parameters (of a given type) have unique names." << std::endl;
exit(-1);
}
return;
}

std::ostream& operator<<( std::ostream& os , const User_Parameters up )
Expand Down
5 changes: 2 additions & 3 deletions modules/PhysiCell_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,9 @@ class Parameters
Parameter<T>& operator[]( int i );
Parameter<T>& operator[]( std::string str );

int size( void ) const;

bool exists( std::string search_name );
int size( void ) const;

void assert_exists(std::string search_name);
};

class User_Parameters
Expand Down

0 comments on commit a3e9898

Please sign in to comment.