class Ingredient
{
public:
Ingredient(std::string name); //obvious implementation
virtual ~Ingredient(void);
friend std::ostream& operator<<(std::ostream& stream, Ingredient ingredient);
private:
std::string name_;
};
std::ostream& operator<<(std::ostream& stream, Ingredient ingredient)
{
stream << ingredient.name_;
return stream;
}
class IngredientManager
{
public:
// Init and DeInit functions
IngredientManager(void);
~IngredientManager(void);
// Utility functions
void SaveIngredients();
void AddNewIngredient(std::string name);
private:
typedef std::list<Ingredient> listType;
listType ingredientList_;
};
void IngredientManager::AddNewIngredient(std::string name)
{
ingredientList_.push_back(Ingredient(name));
}
void IngredientManager::SaveIngredients()
{
std::ofstream fileOut("./DataStore/Ingredients.txt");
std::copy(ingredientList_.begin(),
ingredientList_.end(),
std::ostream_iterator<Ingredient>(fileOut, " "));
fileOut.close();
}