Skip to content

Commit

Permalink
More corrections and tidy-up
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Young committed Sep 24, 2024
1 parent de9faa1 commit 449b9b1
Show file tree
Hide file tree
Showing 35 changed files with 277 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2526,7 +2526,7 @@ void MainWindow::newRecipe()
return;
}
ObjectStoreWrapper::insert(newRec);
std::shared_ptr<Boil> newBoil = std::make_shared<Boil>(QString("Boil for").arg(name));
std::shared_ptr<Boil> newBoil = std::make_shared<Boil>(QString("Boil for %1").arg(name));
newRec->setBoil(newBoil);
ObjectStoreWrapper::insert(newBoil);

Expand Down
13 changes: 8 additions & 5 deletions src/model/Boil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,23 @@ Boil::Boil(QString name) :
m_description {"" },
m_notes {"" },
m_preBoilSize_l{std::nullopt} {

CONSTRUCTOR_END
return;
}

Boil::Boil(NamedParameterBundle const & namedParameterBundle) :
NamedEntity {namedParameterBundle},
NamedEntity {namedParameterBundle},
FolderBase<Boil>{namedParameterBundle},
StepOwnerBase<Boil, BoilStep>{},
SET_REGULAR_FROM_NPB (m_description , namedParameterBundle, PropertyNames::Boil::description ),
SET_REGULAR_FROM_NPB (m_notes , namedParameterBundle, PropertyNames::Boil::notes ),
SET_REGULAR_FROM_NPB (m_preBoilSize_l, namedParameterBundle, PropertyNames::Boil::preBoilSize_l) {

// If we're being constructed from a BeerXML file, we use the property boilTime_mins for RECIPE > BOIL_TIME
if (namedParameterBundle.contains(PropertyNames::Boil::boilTime_mins)) {
double boilTime_mins{namedParameterBundle.val<double>(PropertyNames::Boil::boilTime_mins)};
this->setBoilTime_mins(boilTime_mins);
}
SET_IF_PRESENT_FROM_NPB_NO_MV(Boil::setBoilTime_mins, namedParameterBundle, PropertyNames::Boil::boilTime_mins);

CONSTRUCTOR_END
return;
}

Expand All @@ -93,6 +94,8 @@ Boil::Boil(Boil const & other) :
m_description {other.m_description },
m_notes {other.m_notes },
m_preBoilSize_l{other.m_preBoilSize_l} {

CONSTRUCTOR_END
return;
}

Expand Down
6 changes: 6 additions & 0 deletions src/model/BoilStep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ static_assert(std::is_base_of<StepExtended, BoilStep>::value);
BoilStep::BoilStep(QString name) :
StepExtended {name },
m_chillingType{std::nullopt} {

CONSTRUCTOR_END
return;
}

Expand All @@ -67,12 +69,16 @@ BoilStep::BoilStep(NamedParameterBundle const & namedParameterBundle) :
// always be because it's optional) then it is supported by this class. In other words, either it's not there, or
// (if it is then) it's supported.
Q_ASSERT(!namedParameterBundle.contains(PropertyNames::Step::rampTime_mins) || this->rampTimeIsSupported());

CONSTRUCTOR_END
return;
}

BoilStep::BoilStep(BoilStep const & other) :
StepExtended {other },
m_chillingType{other.m_chillingType} {

CONSTRUCTOR_END
return;
}

