GridFire 0.0.1a
General Purpose Nuclear Network
Loading...
Searching...
No Matches
gridfire::reaction::TemplatedReactionSet< ReactionT > Class Template Referencefinal

#include <reaction.h>

Public Member Functions

 TemplatedReactionSet (std::vector< ReactionT > reactions)
 Constructs a ReactionSet from a vector of reactions.
 
 TemplatedReactionSet (const TemplatedReactionSet< ReactionT > &other)
 Copy constructor.
 
TemplatedReactionSet< ReactionT > & operator= (const TemplatedReactionSet< ReactionT > &other)
 Copy assignment operator.
 
void add_reaction (ReactionT reaction)
 Adds a reaction to the set.
 
void remove_reaction (const ReactionT &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 ReactionT & operator[] (size_t index) const
 Accesses a reaction by its index.
 
const ReactionT & operator[] (const std::string_view &id) const
 Accesses a reaction by its ID.
 
bool operator== (const TemplatedReactionSet &other) const
 Compares this set with another for equality.
 
bool operator!= (const TemplatedReactionSet &other) const
 Compares this set with another for inequality.
 
uint64_t hash (uint64_t seed=0) 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< ReactionT > m_reactions
 
std::string m_id
 
std::unordered_map< std::string, ReactionT > m_reactionNameMap
 Maps reaction IDs to Reaction objects for quick lookup.
 

Friends

std::ostream & operator<< (std::ostream &os, const TemplatedReactionSet< ReactionT > &r)
 

Detailed Description

template<typename ReactionT>
class gridfire::reaction::TemplatedReactionSet< ReactionT >

Definition at line 402 of file reaction.h.

Constructor & Destructor Documentation

◆ TemplatedReactionSet() [1/2]

template<typename ReactionT>
gridfire::reaction::TemplatedReactionSet< ReactionT >::TemplatedReactionSet ( std::vector< ReactionT > reactions)
explicit

Constructs a ReactionSet from a vector of reactions.

Parameters
reactionsThe initial vector of Reaction objects.

Definition at line 562 of file reaction.h.

◆ TemplatedReactionSet() [2/2]

template<typename ReactionT>
gridfire::reaction::TemplatedReactionSet< ReactionT >::TemplatedReactionSet ( const TemplatedReactionSet< ReactionT > & other)

Copy constructor.

Parameters
otherThe ReactionSet to copy.

Definition at line 577 of file reaction.h.

Member Function Documentation

◆ add_reaction()

template<typename ReactionT>
void gridfire::reaction::TemplatedReactionSet< ReactionT >::add_reaction ( ReactionT reaction)

Adds a reaction to the set.

Parameters
reactionThe Reaction to add.

Definition at line 600 of file reaction.h.

◆ begin() [1/2]

template<typename ReactionT>
auto gridfire::reaction::TemplatedReactionSet< ReactionT >::begin ( )
inline

Definition at line 525 of file reaction.h.

◆ begin() [2/2]

template<typename ReactionT>
auto gridfire::reaction::TemplatedReactionSet< ReactionT >::begin ( ) const
inlinenodiscard

Definition at line 526 of file reaction.h.

◆ clear()

template<typename ReactionT>
void gridfire::reaction::TemplatedReactionSet< ReactionT >::clear ( )

Removes all reactions from the set.

Definition at line 640 of file reaction.h.

◆ contains() [1/2]

template<typename ReactionT>
bool gridfire::reaction::TemplatedReactionSet< ReactionT >::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.

Definition at line 630 of file reaction.h.

◆ contains() [2/2]

template<typename ReactionT>
bool gridfire::reaction::TemplatedReactionSet< ReactionT >::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.

Definition at line 620 of file reaction.h.

◆ contains_product()

template<typename ReactionT>
bool gridfire::reaction::TemplatedReactionSet< ReactionT >::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.

Definition at line 666 of file reaction.h.

◆ contains_reactant()

template<typename ReactionT>
bool gridfire::reaction::TemplatedReactionSet< ReactionT >::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.

Definition at line 656 of file reaction.h.

◆ contains_species()

template<typename ReactionT>
bool gridfire::reaction::TemplatedReactionSet< ReactionT >::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.

Definition at line 646 of file reaction.h.

◆ end() [1/2]

template<typename ReactionT>
auto gridfire::reaction::TemplatedReactionSet< ReactionT >::end ( )
inline

Definition at line 527 of file reaction.h.

◆ end() [2/2]

template<typename ReactionT>
auto gridfire::reaction::TemplatedReactionSet< ReactionT >::end ( ) const
inlinenodiscard

Definition at line 528 of file reaction.h.

◆ getReactionSetSpecies()

template<typename ReactionT>
std::unordered_set< fourdst::atomic::Species > gridfire::reaction::TemplatedReactionSet< ReactionT >::getReactionSetSpecies ( ) const
nodiscard

Definition at line 725 of file reaction.h.

◆ hash()

template<typename ReactionT>
uint64_t gridfire::reaction::TemplatedReactionSet< ReactionT >::hash ( uint64_t seed = 0) 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.

Definition at line 707 of file reaction.h.

◆ operator!=()

template<typename ReactionT>
bool gridfire::reaction::TemplatedReactionSet< ReactionT >::operator!= ( const TemplatedReactionSet< ReactionT > & other) const

Compares this set with another for inequality.

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

Definition at line 702 of file reaction.h.

◆ operator=()

template<typename ReactionT>
TemplatedReactionSet< ReactionT > & gridfire::reaction::TemplatedReactionSet< ReactionT >::operator= ( const TemplatedReactionSet< ReactionT > & other)

Copy assignment operator.

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

Definition at line 590 of file reaction.h.

◆ operator==()

template<typename ReactionT>
bool gridfire::reaction::TemplatedReactionSet< ReactionT >::operator== ( const TemplatedReactionSet< ReactionT > & 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).

Definition at line 694 of file reaction.h.

◆ operator[]() [1/2]

template<typename ReactionT>
const ReactionT & gridfire::reaction::TemplatedReactionSet< ReactionT >::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.

Definition at line 685 of file reaction.h.

◆ operator[]() [2/2]

template<typename ReactionT>
const ReactionT & gridfire::reaction::TemplatedReactionSet< ReactionT >::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.

Definition at line 676 of file reaction.h.

◆ remove_reaction()

template<typename ReactionT>
void gridfire::reaction::TemplatedReactionSet< ReactionT >::remove_reaction ( const ReactionT & reaction)

Removes a reaction from the set.

Parameters
reactionThe Reaction to remove.

Definition at line 607 of file reaction.h.

◆ size()

template<typename ReactionT>
size_t gridfire::reaction::TemplatedReactionSet< ReactionT >::size ( ) const
inlinenodiscard

Gets the number of reactions in the set.

Returns
The size of the set.

Definition at line 453 of file reaction.h.

Friends And Related Symbol Documentation

◆ operator<<

template<typename ReactionT>
std::ostream & operator<< ( std::ostream & os,
const TemplatedReactionSet< ReactionT > & r )
friend

Definition at line 531 of file reaction.h.

Member Data Documentation

◆ m_id

template<typename ReactionT>
std::string gridfire::reaction::TemplatedReactionSet< ReactionT >::m_id
private

Definition at line 551 of file reaction.h.

◆ m_logger

template<typename ReactionT>
quill::Logger* gridfire::reaction::TemplatedReactionSet< ReactionT >::m_logger = fourdst::logging::LogManager::getInstance().getLogger("log")
private

Definition at line 549 of file reaction.h.

◆ m_reactionNameMap

template<typename ReactionT>
std::unordered_map<std::string, ReactionT> gridfire::reaction::TemplatedReactionSet< ReactionT >::m_reactionNameMap
private

Maps reaction IDs to Reaction objects for quick lookup.

Definition at line 552 of file reaction.h.

◆ m_reactions

template<typename ReactionT>
std::vector<ReactionT> gridfire::reaction::TemplatedReactionSet< ReactionT >::m_reactions
private

Definition at line 550 of file reaction.h.


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