GridFire v0.7.0-alpha
General Purpose Nuclear Network
Loading...
Searching...
No Matches
gridfire::ReactionSet Class Referencefinal

#include <reaction.h>

Public Member Functions

 ReactionSet (std::vector< std::unique_ptr< Reaction > > &&reactions)
 Constructs a ReactionSet from a vector of reactions.
 
 ReactionSet (const std::vector< Reaction * > &reactions)
 
 ReactionSet ()
 
 ReactionSet (const ReactionSet &other)
 Copy constructor.
 
ReactionSetoperator= (const ReactionSet &other)
 Copy assignment operator.
 
void add_reaction (const Reaction &reaction)
 Adds a reaction to the set.
 
void add_reaction (std::unique_ptr< Reaction > &&reaction)
 
void extend (const ReactionSet &other)
 
std::optional< std::unique_ptr< Reaction > > get (const std::string_view &id) const
 
void remove_reaction (const Reaction &reaction)
 Removes a reaction from the set.
 
bool contains (const std::string_view &id) const
 Checks if the set contains a reaction with the given ID.
 
bool contains (const Reaction &reaction) const
 Checks if the set contains the given reaction.
 
size_t size () const
 Gets the number of reactions in the set.
 
void clear ()
 Removes all reactions from the set.
 
bool contains_species (const fourdst::atomic::Species &species) const
 Checks if any reaction in the set involves the given species.
 
bool contains_reactant (const fourdst::atomic::Species &species) const
 Checks if any reaction in the set contains the given species as a reactant.
 
bool contains_product (const fourdst::atomic::Species &species) const
 Checks if any reaction in the set contains the given species as a product.
 
const Reactionoperator[] (size_t index) const
 Accesses a reaction by its index.
 
const Reactionoperator[] (const std::string_view &id) const
 Accesses a reaction by its ID.
 
bool operator== (const ReactionSet &other) const
 Compares this set with another for equality.
 
bool operator!= (const ReactionSet &other) const
 Compares this set with another for inequality.
 
uint64_t hash (uint64_t seed) const
 Computes a hash for the entire set.
 
std::unordered_set< fourdst::atomic::Species > getReactionSetSpecies () const
 
Iterators

Provides iterators to loop over the reactions in the set.

auto begin ()
 
auto begin () const
 
auto end ()
 
auto end () const
 

Private Attributes

quill::Logger * m_logger = fourdst::logging::LogManager::getInstance().getLogger("log")
 
std::vector< std::unique_ptr< Reaction > > m_reactions
 
std::string m_id
 
std::unordered_map< std::string, size_t > m_reactionNameMap
 Maps reaction IDs to Reaction objects for quick lookup.
 

Friends

std::ostream & operator<< (std::ostream &os, const ReactionSet &rs)
 

Constructor & Destructor Documentation

◆ ReactionSet() [1/4]

gridfire::reaction::ReactionSet::ReactionSet ( std::vector< std::unique_ptr< Reaction > > && reactions)
explicit

Constructs a ReactionSet from a vector of reactions.

Parameters
reactionsThe initial vector of Reaction objects.

◆ ReactionSet() [2/4]

gridfire::reaction::ReactionSet::ReactionSet ( const std::vector< Reaction * > & reactions)
explicit

◆ ReactionSet() [3/4]

gridfire::reaction::ReactionSet::ReactionSet ( )
default

◆ ReactionSet() [4/4]

gridfire::reaction::ReactionSet::ReactionSet ( const ReactionSet & other)

Copy constructor.

Parameters
otherThe ReactionSet to copy.

Member Function Documentation

◆ add_reaction() [1/2]

void gridfire::reaction::ReactionSet::add_reaction ( const Reaction & reaction)

Adds a reaction to the set.

Parameters
reactionThe Reaction to add.

◆ add_reaction() [2/2]

void gridfire::reaction::ReactionSet::add_reaction ( std::unique_ptr< Reaction > && reaction)

◆ begin() [1/2]

auto gridfire::reaction::ReactionSet::begin ( )
inline

◆ begin() [2/2]

auto gridfire::reaction::ReactionSet::begin ( ) const
inlinenodiscard

◆ clear()

void gridfire::reaction::ReactionSet::clear ( )

Removes all reactions from the set.

◆ contains() [1/2]

bool gridfire::reaction::ReactionSet::contains ( const Reaction & reaction) const
nodiscard

Checks if the set contains the given reaction.

Parameters
reactionThe Reaction to find.
Returns
True if the reaction is in the set, false otherwise.

◆ contains() [2/2]

