-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const transport::Reaction& reaction( const std::string& label ) const { | ||
|
||
return this->reactions().reaction( label ); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const transport::Reaction& reaction( const std::string& label ) const { | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
auto getLabel = [] ( const auto& variant ) | ||
This comment has been minimized.
Sorry, something went wrong. |
||
{ return variant.get().label().value(); }; | ||
|
||
auto iter std::find_if( this->content.reaction.begin(), this->content.reaction.end(), | ||
This comment has been minimized.
Sorry, something went wrong. |
||
[&] ( const transport::Reaction& element ) | ||
{ return element.label() == label; } ); | ||
|
||
if ( iter != this->children_.end() ) { | ||
|
||
log::error( "No cross section style \"{}\" can be found", style ); | ||
throw std::exception(); | ||
} | ||
|
||
return *iter; | ||
} |
1 comment
on commit 594fdba
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course, the core interface already provides for queries such as node(reactions,reaction,"label"), given a node that contains a reactions child. (Or if you're in reactions already, just write node(reaction,"label")). The issue here is that we don't have a node, because we're working directly with our "high-level" classes. Each high-level class that's derived from Component - as they all in fact are - automatically gets a conversion to a Node. Through that, a query like this would be short - but computationally intensive, because I'd be making an entire Node on-the-fly each time, just to pull out the one value with a particular label. I'll think about things I might be able to do that would remove the need to write functions like this all over the place throughout the high-level interface. For common activities such as finding something by-level in a sub-node, I could almost certainly write some generic utility function that would do almost all of the work, so that things like this could become one-liners.
This looks incomplete.