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 ()
| 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)

## Constructor & Destructor Documentation

## TemplatedReactionSet() [1/3]

template<typename ReactionT>

gridfire::reaction::TemplatedReactionSet< ReactionT >::TemplatedReactionSet | ( | std::vector< ReactionT > | reactions | ) |

explicit

Constructs a ReactionSet from a vector of reactions.

Parameters

  reactions | The initial vector of Reaction objects.

## TemplatedReactionSet() [2/3]

template<typename ReactionT>

gridfire::reaction::TemplatedReactionSet< ReactionT >::TemplatedReactionSet | ( |  | ) |

## TemplatedReactionSet() [3/3]

template<typename ReactionT>

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

Copy constructor.

Parameters

  other | The ReactionSet to copy.

## Member Function Documentation

## add_reaction()

template<typename ReactionT>

void gridfire::reaction::TemplatedReactionSet< ReactionT >::add_reaction | ( | ReactionT | reaction | ) |

Adds a reaction to the set.

Parameters

  reaction | The Reaction to add.

## begin() [1/2]

template<typename ReactionT>

auto gridfire::reaction::TemplatedReactionSet< ReactionT >::begin | ( |  | ) |

inline

## begin() [2/2]

template<typename ReactionT>

auto gridfire::reaction::TemplatedReactionSet< ReactionT >::begin | ( |  | ) | const

inlinenodiscard

## clear()

template<typename ReactionT>

void gridfire::reaction::TemplatedReactionSet< ReactionT >::clear | ( |  | ) |

Removes all reactions from the set.

## 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

  reaction | The Reaction to find.

Returns
  True if the reaction is in the set, false otherwise.

## 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

  id | The ID of the reaction to find.

Returns
  True if the reaction is in the set, false otherwise.

## 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

  species | The species to check for.

Returns
  True if the species is a product in any reaction.

## 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

  species | The species to check for.

Returns
  True if the species is a reactant in any reaction.

## 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

  species | The species to check for.

Returns
  True if the species is involved in any reaction.

## end() [1/2]

template<typename ReactionT>

auto gridfire::reaction::TemplatedReactionSet< ReactionT >::end | ( |  | ) |

inline

## end() [2/2]

template<typename ReactionT>

auto gridfire::reaction::TemplatedReactionSet< ReactionT >::end | ( |  | ) | const

inlinenodiscard

## getReactionSetSpecies()

template<typename ReactionT>

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

nodiscard

## 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

  seed | The 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!=()

template<typename ReactionT>

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

Compares this set with another for inequality.

Parameters

  other | The other ReactionSet to compare with.

Returns
  True if the sets are not equal.

## operator=()

template<typename ReactionT>

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

Copy assignment operator.

Parameters

  other | The ReactionSet to assign from.

Returns
  A reference to this ReactionSet.

## operator==()

template<typename ReactionT>

bool gridfire::reaction::TemplatedReactionSet< ReactionT >::operator== | ( | const TemplatedReactionSet< ReactionT > & | other | ) | const

Compares this set with another for equality.

Parameters

  other | The other ReactionSet to compare with.

Returns
  True if the sets are equal (same size and hash).

## 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

  id | The ID of the reaction to access.

Returns
  A const reference to the Reaction.

Exceptions

  std::out_of_range | if no reaction with the given ID exists.

## 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

  index | The index of the reaction to access.

Returns
  A const reference to the Reaction.

Exceptions

  std::out_of_range | if the index is out of bounds.

## remove_reaction()

template<typename ReactionT>

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

Removes a reaction from the set.

Parameters

  reaction | The Reaction to remove.

## 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.

## Friends And Related Symbol Documentation

## operator<<

template<typename ReactionT>

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

friend

## Member Data Documentation

## m_id

template<typename ReactionT>

std::string gridfire::reaction::TemplatedReactionSet< ReactionT >::m_id

private

## m_logger

template<typename ReactionT>

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

private

## 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.

## m_reactions

template<typename ReactionT>

std::vector<ReactionT> gridfire::reaction::TemplatedReactionSet< ReactionT >::m_reactions

private

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

- src/include/gridfire/reaction/reaction.h