#include <UserMenu.h>
Public Member Functions | |
UserMenu () | |
~UserMenu () | |
void | mainMenu () |
Displays the main menu: user is allowed to login into the system, register himself as new user or quit the application. | |
bool | login () |
Ask user to enter his crendentials and test the access: if successful, an instance of User is allocated and assigned to _currentUser. | |
void | display () throw (BadAuthException) |
Display a menu to the screen, according to authorization level of current user. | |
void | registerNewUser () |
Give the user the opportunity to register as new user. | |
Private Member Functions | |
void | browseProductCatalog () throw (BadAuthException) |
Browse product catalog by category. | |
void | showProductDetail () throw (BadAuthException) |
void | showConfigurationByProduct () throw (BadAuthException) |
void | showUserProfile () throw (BadAuthException) |
void | placeNewOrder () throw (BadAuthException) |
void | addNewCategory () throw (BadAuthException) |
Admin operation to create a new category of products. | |
void | addNewProduct () throw (BadAuthException) |
void | changeProductDetail () throw (BadAuthException) |
void | disableUser () throw (BadAuthException) |
Admin operation to disable a registered user. | |
void | displayMonthlyTrend () throw (BadAuthException) |
Admin operation to display monthly trend of sales. | |
void | displayUnprivilegedMenu () throw (BadAuthException) |
void | displayAdminMenu () throw (BadAuthException) |
void | wait () |
Wait for user to press enter/return to continue. | |
bool | getNotEmptyLine (const char *msg, char **buffer, int len, const char *end) |
Private Attributes | |
User * | _currentUser |
map< int, op > | usr_operations |
map< int, op > | adm_operations |
UserMenu::UserMenu | ( | ) |
UserMenu::~UserMenu | ( | ) |
References _currentUser, and LOG_DTOR.
void UserMenu::addNewCategory | ( | ) | throw (BadAuthException) [private] |
Admin operation to create a new category of products.
BadAuthException | If called without being authenticated |
References _currentUser, CLEAR_SCREEN_CMD, Category::factory(), ManagedObject::store(), and wait().
Referenced by UserMenu().
void UserMenu::addNewProduct | ( | ) | throw (BadAuthException) [private] |
References _currentUser, Category::catalog(), CLEAR_SCREEN_CMD, Product::factory(), ManagedObject::store(), and wait().
Referenced by UserMenu().
void UserMenu::browseProductCatalog | ( | ) | throw (BadAuthException) [private] |
Browse product catalog by category.
(All categories could be listed at the same time)
BadAuthException | If called without being authenticated |
References _currentUser, ProductProxy::catalog(), Category::catalog(), CLEAR_SCREEN_CMD, ProductProxy::getCategory(), ProductProxy::getName(), ProductProxy::uniqueID(), and wait().
Referenced by changeProductDetail(), placeNewOrder(), showProductDetail(), and UserMenu().
void UserMenu::changeProductDetail | ( | ) | throw (BadAuthException) [private] |
References _currentUser, browseProductCatalog(), KEY_PRD_DESCR, KEY_PRD_NAME, KEY_PRD_PRICE, Product::productByID(), ManagedObject::setFloatForKey(), ManagedObject::setValueForKey(), ManagedObject::update(), and wait().
Referenced by UserMenu().
void UserMenu::disableUser | ( | ) | throw (BadAuthException) [private] |
Admin operation to disable a registered user.
BadAuthException | If called without being authenticated or not authorized |
References _currentUser, AdminUser::changeUserPassword(), CLEAR_SCREEN_CMD, User::fullName(), AdminUser::userList(), and wait().
Referenced by UserMenu().
void UserMenu::display | ( | ) | throw (BadAuthException) |
Display a menu to the screen, according to authorization level of current user.
BadAuthException | If called by client programmer without any logged user |
References _currentUser, displayAdminMenu(), displayUnprivilegedMenu(), and User::isAdmin().
Referenced by mainMenu().
void UserMenu::displayAdminMenu | ( | ) | throw (BadAuthException) [private] |
References _currentUser, adm_operations, and CLEAR_SCREEN_CMD.
Referenced by display().
void UserMenu::displayMonthlyTrend | ( | ) | throw (BadAuthException) [private] |
Admin operation to display monthly trend of sales.
BadAuthException | If called without being authenticated or not authorized |
References _currentUser, CLEAR_SCREEN_CMD, AdminUser::showMonthlyTrend(), and wait().
Referenced by UserMenu().
void UserMenu::displayUnprivilegedMenu | ( | ) | throw (BadAuthException) [private] |
References _currentUser, CLEAR_SCREEN_CMD, and usr_operations.
Referenced by display().
bool UserMenu::getNotEmptyLine | ( | const char * | msg, | |
char ** | buffer, | |||
int | len, | |||
const char * | end | |||
) | [private] |
Referenced by registerNewUser().
bool UserMenu::login | ( | ) |
Ask user to enter his crendentials and test the access: if successful, an instance of User is allocated and assigned to _currentUser.
References _currentUser, CLEAR_SCREEN_CMD, User::login(), and wait().
Referenced by mainMenu(), and registerNewUser().
void UserMenu::mainMenu | ( | ) |
Displays the main menu: user is allowed to login into the system, register himself as new user or quit the application.
References CLEAR_SCREEN_CMD, display(), login(), and registerNewUser().
Referenced by main().
void UserMenu::placeNewOrder | ( | ) | throw (BadAuthException) [private] |
References _currentUser, Basket::addProduct(), browseProductCatalog(), CLEAR_SCREEN_CMD, User::getBasket(), User::placeOrder(), and wait().
Referenced by UserMenu().
void UserMenu::registerNewUser | ( | ) |
Give the user the opportunity to register as new user.
References CLEAR_SCREEN_CMD, User::factory(), getNotEmptyLine(), login(), and wait().
Referenced by mainMenu().
void UserMenu::showConfigurationByProduct | ( | ) | throw (BadAuthException) [private] |
References _currentUser, ProductProxy::catalog(), CLEAR_SCREEN_CMD, ProductProxy::getName(), Product::showCompatibleProducts(), ProductProxy::uniqueID(), and wait().
Referenced by UserMenu().
void UserMenu::showProductDetail | ( | ) | throw (BadAuthException) [private] |
References _currentUser, browseProductCatalog(), CLEAR_SCREEN_CMD, and wait().
Referenced by UserMenu().
void UserMenu::showUserProfile | ( | ) | throw (BadAuthException) [private] |
References _currentUser, CLEAR_SCREEN_CMD, Order::ordersForUser(), Order::products(), and wait().
Referenced by UserMenu().
void UserMenu::wait | ( | ) | [private] |
Wait for user to press enter/return to continue.
Referenced by addNewCategory(), addNewProduct(), browseProductCatalog(), changeProductDetail(), disableUser(), displayMonthlyTrend(), login(), placeNewOrder(), registerNewUser(), showConfigurationByProduct(), showProductDetail(), and showUserProfile().
User* UserMenu::_currentUser [private] |
Referenced by addNewCategory(), addNewProduct(), browseProductCatalog(), changeProductDetail(), disableUser(), display(), displayAdminMenu(), displayMonthlyTrend(), displayUnprivilegedMenu(), login(), placeNewOrder(), showConfigurationByProduct(), showProductDetail(), showUserProfile(), UserMenu(), and ~UserMenu().
map<int, op> UserMenu::adm_operations [private] |
Referenced by displayAdminMenu(), and UserMenu().
map<int, op> UserMenu::usr_operations [private] |
Referenced by displayUnprivilegedMenu(), and UserMenu().