ProductProxy Class Reference

The class ProductProxy is a virtual proxy of class Product. More...

#include <Product.h>

Collaboration diagram for ProductProxy:
Collaboration graph
[legend]

List of all members.

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< CategorygetCategory ()
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

ProductgetProduct ()
 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 &)

Detailed Description

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.

See also:
Product, getProduct()

Constructor & Destructor Documentation

ProductProxy::ProductProxy ( int  aPid  ) 

Construct an instance of ProductProxy by specifying product unique ID.

Parameters:
[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.


Member Function Documentation

vector< ProductProxy * > & ProductProxy::catalog ( int  aCid = 0  )  [static]
int ProductProxy::getAvailability (  ) 

Return the product availability.

Returns:
How many pieces of this product are available

References getProduct(), ManagedObject::intForKey(), and KEY_PRD_AVAILABILITY.

auto_ptr< Category > ProductProxy::getCategory (  ) 
string ProductProxy::getDescr (  ) 

Returns product description.

Returns:
The product description
See also:
getProduct(), Product()

References getProduct(), KEY_PRD_DESCR, and ManagedObject::valueForKey().

string ProductProxy::getName (  ) 

Returns product name.

Returns:
THe name of the product
See also:
getProduct(), Product()

References getProduct(), KEY_PRD_NAME, and ManagedObject::valueForKey().

Referenced by UserMenu::browseProductCatalog(), and UserMenu::showConfigurationByProduct().

float ProductProxy::getPrice (  ) 

Returns the price of this product.

Returns:
The price of the product
See also:
getProduct(), 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.

Returns:
A pointer to class Product

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.

Returns:
Product ID

References _pid.

Referenced by Basket::addProduct(), UserMenu::browseProductCatalog(), and UserMenu::showConfigurationByProduct().


Friends And Related Function Documentation

ostream& operator<< ( ostream &  aStream,
ProductProxy pp 
) [friend]

Member Data Documentation

int ProductProxy::_pid [private]

Referenced by getProduct(), ProductProxy(), and uniqueID().


The documentation for this class was generated from the following files:

Generated by  doxygen 1.6.2