Loading...
Searching...
No Matches
gridfire::policy::MultiReactionChainPolicy Class Reference

A ReactionChainPolicy composed of multiple child ReactionChainPolicy instances. More...

`#include <policy_logical.h>`

Inheritance diagram for gridfire::policy::MultiReactionChainPolicy:
[legend]
Collaboration diagram for gridfire::policy::MultiReactionChainPolicy:
[legend]

## Public Member Functions

| MultiReactionChainPolicy (std::vector< std::unique_ptr< ReactionChainPolicy > > &&chain_policies)
| Constructs a MultiReactionChainPolicy from a vector of ReactionChainPolicy instances.
const std::vector< std::unique_ptr< ReactionChainPolicy > > & | get_chain_policies () const
| Returns the vector of child ReactionChainPolicy instances.
const reaction::ReactionSet & | get_reactions () const override
| Returns the combined ReactionSet of all child chain policies.
bool | contains (const std::string &id) const override
| Checks if the MultiReactionChainPolicy contains a reaction by ID.
bool | contains (const reaction::Reaction &reaction) const override
| Checks if the MultiReactionChainPolicy contains a specific reaction.
std::unique_ptr< ReactionChainPolicy > | clone () const override
| Creates a deep copy of the MultiReactionChainPolicy.
std::string | name () const override
| Returns the name of the MultiReactionChainPolicy.
uint64_t | hash (uint64_t seed) const override
| Computes a hash value for the MultiReactionChainPolicy.
bool | operator== (const ReactionChainPolicy &other) const override
| Equality comparison operator.
bool | operator!= (const ReactionChainPolicy &other) const override
| Inequality comparison operator.
size_t | size () const
| Returns the number of child ReactionChainPolicy instances.
auto | begin ()
| Returns iterator to the beginning of the child ReactionChainPolicy instances.
auto | begin () const
| Returns const iterator to the beginning of the child ReactionChainPolicy instances.
auto | end ()
| Returns iterator to the end of the child ReactionChainPolicy instances.
auto | end () const
| Returns const iterator to the end of the child ReactionChainPolicy instances.
Public Member Functions inherited from gridfire::policy::ReactionChainPolicy
virtual | ~ReactionChainPolicy ()=default

## Protected Attributes

std::vector< std::unique_ptr< ReactionChainPolicy > > | m_chain_policies {}
| Child chain policies.
reaction::ReactionSet | m_reactions
| Combined reactions from all child policies.

## Detailed Description

A ReactionChainPolicy composed of multiple child ReactionChainPolicy instances.

Useful for policies that represent a union of several reaction chains (for example the `LowMassMainSequenceReactionChainPolicy` composes the proton-proton and CNO chains).

Example
  LowMassMainSequenceReactionChainPolicy multi;
  const auto &chains = multi.get_chain_policies();
  for (const auto &ch : chains) { std::cout << ch->get_reactions().size() << " reactions\n"; }

## Constructor & Destructor Documentation

## MultiReactionChainPolicy()

gridfire::policy::MultiReactionChainPolicy::MultiReactionChainPolicy | ( | std::vector< std::unique_ptr< ReactionChainPolicy > > && | chain_policies | ) |

explicit

Constructs a MultiReactionChainPolicy from a vector of ReactionChainPolicy instances.

The provided chain policies are moved into the new MultiReactionChainPolicy instance.

Parameters

  chain_policies | vector of unique_ptr to ReactionChainPolicy instances.

Example
  std::vector<std::unique_ptr<ReactionChainPolicy>> chains;
  chains.push_back(std::make_unique<ProtonProtonChainPolicy>());
  chains.push_back(std::make_unique<CNOChainPolicy>());
  MultiReactionChainPolicy multi(std::move(chains));
  gridfire::policy::MultiReactionChainPolicy
  A ReactionChainPolicy composed of multiple child ReactionChainPolicy instances.
  Definition policy_logical.h:23

## Member Function Documentation

## begin() [1/2]

auto gridfire::policy::MultiReactionChainPolicy::begin | ( |  | ) |

inline

Returns iterator to the beginning of the child ReactionChainPolicy instances.

Returns
  iterator to the beginning.

Example
  for (auto it = multi.begin(); it != multi.end(); ++it) {
  std::cout << (*it)->name() << std::endl;
  }

## begin() [2/2]

auto gridfire::policy::MultiReactionChainPolicy::begin | ( |  | ) | const

inline

Returns const iterator to the beginning of the child ReactionChainPolicy instances.

Returns
  const iterator to the beginning.

Example
  for (auto it = multi.begin(); it != multi.end(); ++it) {
  std::cout << (*it)->name() << std::endl;
  }

## clone()

std::unique_ptr< ReactionChainPolicy > gridfire::policy::MultiReactionChainPolicy::clone | ( |  | ) | const

overridevirtual

Creates a deep copy of the MultiReactionChainPolicy.

Returns
  std::unique_ptr<ReactionChainPolicy> unique pointer to the cloned instance.

Example
  std::unique_ptr<ReactionChainPolicy> clone = multi.clone();
  gridfire::policy::MultiReactionChainPolicy::clone
  std::unique_ptr< ReactionChainPolicy > clone() const override
  Creates a deep copy of the MultiReactionChainPolicy.
  Definition policy_logical.cpp:32

Implements gridfire::policy::ReactionChainPolicy.

