fix(reaclib): added species.h header so compiler directives are defined
This commit is contained in:
@@ -104,6 +104,10 @@ namespace serif::network::reaclib {
|
||||
<< "Chapter: " << reaction.m_chapter << ")";
|
||||
return os;
|
||||
}
|
||||
|
||||
friend bool operator==(const REACLIBReaction& lhs, const REACLIBReaction& rhs);
|
||||
|
||||
friend bool operator!=(const REACLIBReaction& lhs, const REACLIBReaction& rhs);
|
||||
};
|
||||
|
||||
class REACLIBReactionSet {
|
||||
@@ -136,6 +140,15 @@ namespace serif::network::reaclib {
|
||||
return false;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool contains(const REACLIBReaction& reaction) const {
|
||||
for (const auto& r : m_reactions) {
|
||||
if (r == reaction) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
[[nodiscard]] size_t size() const {
|
||||
return m_reactions.size();
|
||||
}
|
||||
@@ -170,6 +183,16 @@ namespace serif::network::reaclib {
|
||||
return m_reactions.end();
|
||||
}
|
||||
|
||||
bool containsSpecies(const serif::atomic::Species &species) const {
|
||||
for (const auto& reaction : m_reactions) {
|
||||
if (std::ranges::find(reaction.reactants(), species) != reaction.reactants().end() ||
|
||||
std::ranges::find(reaction.products(), species) != reaction.products().end()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
[[nodiscard]] const REACLIBReaction& operator[](size_t index) const {
|
||||
if (index >= m_reactions.size()) {
|
||||
throw std::out_of_range("Index out of range in REACLIBReactionSet.");
|
||||
@@ -188,6 +211,7 @@ namespace serif::network::reaclib {
|
||||
[[nodiscard]] auto end() const {
|
||||
return m_reactions.cend();
|
||||
}
|
||||
|
||||
};
|
||||
static std::unordered_map<std::string, REACLIBReaction> s_all_reaclib_reactions;
|
||||
static bool s_initialized = false;
|
||||
@@ -198,6 +222,18 @@ namespace serif::network::reaclib {
|
||||
inline bool operator!=(const REACLIBReaction& lhs, const REACLIBReaction& rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
inline bool operator==(const REACLIBReactionSet& lhs, const REACLIBReactionSet& rhs) {
|
||||
if (lhs.size() != rhs.size()) return false;
|
||||
for (const auto& reaction : lhs) {
|
||||
if (!rhs.contains(reaction)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool operator!=(const REACLIBReactionSet& lhs, const REACLIBReactionSet& rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
}
|
||||
|
||||
namespace std {
|
||||
|
||||
Reference in New Issue
Block a user