Implementation of the Village structure's support functions, Village_Initialize(), Village_Clear(), Village_Load(), Village_AddShop(), and Village_VisitShop(), as used in the Visitor Pattern. More...
Go to the source code of this file.
Functions | |
static bool | Village_AddShop (Village *village, Visitor_Shop *shop) |
Add a Visitor_Shop object to the specified Village. The Village object takes ownership of the Visitor_Shop object and is responsible for freeing up any memory associated with the shop. | |
void | Village_Initialize (Village *village) |
Initialize the specified Village object. | |
void | Village_Clear (Village *village) |
Clear the specified Village object, releasing any allocated memory associated with the village and its contents. The Village object is left in an newly-initialized state. | |
bool | Village_Load (Village *village) |
Set up the specified Village object with all the shops that can be visited. | |
bool | Village_VisitShop (Village *village, OrderVisitor *visitor) |
Visit all shops in the given Village object to find the ingredients specified in the OrderVisitor object. | |
Implementation of the Village structure's support functions, Village_Initialize(), Village_Clear(), Village_Load(), Village_AddShop(), and Village_VisitShop(), as used in the Visitor Pattern.
Definition in file Visitor_Village.c.
|
static |
Add a Visitor_Shop object to the specified Village. The Village object takes ownership of the Visitor_Shop object and is responsible for freeing up any memory associated with the shop.
village | The Village to which to add the shop. |
shop | The Visitor_Shop object to add to the village. |
Definition at line 24 of file Visitor_Village.c.
References Village::shops, and Village::shops_count.
Referenced by Village_Load().
void Village_Clear | ( | Village * | village | ) |
Clear the specified Village object, releasing any allocated memory associated with the village and its contents. The Village object is left in an newly-initialized state.
village | The Village object to clear. |
Definition at line 72 of file Visitor_Village.c.
References Shop_Destroy(), Village::shops, Village::shops_count, and Village_Initialize().
Referenced by Visitor_Exercise().
void Village_Initialize | ( | Village * | village | ) |
Initialize the specified Village object.
village | The Village object to initialize. |
Definition at line 59 of file Visitor_Village.c.
References Village::Name, Village::shops, and Village::shops_count.
Referenced by Village_Clear(), and Visitor_Exercise().
bool Village_Load | ( | Village * | village | ) |
Set up the specified Village object with all the shops that can be visited.
village | The Village object to load. |
Definition at line 88 of file Visitor_Village.c.
References Visitor_Shop::IngredientsForItems, MapOfStrings_AddArray(), Village::Name, Shop_Create(), Shop_Destroy(), and Village_AddShop().
Referenced by Visitor_Exercise().
bool Village_VisitShop | ( | Village * | village, |
OrderVisitor * | visitor | ||
) |
Visit all shops in the given Village object to find the ingredients specified in the OrderVisitor object.
village | The Village object whose shops are to be visited. |
visitor | The OrderVisitor object describing what is being ordered. |
Definition at line 338 of file Visitor_Village.c.
References OrderVisitor_VisitShop(), Village::shops, and Village::shops_count.
Referenced by Shop_PlaceOrder(), and Visitor_Exercise().