MARLEY (Model of Argon Reaction Low Energy Yields)  v1.2.0
A Monte Carlo event generator for tens-of-MeV neutrino interactions
Public Member Functions | Protected Attributes | List of all members
marley::Parity Class Reference

Type-safe representation of a parity value (either +1 or -1) More...

#include <Parity.hh>

Public Member Functions

constexpr Parity ()
 Default constructor chooses positive parity.
 
constexpr Parity (bool is_positive)
 Create a Parity object from a boolean value. More...
 
 Parity (int i)
 Create a Parity object from an integer. More...
 
void from_char (const char c)
 Assign a value to this Parity object from a char.
 
constexpr operator bool () const
 Convert the Parity object to a bool (true for +1, false for -1)
 
 operator int () const
 
Parityoperator! ()
 Unary operator that flips a Parity value in place.
 
bool operator!= (const marley::Parity &p) const
 
int operator* (const int &i) const
 
marley::Parity operator* (const marley::Parity &p) const
 
constexpr marley::Parity operator- () const
 Creates a copy of the Parity object with a flipped value.
 
marley::Parityoperator= (const int &i)
 Assigns a parity value using an integer. More...
 
bool operator== (const marley::Parity &p) const
 
char to_char () const
 Convert the Parity object to a char.
 

Protected Attributes

bool is_positive_
 Boolean representation of the parity value that is true when the parity is +1 and false when it is -1.
 

Detailed Description

Type-safe representation of a parity value (either +1 or -1)

Constructor & Destructor Documentation

◆ Parity() [1/2]

constexpr marley::Parity::Parity ( bool  is_positive)
inlineexplicitconstexpr

Create a Parity object from a boolean value.

Parameters
is_positiveBoolean parameter that is true for +1, or false for -1.

◆ Parity() [2/2]

marley::Parity::Parity ( int  i)
explicit

Create a Parity object from an integer.

If an int value other than +1 or -1 is passed to this constructor, a marley::Error will be thrown.

Member Function Documentation

◆ operator int()

marley::Parity::operator int ( ) const
inlineexplicit
Todo:
See comments for marley::TargetAtom::operator int(). A similar situation occurs for this function.

◆ operator=()

marley::Parity & marley::Parity::operator= ( const int &  i)

Assigns a parity value using an integer.

If an int value other than +1 or -1 is used, a marley::Error will be thrown.


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