From 9878eb47effd38c9ee870495fbd7ec3ed1c96438 Mon Sep 17 00:00:00 2001 From: Hugo Puhlmann Date: Fri, 10 Dec 2010 01:34:05 -0200 Subject: [PATCH] all methods implemented --- src/RestaurantRegistry.h | 53 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/src/RestaurantRegistry.h b/src/RestaurantRegistry.h index 3478122..a99fb9c 100644 --- a/src/RestaurantRegistry.h +++ b/src/RestaurantRegistry.h @@ -33,12 +33,57 @@ namespace rty { public: typedef UserInterface::group_data group_data; + + struct gp_time + { + group_data gd; + time_t left_at; + }; + + struct ord_group + { + group_data gp; + htl::list ord; + }; + + void registryGroup(const group_data& gp) + { + group_active.push_back(gp); + } + + void notifyGroupLeft(const group_data& gp) + { + int no_table = gp.tables.front()->num; + for(htl::list::iterator it = group_active.begin(); it != group_active.end(); it++) + { + for(htl::vector::iterator iv = (*it).tables.begin(); iv != (*it).tables.end(); it++) + { + if((*iv)->num == no_table) + { + group_active.erase(it); + gp_time g = {(*it), Chronometer::getInstance().getCurrent()}; + groups_left.push_back(g); + no_table = -1; + break; + } + } + if(no_table == -1) + break; + } + } + + void registryOrder(const group_data& gp, const htl::list& order) + { + ord_group o = { gp , order }; + orders.push_back(o); + } + - void registryGroup(const group_data& gp); - void notifyGroupLeft(const group_data& gp); - void registryOrder(const group_data& gp, const htl::list& order); - private: + private: + htl::list groups_left; + htl::list group_active; + htl::list orders; }; }