/* -*- mode: c++; indent-tabs-mode: nil; -*-
 *
 * This file is part of the Mango recipe management distribution.
 * Copyright (c) 2000-2003, Roland Jesse
 * All rights reserved.
 *
 * For license and copyright information see the file COPYRIGHT or 
 * <http://www.opensource.org/licenses/bsd-license.html>.
 *
 * $Id: Menu.h,v 1.2 2003/05/11 14:47:35 rjesse Exp $
 */
 
#ifndef MENU_H
#define MENU_H

#include "AmbrosiaFingerprint.h"

#include <qmap.h>
#include <qvaluelist.h>

class Recipe;
class QString;

/*!
  \internal helper class.
*/
class MenuRecipe {
   public:
      void clear();
      
      QString recipeId() const { return m_recipeId.asString(); }
      void setRecipeId( const AmbrosiaFingerprint& af) { m_recipeId = af; }
      void setRecipeId( const QString& s) { m_recipeId = s; }
      QString title() const { return m_title; }
      void setTitle( const QString& s) { m_title = s; }
      int amount() const { return m_amount; }
      void setAmount( const int a) { m_amount = a; }
      int persons() const { return m_persons; }
      void setPersons( const int p) { m_persons = p; }
      QString description() const { return m_description; }
      void setDescription( const QString& s) { m_description = s; }

   private:
      AmbrosiaFingerprint m_recipeId; //!< References a recipe.
      QString m_title;            //!< recipe's title in case the id is invalid.
      int m_amount;
      int m_persons;
      QString m_description;
};

/*!
  The Menu class defines menues by referencing recipes. It does not
  store recipes by itself but only recipe IDs that point to entries
  in the corresponding cookbook.

  A menu is always part of a specific cookbook and should only contain
  recipes that are stored in this cookbook as well.
*/
class Menu {
   public:
      typedef QValueList<MenuRecipe> MenuRecipes;
      typedef QMap<QString,QString> CustomData;

      Menu();
      Menu( const Menu&);
      void clear();
      
      QString title() const;
      void setTitle( const QString&);
      void addRecipe( const Recipe&);
      void addMenuRecipe( const MenuRecipe&);
      MenuRecipes getRecipes() const;

      CustomData getCustomData() const;
      void setCustomData( const CustomData&);
      void addCustomData( const QString&, const QString&);

   private:
      QString m_title;          //!< Menu's title.
      MenuRecipes m_recipes; //!< Menu's recipes.
      CustomData m_customData; //!< Mainly for CookML support.
};

/*****************************************************************************
  Menu stream functions
 *****************************************************************************/
QDataStream& operator<<( QDataStream&, const Menu&);
QDataStream& operator>>( QDataStream&, Menu&);
#endif // MENU_H
