Skip to content

Commit

Permalink
Fixed missing stdexcept include in SOMcomponent.cpp and moved
Browse files Browse the repository at this point in the history
some definitions to SOMcomponent.cpp
  • Loading branch information
philippkraft committed Sep 4, 2018
1 parent 0b5a6d0 commit 1f2921f
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 109 deletions.
26 changes: 26 additions & 0 deletions decomp/SOMcomponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "SOMcomponent.h"
#include <cmath>
#include <stdexcept>


double SOMcomponent::decomp( double T, double wetness, double pH) const
Expand Down Expand Up @@ -67,6 +68,31 @@
}
return res;
}
void SOMcomponent::set_product(const SOMcomponent& product,double fraction) {
if (fraction<0 || fraction>1) throw std::runtime_error("Fraction is a number in [0..1]");
products[product]=fraction;
}
SOMcomponent::SOMcomponent() : Id(-1)
{
throw std::runtime_error("Never use standard ctor for SOMcomponent");
}

SOMcomponent& SOMcomponent::operator=(const SOMcomponent& copy)
{
if (Id!=copy.Id)
{
throw std::runtime_error("Tried to assign an SOMcomponent to another with an differing IDs");
}
products=copy.products;
E_a=copy.E_a;
k_pot=copy.k_pot;
K_w=copy.K_w;
n_w=copy.n_w;
K_pH=copy.K_pH;
m_pH=copy.m_pH;
Name=copy.Name;
return *this;
}

int SOMcomponent::count(0);

Expand Down
30 changes: 5 additions & 25 deletions decomp/SOMcomponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ class SOMcomponent {


/// Set the fraction of a product
void set_product(const SOMcomponent& product,double fraction) {
if (fraction<0 || fraction>1) throw std::runtime_error("Fraction is a number in [0..1]");
products[product]=fraction;
}
void set_product(const SOMcomponent& product,double fraction);
/// Get the fraction of a product
double get_product_fraction(const SOMcomponent& product) const {
product_map::const_iterator fract=products.find(product);
Expand All @@ -70,31 +67,14 @@ class SOMcomponent {
component_set get_products() const;
/// Calculates the decomposition rate in 1/day of this component
double decomp(double T, double wetness, double pH) const;
SOMcomponent() : Id(-1)
{
throw std::runtime_error("Never use standard ctor for SOMcomponent");
}
SOMcomponent();
bool operator<(const SOMcomponent& cmp) const { return Id<cmp.Id;}
bool operator==(const SOMcomponent& cmp) { return Id==cmp.Id;}
bool operator!=(const SOMcomponent& cmp) { return Id!=cmp.Id;}

#ifndef SWIG
SOMcomponent& operator=(const SOMcomponent& copy)
{
if (Id!=copy.Id)
{
throw std::runtime_error("Tried to assign an SOMcomponent to another with an differing IDs");
}
products=copy.products;
E_a=copy.E_a;
k_pot=copy.k_pot;
K_w=copy.K_w;
n_w=copy.n_w;
K_pH=copy.K_pH;
m_pH=copy.m_pH;
Name=copy.Name;
return *this;
}
#endif
SOMcomponent& operator=(const SOMcomponent& copy);
#endif
/// Copy constructor
SOMcomponent(const SOMcomponent& copy);
~SOMcomponent();
Expand Down
Loading

0 comments on commit 1f2921f

Please sign in to comment.