Skip to content

Commit

Permalink
Merge pull request #2307 from stinebuu/move_update_value_int
Browse files Browse the repository at this point in the history
Use `updateValue< long >` instead of `update_value_int` in `quantal_stp_synapse`
  • Loading branch information
heplesser committed Mar 27, 2022
2 parents 432fc53 + 0434725 commit be526a6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 35 deletions.
36 changes: 2 additions & 34 deletions models/quantal_stp_synapse_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,38 +36,6 @@
namespace nest
{


/* Polymorphic version of update_value.
* This code will take either an int or a double and convert it to an
* int.
*/
bool
update_value_int( const DictionaryDatum& d, Name propname, int& prop )
{
if ( d->known( propname ) )
{
Datum* dat = ( *d )[ propname ].datum();
IntegerDatum* intdat = dynamic_cast< IntegerDatum* >( dat );
if ( intdat != 0 )
{
prop = static_cast< int >( intdat->get() );
return true;
}
DoubleDatum* doubledat = dynamic_cast< DoubleDatum* >( dat );
if ( doubledat != 0 )
{
prop = static_cast< int >( doubledat->get() );
return true;
}
else
{
throw TypeMismatch();
}
}

return false;
}

template < typename targetidentifierT >
quantal_stp_synapse< targetidentifierT >::quantal_stp_synapse()
: ConnectionBase()
Expand Down Expand Up @@ -108,8 +76,8 @@ quantal_stp_synapse< targetidentifierT >::set_status( const DictionaryDatum& d,
updateValue< double >( d, names::u, u_ );
updateValue< double >( d, names::tau_rec, tau_rec_ );
updateValue< double >( d, names::tau_fac, tau_fac_ );
update_value_int( d, names::n, n_ );
update_value_int( d, names::a, a_ );
updateValue< long >( d, names::n, n_ );
updateValue< long >( d, names::a, a_ );
}

} // of namespace nest
Expand Down
2 changes: 1 addition & 1 deletion sli/dictutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ def( DictionaryDatum& d, Name const n, FT const& value )

/** Update a variable from a dictionary entry if it exists, skip call if it
* doesn't.
* @note If the dictionary entry is an integer, use updateValue< long >.
* @ingroup DictUtils
* @throws see getValue(DictionaryDatum, Name)
*/
Expand Down Expand Up @@ -268,7 +269,6 @@ updateValue2( DictionaryDatum const& d, Name const n, C& obj, void ( C::*setfunc
}
}


/** Create a property of type ArrayDatum in the dictionary, if it does not
* already exist.
* @ingroup DictUtils
Expand Down

0 comments on commit be526a6

Please sign in to comment.