2018-03-01 16:19:13 +00:00
|
|
|
#ifndef RECIPEDATABASE_H
|
|
|
|
#define RECIPEDATABASE_H
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "database.h"
|
2018-03-01 16:28:18 +00:00
|
|
|
#include "model/recipe/recipe.h"
|
2018-03-02 13:14:56 +00:00
|
|
|
#include "utils/fileutils.h"
|
2018-03-01 16:19:13 +00:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief The RecipeDatabase class represents the precise database used for the recipe storage, and is specialized.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class RecipeDatabase : public Database
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RecipeDatabase(string filename);
|
2018-03-01 16:28:18 +00:00
|
|
|
|
|
|
|
//Stores a full recipe in the database.
|
2018-03-02 13:14:56 +00:00
|
|
|
bool storeRecipe(Recipe recipe);
|
2018-03-02 08:32:40 +00:00
|
|
|
|
|
|
|
//SQL Helper methods.
|
2018-03-10 07:51:17 +00:00
|
|
|
//Storage.
|
2018-03-02 13:14:56 +00:00
|
|
|
bool storeRecipeIngredient(RecipeIngredient ri, int recipeId);
|
2018-03-10 07:51:17 +00:00
|
|
|
int storeIngredient(Ingredient ingredient);
|
|
|
|
bool storeUnitOfMeasure(UnitOfMeasure u);
|
2018-03-02 13:14:56 +00:00
|
|
|
bool storeInstruction(Instruction instruction, int recipeId);
|
|
|
|
bool storeImage(QImage image, int recipeId);
|
2018-03-03 09:18:38 +00:00
|
|
|
bool storeTags(vector<RecipeTag> tags, int recipeId);
|
2018-03-03 07:38:32 +00:00
|
|
|
|
2018-03-10 07:51:17 +00:00
|
|
|
//Retrieval.
|
2018-03-03 07:48:55 +00:00
|
|
|
Recipe retrieveRecipe(string name);
|
2018-03-03 09:18:38 +00:00
|
|
|
vector<RecipeIngredient> retrieveRecipeIngredients(int recipeId);
|
2018-03-10 07:51:17 +00:00
|
|
|
vector<Ingredient> retrieveAllIngredients();
|
|
|
|
vector<UnitOfMeasure> retrieveAllUnitsOfMeasure();
|
2018-03-10 11:36:14 +00:00
|
|
|
vector<RecipeTag> retrieveTags(int recipeId);
|
|
|
|
vector<RecipeTag> retrieveAllTags();
|
2018-03-01 16:19:13 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
//Utility methods.
|
|
|
|
void ensureTablesExist();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // RECIPEDATABASE_H
|