Design Pattern Examples
Overview of object-oriented design patterns
c/Visitor_Shop.h
Go to the documentation of this file.
1
6
7#pragma once
8#ifndef __VISITOR_SHOP_H__
9#define __VISITOR_SHOP_H__
10
11#include "helpers/mapofstrings.h"
12#include "helpers/mapofint.h"
13
14struct OrderVisitor; // forward declaration
15
19typedef enum
20{
25
29typedef struct
30{
31 const char* Name;
32 const char* Address;
33 struct Village* Village;
37
38//-----------------------------------------------------------------------------
39
49Visitor_Shop* Shop_Create(const char* name, const char* address, struct Village* village);
50
57void Shop_Destroy(Visitor_Shop* shop);
58
59
72
87bool Shop_PickupOrder(Visitor_Shop* shop, ConstStringList* items, ConstStringList* itemsToBePickedUp);
88
89#endif // __VISITOR_SHOP_H__
90
bool Shop_PickupOrder(Visitor_Shop *shop, ConstStringList *items, ConstStringList *itemsToBePickedUp)
Pick up the items sold by this shop (assumes the items were ordered already). Basically,...
Definition: Visitor_Shop.c:331
void Shop_Destroy(Visitor_Shop *shop)
Destroy an instance of the Visitor_Shop structure, freeing up any memory that may have been allocated...
Definition: Visitor_Shop.c:163
PlaceOrderReponse
Represents the possible responses from the Shop_PlaceOrder() function.
@ PlaceOrderResponse_OrderIgnored
Order was ignored.
@ PlaceOrderResponse_Error
There was an error placing the order, likely an out of memory condition.
@ PlaceOrderResponse_OrderAccepted
Order was accepted.
Visitor_Shop * Shop_Create(const char *name, const char *address, struct Village *village)
Creates a new instance of a Visitor_Shop structure, and initializes it with the given name,...
Definition: Visitor_Shop.c:140
PlaceOrderReponse Shop_PlaceOrder(Visitor_Shop *shop, ConstStringList *itemsToOrder)
Visit the specified Visitor_Shop object to try to place an order as described in the OrderVisitor obj...
Definition: Visitor_Shop.c:177
Declaration of the MapOfInt structure and supporting functions for managing a map of integers keyed b...
Represents a list of pointers to zero-terminated strings that are to remain constant and never delete...
Represents a list of MapOfIntEntry objects that maps a string to an integer value....
Definition: mapofint.h:27
Represents a list of structures that map strings to ConstStringList objects.
Represents a visitor used for ordering items from various shops. The user starts with an instance of ...
Represents a collection of shops that can be visited.
Represents a shop in the village that can be visited.
const char * Name
Name of shop. Borrowed pointer.
const char * Address
Address of shop. Borrowed pointer.
MapOfInt Inventory
Maps ingredient to number of that ingredient in the shop.
struct Village * Village
Village this shop is in. Borrowed pointer.
MapOfStrings IngredientsForItems
Maps ingredient to list of items need for ingredient.