## contains() [1/2]

bool gridfire::policy::MultiReactionChainPolicy::contains | ( | const reaction::Reaction & | reaction | ) | const

overridevirtual

Checks if the MultiReactionChainPolicy contains a specific reaction.

Parameters

  reaction | the Reaction to check for.

Returns
  true if the reaction is present in the combined ReactionSet, false otherwise.

Example
  reaction::Reaction r = ...; // obtain a Reaction instance
  bool has_reaction = multi.contains(r);
  gridfire::reaction::Reaction
  Represents a single nuclear reaction from a specific data source.
  Definition reaction.h:98

Implements gridfire::policy::ReactionChainPolicy.

## contains() [2/2]

bool gridfire::policy::MultiReactionChainPolicy::contains | ( | const std::string & | id | ) | const

overridevirtual

Checks if the MultiReactionChainPolicy contains a reaction by ID.

Parameters

  id | the reaction ID to check for.

Returns
  true if the reaction ID is present in the combined ReactionSet, false otherwise.

Example
  bool has_pp = multi.contains("p(p,e+)d");

Implements gridfire::policy::ReactionChainPolicy.

## end() [1/2]

auto gridfire::policy::MultiReactionChainPolicy::end | ( |  | ) |

inline

Returns iterator to the end of the child ReactionChainPolicy instances.

Returns
  iterator to the end.

Example
  for (auto it = multi.begin(); it != multi.end(); ++it) {
  std::cout << (*it)->name() << std::endl;
  }

## end() [2/2]

auto gridfire::policy::MultiReactionChainPolicy::end | ( |  | ) | const

inline

Returns const iterator to the end of the child ReactionChainPolicy instances.

Returns
  const iterator to the end.

Example
  for (auto it = multi.begin(); it != multi.end(); ++it) {
  std::cout << (*it)->name() << std::endl;
  }

## get_chain_policies()

const std::vector< std::unique_ptr< ReactionChainPolicy > > & gridfire::policy::MultiReactionChainPolicy::get_chain_policies | ( |  | ) | const

Returns the vector of child ReactionChainPolicy instances.

Returns
  const std::vector<std::unique_ptr<ReactionChainPolicy>>& reference to the child chain policies.

Example
  const auto &chains = multi.get_chain_policies();
  for (const auto &ch : chains) { std::cout << ch->get_reactions().size() << " reactions\n"; }

## get_reactions()

const reaction::ReactionSet & gridfire::policy::MultiReactionChainPolicy::get_reactions | ( |  | ) | const

overridevirtual

Returns the combined ReactionSet of all child chain policies.

Returns
  const reaction::ReactionSet& reference to the combined reactions.

Example
  const auto &reactions = multi.get_reactions();
  std::cout << "Multi chain contains " << reactions.size() << " reactions\n";

Implements gridfire::policy::ReactionChainPolicy.

## hash()

uint64_t gridfire::policy::MultiReactionChainPolicy::hash | ( | uint64_t | seed | ) | const

overridevirtual

Computes a hash value for the MultiReactionChainPolicy.

Parameters

  seed | the seed value for the hash computation.

Returns
  uint64_t the computed hash value.

Example
  uint64_t h = multi.hash(0);
  std::cout << "Policy hash: " << h << std::endl;

Implements gridfire::policy::ReactionChainPolicy.

## name()

std::string gridfire::policy::MultiReactionChainPolicy::name | ( |  | ) | const

overridevirtual

Returns the name of the MultiReactionChainPolicy.

Returns
  std::string the name of the policy.

Example
  std::string n = multi.name();
  std::cout << "Using policy: " << n << std::endl;

Implements gridfire::policy::ReactionChainPolicy.

Reimplemented in gridfire::policy::ProtonProtonChainPolicy.

## operator!=()

bool gridfire::policy::MultiReactionChainPolicy::operator!= | ( | const ReactionChainPolicy & | other | ) | const

overridevirtual

Inequality comparison operator.

Parameters

  other | the other ReactionChainPolicy to compare against.

Returns
  true if the policies are not equal, false otherwise.

Example
  bool not_equal = (multi1 != multi2);

Implements gridfire::policy::ReactionChainPolicy.

## operator==()

bool gridfire::policy::MultiReactionChainPolicy::operator== | ( | const ReactionChainPolicy & | other | ) | const

overridevirtual

Equality comparison operator.

Parameters

  other | the other ReactionChainPolicy to compare against.

Returns
  true if the policies are equal, false otherwise.

Example
  bool equal = (multi1 == multi2);

Implements gridfire::policy::ReactionChainPolicy.

## size()

size_t gridfire::policy::MultiReactionChainPolicy::size | ( |  | ) | const

Returns the number of child ReactionChainPolicy instances.

Returns
  size_t the number of child chain policies.

Example
  size_t n = multi.size();
  std::cout << "Multi chain has " << n << " child policies\n";

## Member Data Documentation

## m_chain_policies

std::vector<std::unique_ptr<ReactionChainPolicy> > gridfire::policy::MultiReactionChainPolicy::m_chain_policies {}

protected

Child chain policies.

## m_reactions

reaction::ReactionSet gridfire::policy::MultiReactionChainPolicy::m_reactions

protected

Combined reactions from all child policies.

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

- src/include/gridfire/policy/policy_logical.h
- src/lib/policy/policy_logical.cpp