Design Pattern Examples
Overview of object-oriented design patterns
Visitor_PickleGrocer Class Reference

Represent a pickle grocer. More...

#include <Visitor_Element_Classes.h>

Inheritance diagram for Visitor_PickleGrocer:
Inheritance graph
Collaboration diagram for Visitor_PickleGrocer:
Collaboration graph

Private Member Functions

void Accept (Visitor *visitor)
 Handle visitors to this class.
 

Additional Inherited Members

- Public Types inherited from Visitor_Shop
using unique_ptr_t = std::unique_ptr< Visitor_Shop >
 Alias to make it easier to refer to a unique instance of this class.
 
- Public Member Functions inherited from Visitor_Shop
 Visitor_Shop ()
 Default Constructor.
 
virtual ~Visitor_Shop ()
 Virtual destructor.
 
std::string Name ()
 Name of the shop.
 
void SetName (std::string name)
 
std::string Address ()
 Address of the shop (could be a structure but a simple string is sufficient for this example).
 
void SetAddress (std::string address)
 
Visitor_VillageVillage ()
 The Village that contains this shop.
 
void SetVillage (Visitor_Village *v)
 
const MapOfStringsIngredientsForItems ()
 Specifies the ingredients needed for each item sold by the shop. Also, the keys are what the shop sells. The ingredient list could be empty if this shop is the origin of the item used as the key.
 
void SetIngredientsForItems (const MapOfStrings &ingredients)
 
bool DoesShopSellItem (std::string item)
 Determine if this shop sells the specified item.
 
bool IsItemInStock (std::string item)
 Determine if this shop has the specified item in stock.
 
void AddItemToInventory (std::string item)
 Add the specified item to this shop's inventory.
 
std::string StringizeList (StringList items)
 Convert a string list to a comma-delimited string. Useful for displaying the list.
 
bool PlaceOrder (StringList items)
 Place an order for the specified items. If the inventory is empty, replenish the inventory by visiting other shops for the missing ingredients.
 
void PickupOrder (StringList items, StringList &itemsToBePickedUp)
 Pick up the items sold by this shop (assumes the items were ordered already). Basically, this reduces the inventory for the given items that are sold by this shop.
 
virtual void Accept (Visitor *visitor)=0
 The visitor will call this method on each element it wants to visit.
 
- Public Attributes inherited from Visitor_Shop
std::map< std::string, int > Inventory
 Inventory for this shop.
 

Detailed Description

Represent a pickle grocer.

Definition at line 208 of file Visitor_Element_Classes.h.

Member Function Documentation

◆ Accept()

void Accept ( Visitor visitor)
inlineprivatevirtual

Handle visitors to this class.

Parameters
visitorThe visitor

Implements Visitor_Shop.

Definition at line 214 of file Visitor_Element_Classes.h.

References Visitor::VisitPickleGrocer().


The documentation for this class was generated from the following file: