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 8f19f0b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
16 changes: 6 additions & 10 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_not_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_not_exists(param.name);

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

template <class T>
bool Parameters<T>::exists( std::string search_name )
void Parameters<T>::assert_not_exists( std::string search_name )
{
if( find_index( search_name ) == -1 )
{ return false; }
{ return; }

std::cout << "ERROR: Parameter " << search_name << " already exists. Make sure all parameters (of a given type) have unique names." << std::endl;
return true;
exit(-1);
}

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_not_exists(std::string search_name);
};

class User_Parameters
Expand Down

0 comments on commit 8f19f0b

Please sign in to comment.