The class ProductProxy is a virtual proxy of class Product. More...
#include <Product.h>
Public Member Functions | |
ProductProxy (int aPid) | |
Construct an instance of ProductProxy by specifying product unique ID. | |
~ProductProxy () | |
Default destructor: dealloc instance of real object if it was allocated. | |
auto_ptr< Category > | getCategory () |
int | uniqueID () const |
Return the product unique ID. | |
float | getPrice () |
Returns the price of this product. | |
string | getName () |
Returns product name. | |
string | getDescr () |
Returns product description. | |
int | getAvailability () |
Return the product availability. | |
Static Public Member Functions | |
static vector< ProductProxy * > & | catalog (int aCid=0) |
Protected Member Functions | |
Product * | getProduct () |
Concrete creation of an instance of Product class; when client programmer tries to access to some ProductProxy methods, such as getPrice(), a call to this method ensures that the product is instantiated only we really needed. | |
Private Attributes | |
Product * | _theProduct |
int | _pid |
Friends | |
ostream & | operator<< (ostream &, ProductProxy &) |
The class ProductProxy is a virtual proxy of class Product.
There could be situation when only a proxy of the real product is needed and not all its data are requested: for example, think at new order placing, where only product ID is asked to be known. Whenever other information are requested, ProductProxy provides lazy creation of the product and forwards the request.
ProductProxy::ProductProxy | ( | int | aPid | ) |
Construct an instance of ProductProxy by specifying product unique ID.
[in] | aPid | Product unique ID |
References _pid, and _theProduct.
Referenced by catalog().
ProductProxy::~ProductProxy | ( | ) |
Default destructor: dealloc instance of real object if it was allocated.
References _theProduct.
vector< ProductProxy * > & ProductProxy::catalog | ( | int | aCid = 0 |
) | [static] |
References Database::getConnection(), Database::Instance(), ProductProxy(), and SQL_CATALOG_PROXY.
Referenced by UserMenu::browseProductCatalog(), and UserMenu::showConfigurationByProduct().
int ProductProxy::getAvailability | ( | ) |
Return the product availability.
References getProduct(), ManagedObject::intForKey(), and KEY_PRD_AVAILABILITY.
auto_ptr< Category > ProductProxy::getCategory | ( | ) |
References Product::getCategory(), and getProduct().
Referenced by UserMenu::browseProductCatalog().
string ProductProxy::getDescr | ( | ) |
Returns product description.
References getProduct(), KEY_PRD_DESCR, and ManagedObject::valueForKey().
string ProductProxy::getName | ( | ) |
Returns product name.
References getProduct(), KEY_PRD_NAME, and ManagedObject::valueForKey().
Referenced by UserMenu::browseProductCatalog(), and UserMenu::showConfigurationByProduct().
float ProductProxy::getPrice | ( | ) |
Returns the price of this product.
References Product::getPrice(), and getProduct().
Referenced by Basket::addProduct().
Product * ProductProxy::getProduct | ( | ) | [protected] |
Concrete creation of an instance of Product class; when client programmer tries to access to some ProductProxy methods, such as getPrice(), a call to this method ensures that the product is instantiated only we really needed.
References _pid, _theProduct, Database::getConnection(), Database::Instance(), and SQL_PRODUCT_PROXY.
Referenced by getAvailability(), getCategory(), getDescr(), getName(), getPrice(), and operator<<().
int ProductProxy::uniqueID | ( | ) | const |
Return the product unique ID.
References _pid.
Referenced by Basket::addProduct(), UserMenu::browseProductCatalog(), and UserMenu::showConfigurationByProduct().
ostream& operator<< | ( | ostream & | aStream, | |
ProductProxy & | pp | |||
) | [friend] |
int ProductProxy::_pid [private] |
Referenced by getProduct(), ProductProxy(), and uniqueID().
Product* ProductProxy::_theProduct [private] |
Referenced by getProduct(), ProductProxy(), and ~ProductProxy().