1. Framework of Assignment One 0) what modules do we need? shell : deal with user inputs thread manager : start or cancel a thread according to user's command thread object: id, real thread id, description database : manage the data record, add, del, mod , updates etc. 1) the command shell > after start your program up, a shell should be working to get user commands > The shell should be a while/do loop. In the body of the loop, the shell get user input, parse the input string, issue the correspondent command if it is a valid command. > shell ends until get a "quit" command > parse user input, you could use strtok_r() see the example > if it is a valid command, then pass the command and its parameters to THread Manager. Q: How to pass the info ? Note: different commands have different parameter and format. 2) Thread manager: > Thread manger wait for shell's instruction. it gets commands from shell then spawn the working threads. > It may have a function like this: ThreadManager.MakeThread(myAuction.Alter, Packed_data, "Modifying a data record"); it is to spawn a modification thread, Packed_data is the arguments passed to Mod funcion, and there is also a description of the thread, which will be displayed after the list command. > the packed_data is the arguments of command "Alter", i.e. Auction_name Key NewTitle > Here, we should use wrapper to pass multiple arguments Q: But, different command has different arguments, so do we have to use different MakeThread? such as MakeAlterThread(MyAuction.Alter, Packed_data_ALter, "Modifying a data record"); MakeAddThread(myAuction.Add, Packed_data_Add, "Adding a data record"); > you don't have to use the above different MakeThread functions, you can let the actual function to de-wrapper the packed_data. > further, you can use class inheritage. you have a base_wrapper to include the basic data items, and you have a ALter_wrapper inherit this base class to inlude extra data items used by "Alter_func()" e.g. class Base_Wrapper { public: char* Name; char* Identifier; int Amount; Auction* Object; char Auction_Name[25]; Base_Wrapper(); virtual ~Base_Wrapper(); } class Alater_Wrapper : public Base_Wrapper { public: Key_Type Key_To_Find; char String_Data[25]; int Integer_Data; Item_Type Item_Data; Modification_Type What_To_Do; Mod_Wrapper() : Base_Wrapper() {;} bool Is_Mod() { return true; } }; > Thread Manager have to maintain a list of threads currently running. The list item should contain info such as "id of this thread", "pthread_t id", "description" etc. so we'd better have a thread_object also. > you can use "Standard Template Library" in C++ to manage such thread list #include class Thread_Manager { private: list All_Threads; int Current_Id_Counter; } to append a item to this list: Thread_Object * newThrd = new Thread_Object; All_Threads.push_back(newThrd); To traverse this list: list::iterator go_through = All_Threads.begin(); current_item = *go_through; go_through ++; to get rid of an item: delete(*go_through) All_threads.erase(go_through); > each thread in the list should have a unique id, so THread manager should have a Id_counter. After allocate a id to a new thread , id is increased by 1. 3) Thread Object > our id of this thread, real thread id, a description. > in destructor, THread Object "kill" this thread using pthread_cancel(); 4) Data Object > char* Title; char* Seller; int Timeleft; int Bid_amount; char* Bidder; char* ID; 5) Auction Object >class Auction { private: list All_Objects; char* Auction_Name; public: Auction(char* Name); ~Auction(); //Thread Functions that will be spawned off static void* Mod(void* Packed_Data); static void* Add(void* Packed_Data); static void* Del(void* Packed_Data); static void* Printo(void* Packed_Data); static void* Printi(void* Packed_Data); static void* Load(void* Packed_Data); static void* Save(void* Packed_Data); }; 2. Reminders 1) be careful with the pointers. 2) take advantage of C++ 2) deal with the error commands , give enough response to user inputs 3) Make file and Readme file 3. Test case