Expand Down
10 changes: 10 additions & 0 deletions src/model/BrewNote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,16 @@ TypeLookup const BrewNote::typeLookup {
// Initializers
BrewNote::BrewNote(QString name) :
BrewNote(QDate(), name) {

CONSTRUCTOR_END
return;
}

BrewNote::BrewNote(Recipe const & recipe) :
BrewNote(QDate(), "") {
this->m_recipeId = recipe.key();

CONSTRUCTOR_END
return;
}

Expand Down Expand Up @@ -142,6 +146,8 @@ BrewNote::BrewNote(QDate dateNow, QString const & name) :
m_projPoints {0.0 },
m_projFermPoints {0.0 },
m_projAtten {0.0 } {

CONSTRUCTOR_END
return;
}

Expand Down Expand Up @@ -178,6 +184,8 @@ BrewNote::BrewNote(NamedParameterBundle const & namedParameterBundle) :
SET_REGULAR_FROM_NPB (m_projPoints , namedParameterBundle, PropertyNames::BrewNote::projPoints ),
SET_REGULAR_FROM_NPB (m_projFermPoints , namedParameterBundle, PropertyNames::BrewNote::projFermPoints ),
SET_REGULAR_FROM_NPB (m_projAtten , namedParameterBundle, PropertyNames::BrewNote::projAtten ) {

CONSTRUCTOR_END
return;
}

Expand Down Expand Up @@ -213,6 +221,8 @@ BrewNote::BrewNote(BrewNote const & other) :
m_projPoints {other.m_projPoints },
m_projFermPoints {other.m_projFermPoints },
m_projAtten {other.m_projAtten } {

CONSTRUCTOR_END
return;
}

Expand Down
6 changes: 6 additions & 0 deletions src/model/Equipment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ Equipment::Equipment(QString name) :
m_fermenterNotes {"" },
m_agingVesselNotes {"" },
m_packagingVesselNotes {"" } {

CONSTRUCTOR_END
return;
}

Expand Down Expand Up @@ -236,6 +238,8 @@ Equipment::Equipment(NamedParameterBundle const & namedParameterBundle) :
SET_REGULAR_FROM_NPB (m_fermenterNotes , namedParameterBundle, PropertyNames::Equipment::fermenterNotes , "" ),
SET_REGULAR_FROM_NPB (m_agingVesselNotes , namedParameterBundle, PropertyNames::Equipment::agingVesselNotes , "" ),
SET_REGULAR_FROM_NPB (m_packagingVesselNotes , namedParameterBundle, PropertyNames::Equipment::packagingVesselNotes , "" ) {

CONSTRUCTOR_END
return;
}

Expand Down Expand Up @@ -291,6 +295,8 @@ Equipment::Equipment(Equipment const & other) :
m_fermenterNotes {other.m_fermenterNotes },
m_agingVesselNotes {other.m_agingVesselNotes },
m_packagingVesselNotes {other.m_packagingVesselNotes } {

CONSTRUCTOR_END
return;
}

Expand Down
5 changes: 5 additions & 0 deletions src/model/Fermentable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ Fermentable::Fermentable(QString name) :
m_fan_ppm {std::nullopt },
m_fermentability_pct {std::nullopt },
m_betaGlucan_ppm {std::nullopt } {

CONSTRUCTOR_END
return;
}

Expand Down Expand Up @@ -263,6 +265,7 @@ Fermentable::Fermentable(NamedParameterBundle const & namedParameterBundle) :
SET_REGULAR_FROM_NPB (m_fermentability_pct , namedParameterBundle, PropertyNames::Fermentable::fermentability_pct , std::nullopt),
SET_REGULAR_FROM_NPB (m_betaGlucan_ppm , namedParameterBundle, PropertyNames::Fermentable::betaGlucan_ppm , std::nullopt) {

CONSTRUCTOR_END
return;
}

Expand Down Expand Up @@ -301,6 +304,8 @@ Fermentable::Fermentable(Fermentable const & other) :
m_fan_ppm {other.m_fan_ppm },
m_fermentability_pct {other.m_fermentability_pct },
m_betaGlucan_ppm {other.m_betaGlucan_ppm } {

CONSTRUCTOR_END
return;
}

Expand Down
12 changes: 9 additions & 3 deletions src/model/Fermentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,19 @@ Fermentation::Fermentation(QString name) :
StepOwnerBase<Fermentation, FermentationStep>{},
m_description {"" },
m_notes {"" } {

CONSTRUCTOR_END
return;
}

Fermentation::Fermentation(NamedParameterBundle const & namedParameterBundle) :
NamedEntity {namedParameterBundle},
NamedEntity {namedParameterBundle},
FolderBase<Fermentation>{namedParameterBundle},
StepOwnerBase<Fermentation, FermentationStep>{},
SET_REGULAR_FROM_NPB (m_description , namedParameterBundle, PropertyNames::Fermentation::description ),
SET_REGULAR_FROM_NPB (m_notes , namedParameterBundle, PropertyNames::Fermentation::notes ) {
SET_REGULAR_FROM_NPB (m_description, namedParameterBundle, PropertyNames::Fermentation::description),
SET_REGULAR_FROM_NPB (m_notes , namedParameterBundle, PropertyNames::Fermentation::notes ) {

CONSTRUCTOR_END
return;
}

Expand All @@ -79,6 +83,8 @@ Fermentation::Fermentation(Fermentation const & other) :
StepOwnerBase<Fermentation, FermentationStep>{other},
m_description {other.m_description },
m_notes {other.m_notes } {

CONSTRUCTOR_END
return;
}

Expand Down
6 changes: 6 additions & 0 deletions src/model/FermentationStep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ FermentationStep::FermentationStep(QString name) :
StepExtended{name},
m_freeRise {std::nullopt},
m_vessel {""} {

CONSTRUCTOR_END
return;
}

Expand All @@ -58,13 +60,17 @@ FermentationStep::FermentationStep(NamedParameterBundle const & namedParameterBu
SET_REGULAR_FROM_NPB (m_vessel , namedParameterBundle, PropertyNames::FermentationStep::vessel , QString() ) {
// See comment in Step constructor
Q_ASSERT(this->rampTimeIsSupported() == namedParameterBundle.contains(PropertyNames::Step::rampTime_mins));

CONSTRUCTOR_END
return;
}

FermentationStep::FermentationStep(FermentationStep const & other) :
StepExtended{other },
m_freeRise {other.m_freeRise},
m_vessel {other.m_vessel } {

CONSTRUCTOR_END
return;
}

Expand Down
6 changes: 6 additions & 0 deletions src/model/Hop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ Hop::Hop(QString name) :
m_producer {"" },
m_productId {"" },
m_year {"" } {

CONSTRUCTOR_END
return;
}

Expand Down Expand Up @@ -220,6 +222,8 @@ Hop::Hop(NamedParameterBundle const & namedParameterBundle) :
SET_REGULAR_FROM_NPB (m_producer , namedParameterBundle, PropertyNames::Hop::producer , "" ),
SET_REGULAR_FROM_NPB (m_productId , namedParameterBundle, PropertyNames::Hop::productId , "" ),
SET_REGULAR_FROM_NPB (m_year , namedParameterBundle, PropertyNames::Hop::year , "" ) {

CONSTRUCTOR_END
return;
}

Expand Down Expand Up @@ -251,6 +255,8 @@ Hop::Hop(Hop const & other) :
m_producer {other.m_producer },
m_productId {other.m_productId },
m_year {other.m_year } {

CONSTRUCTOR_END
return;
}

Expand Down
6 changes: 6 additions & 0 deletions src/model/Ingredient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,24 @@ static_assert(std::is_base_of<FolderBase<Ingredient>, Ingredient>::value);
Ingredient::Ingredient(QString name) :
OutlineableNamedEntity{name},
FolderBase<Ingredient>{} {

CONSTRUCTOR_END
return;
}

Ingredient::Ingredient(NamedParameterBundle const & namedParameterBundle) :
OutlineableNamedEntity{namedParameterBundle},
FolderBase<Ingredient>{namedParameterBundle} {

CONSTRUCTOR_END
return;
}

Ingredient::Ingredient(Ingredient const & other) :
OutlineableNamedEntity{other},
FolderBase<Ingredient>{other} {

CONSTRUCTOR_END
return;
}

Expand Down
6 changes: 6 additions & 0 deletions src/model/IngredientInRecipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,25 @@ TypeLookup const IngredientInRecipe::typeLookup {
IngredientInRecipe::IngredientInRecipe(QString name, int const recipeId, int const ingredientId) :
OwnedByRecipe{name, recipeId},
m_ingredientId{ingredientId} {

CONSTRUCTOR_END
return;
}

IngredientInRecipe::IngredientInRecipe(NamedParameterBundle const & namedParameterBundle) :
OwnedByRecipe{namedParameterBundle},
// Although ingredientId is required, we have to supply a default value for when we are reading from BeerXML or BeerJSON
SET_REGULAR_FROM_NPB(m_ingredientId, namedParameterBundle, PropertyNames::IngredientInRecipe::ingredientId, -1) {

CONSTRUCTOR_END
return;
}

IngredientInRecipe::IngredientInRecipe(IngredientInRecipe const & other) :
OwnedByRecipe{other},
m_ingredientId{other.m_ingredientId} {

CONSTRUCTOR_END
return;
}

Expand Down
6 changes: 6 additions & 0 deletions src/model/Instruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ Instruction::Instruction(QString name) :
m_timerValue(""),
m_completed (false),
m_interval (0.0) {

CONSTRUCTOR_END
return;
}

Expand All @@ -115,6 +117,8 @@ Instruction::Instruction(NamedParameterBundle const & namedParameterBundle) :
SET_REGULAR_FROM_NPB (m_timerValue, namedParameterBundle, PropertyNames::Instruction::timerValue),
SET_REGULAR_FROM_NPB (m_completed , namedParameterBundle, PropertyNames::Instruction::completed ),
SET_REGULAR_FROM_NPB (m_interval , namedParameterBundle, PropertyNames::Instruction::interval ) {

CONSTRUCTOR_END
return;
}

Expand All @@ -126,6 +130,8 @@ Instruction::Instruction(Instruction const & other) :
m_timerValue{other.m_timerValue},
m_completed {other.m_completed },
m_interval {other.m_interval } {

CONSTRUCTOR_END
return;
}

Expand Down
6 changes: 6 additions & 0 deletions src/model/Inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,24 @@ TypeLookup const Inventory::typeLookup {
Inventory::Inventory() :
NamedEntity{""},
m_ingredientId{-1} {

CONSTRUCTOR_END
return;
}

Inventory::Inventory(NamedParameterBundle const & namedParameterBundle) :
NamedEntity{namedParameterBundle},
SET_REGULAR_FROM_NPB (m_ingredientId, namedParameterBundle, PropertyNames::Inventory::ingredientId) {

CONSTRUCTOR_END
return;
}

Inventory::Inventory(Inventory const & other) :
NamedEntity {other },
m_ingredientId{other.m_ingredientId} {

CONSTRUCTOR_END
return;
}

Expand Down
6 changes: 6 additions & 0 deletions src/model/Mash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ Mash::Mash(QString name) :
m_mashTunWeight_kg {0.0 },
m_mashTunSpecificHeat_calGC{0.0 },
m_equipAdjust {true} {

CONSTRUCTOR_END
return;
}

Expand All @@ -102,6 +104,8 @@ Mash::Mash(NamedParameterBundle const & namedParameterBundle) :
SET_REGULAR_FROM_NPB (m_mashTunWeight_kg , namedParameterBundle, PropertyNames::Mash::mashTunWeight_kg ),
SET_REGULAR_FROM_NPB (m_mashTunSpecificHeat_calGC, namedParameterBundle, PropertyNames::Mash::mashTunSpecificHeat_calGC),
SET_REGULAR_FROM_NPB (m_equipAdjust , namedParameterBundle, PropertyNames::Mash::equipAdjust ) {

CONSTRUCTOR_END
return;
}

Expand All @@ -117,6 +121,8 @@ Mash::Mash(Mash const & other) :
m_mashTunWeight_kg {other.m_mashTunWeight_kg },
m_mashTunSpecificHeat_calGC{other.m_mashTunSpecificHeat_calGC},
m_equipAdjust {other.m_equipAdjust } {

CONSTRUCTOR_END
return;
}

Expand Down
Loading

0 comments on commit 449b9b1

Please sign in to comment.