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 << ")";
|
<< "Chapter: " << reaction.m_chapter << ")";
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
friend bool operator==(const REACLIBReaction& lhs, const REACLIBReaction& rhs);
|
||||||
|
|
||||||
|
friend bool operator!=(const REACLIBReaction& lhs, const REACLIBReaction& rhs);
|
||||||
};
|
};
|
||||||
|
|
||||||
class REACLIBReactionSet {
|
class REACLIBReactionSet {
|
||||||
@@ -136,6 +140,15 @@ namespace serif::network::reaclib {
|
|||||||
return false;
|
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 {
|
[[nodiscard]] size_t size() const {
|
||||||
return m_reactions.size();
|
return m_reactions.size();
|
||||||
}
|
}
|
||||||
@@ -170,6 +183,16 @@ namespace serif::network::reaclib {
|
|||||||
return m_reactions.end();
|
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 {
|
[[nodiscard]] const REACLIBReaction& operator[](size_t index) const {
|
||||||
if (index >= m_reactions.size()) {
|
if (index >= m_reactions.size()) {
|
||||||
throw std::out_of_range("Index out of range in REACLIBReactionSet.");
|
throw std::out_of_range("Index out of range in REACLIBReactionSet.");
|
||||||
@@ -188,6 +211,7 @@ namespace serif::network::reaclib {
|
|||||||
[[nodiscard]] auto end() const {
|
[[nodiscard]] auto end() const {
|
||||||
return m_reactions.cend();
|
return m_reactions.cend();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
static std::unordered_map<std::string, REACLIBReaction> s_all_reaclib_reactions;
|
static std::unordered_map<std::string, REACLIBReaction> s_all_reaclib_reactions;
|
||||||
static bool s_initialized = false;
|
static bool s_initialized = false;
|
||||||
@@ -198,6 +222,18 @@ namespace serif::network::reaclib {
|
|||||||
inline bool operator!=(const REACLIBReaction& lhs, const REACLIBReaction& rhs) {
|
inline bool operator!=(const REACLIBReaction& lhs, const REACLIBReaction& rhs) {
|
||||||
return !(lhs == 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 {
|
namespace std {
|
||||||
|
|||||||
@@ -8,11 +8,10 @@
|
|||||||
// Note: Only reactions with species defined in the atomicSpecies.h header will be included at compile time.
|
// Note: Only reactions with species defined in the atomicSpecies.h header will be included at compile time.
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "atomicSpecies.h"
|
#include "atomicSpecies.h"
|
||||||
|
#include "species.h"
|
||||||
#include "reaclib.h"
|
#include "reaclib.h"
|
||||||
|
|
||||||
namespace serif::network::reaclib {
|
namespace serif::network::reaclib {
|
||||||
|
|
||||||
|
|
||||||
inline void initializeAllReaclibReactions() {
|
inline void initializeAllReaclibReactions() {
|
||||||
if (s_initialized) return; // already initialized
|
if (s_initialized) return; // already initialized
|
||||||
s_initialized = true;
|
s_initialized = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user