bool gridfire::reaction::ReactionSet::contains ( const std::string_view & id) const
nodiscard

Checks if the set contains a reaction with the given ID.

Parameters
idThe ID of the reaction to find.
Returns
True if the reaction is in the set, false otherwise.

◆ contains_product()

bool gridfire::reaction::ReactionSet::contains_product ( const fourdst::atomic::Species & species) const
nodiscard

Checks if any reaction in the set contains the given species as a product.

Parameters
speciesThe species to check for.
Returns
True if the species is a product in any reaction.

◆ contains_reactant()

bool gridfire::reaction::ReactionSet::contains_reactant ( const fourdst::atomic::Species & species) const
nodiscard

Checks if any reaction in the set contains the given species as a reactant.

Parameters
speciesThe species to check for.
Returns
True if the species is a reactant in any reaction.

◆ contains_species()

bool gridfire::reaction::ReactionSet::contains_species ( const fourdst::atomic::Species & species) const
nodiscard

Checks if any reaction in the set involves the given species.

Parameters
speciesThe species to check for.
Returns
True if the species is involved in any reaction.

◆ end() [1/2]

auto gridfire::reaction::ReactionSet::end ( )
inline

◆ end() [2/2]

auto gridfire::reaction::ReactionSet::end ( ) const
inlinenodiscard

◆ extend()

void gridfire::reaction::ReactionSet::extend ( const ReactionSet & other)

◆ get()

std::optional< std::unique_ptr< Reaction > > gridfire::reaction::ReactionSet::get ( const std::string_view & id) const
nodiscard

◆ getReactionSetSpecies()

std::unordered_set< Species > gridfire::reaction::ReactionSet::getReactionSetSpecies ( ) const
nodiscard

◆ hash()

uint64_t gridfire::reaction::ReactionSet::hash ( uint64_t seed) const
nodiscard

Computes a hash for the entire set.

Parameters
seedThe seed for the hash function.
Returns
A 64-bit hash value.

The algorithm computes the hash of each individual reaction, sorts the hashes, and then computes a final hash over the sorted list of hashes. This ensures the hash is order-independent.

◆ operator!=()

bool gridfire::reaction::ReactionSet::operator!= ( const ReactionSet & other) const

Compares this set with another for inequality.

Parameters
otherThe other ReactionSet to compare with.
Returns
True if the sets are not equal.

◆ operator=()

ReactionSet & gridfire::reaction::ReactionSet::operator= ( const ReactionSet & other)

Copy assignment operator.

Parameters
otherThe ReactionSet to assign from.
Returns
A reference to this ReactionSet.

◆ operator==()

bool gridfire::reaction::ReactionSet::operator== ( const ReactionSet & other) const

Compares this set with another for equality.

Parameters
otherThe other ReactionSet to compare with.
Returns
True if the sets are equal (same size and hash).

◆ operator[]() [1/2]

const Reaction & gridfire::reaction::ReactionSet::operator[] ( const std::string_view & id) const
nodiscard

Accesses a reaction by its ID.

Parameters
idThe ID of the reaction to access.
Returns
A const reference to the Reaction.
Exceptions
std::out_of_rangeif no reaction with the given ID exists.

◆ operator[]() [2/2]

const Reaction & gridfire::reaction::ReactionSet::operator[] ( size_t index) const
nodiscard

Accesses a reaction by its index.

Parameters
indexThe index of the reaction to access.
Returns
A const reference to the Reaction.
Exceptions
std::out_of_rangeif the index is out of bounds.

◆ remove_reaction()

void gridfire::reaction::ReactionSet::remove_reaction ( const Reaction & reaction)

Removes a reaction from the set.

Parameters
reactionThe Reaction to remove.

◆ size()

size_t gridfire::reaction::ReactionSet::size ( ) const
inlinenodiscard

Gets the number of reactions in the set.

Returns
The size of the set.

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const ReactionSet & rs )
friend

Member Data Documentation

◆ m_id

std::string gridfire::reaction::ReactionSet::m_id
private

◆ m_logger

quill::Logger* gridfire::reaction::ReactionSet::m_logger = fourdst::logging::LogManager::getInstance().getLogger("log")
private

◆ m_reactionNameMap

std::unordered_map<std::string, size_t> gridfire::reaction::ReactionSet::m_reactionNameMap
private

Maps reaction IDs to Reaction objects for quick lookup.

◆ m_reactions

std::vector<std::unique_ptr<Reaction> > gridfire::reaction::ReactionSet::m_reactions
private

The documentation for this class was generated from the following files: