Product Class Reference

The class Product represents a generic item to be sold. More...

#include <Product.h>

Inheritance diagram for Product:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 Product ()
 Default constructor.
 Product (Row &aRow)
 Construct a Product with values contained in a mysqlpp::Row.
 ~Product ()
 Default destructor.
auto_ptr< CategorygetCategory ()
 Returns product category.
float getPrice ()
 Return the price.
int getAvailability ()
 Return stock availability.
string primaryKey ()
 Primary key.

Static Public Member Functions

static Productfactory (string aName, int aCid, float aPrice, string aDescr="empty", int aQty=0, bool isDel=false)
 New product creation.
static ProductproductByID (int aPid)
 Returns a product with given ID.
static void showCompatibleProducts (int aPid)
 Show all configurations which include a given product.

Friends

ostream & operator<< (ostream &, Product &)

Detailed Description

The class Product represents a generic item to be sold.

As the ER model states, each product logical belongs to a category, i.e. a family of products of the same nature, such as monitor, accessories and so on. The class Product of course need to implements virtual methods of base class ManagedObject, its use is similar to previous classes described so far: the methods factory() allows to create a new instance of product, as well as productByID() fetches a product from the persistent store based on the specified criteria and catalog() returns the entire list of available products.


Constructor & Destructor Documentation

Product::Product (  ) 

Default constructor.

References LOG_CTOR.

Referenced by factory(), and productByID().

Product::Product ( Row &  aRow  ) 

Construct a Product with values contained in a mysqlpp::Row.

See also:
mysqlpp::Row

References LOG_CTOR.

Product::~Product (  ) 

Default destructor.


Member Function Documentation

Product * Product::factory ( string  aName,
int  aCid,
float  aPrice,
string  aDescr = "empty",
int  aQty = 0,
bool  isDel = false 
) [static]

New product creation.

Static method to create a new product (without saving into the database): product details are filled with given parameters.

Parameters:
[in] aName Product name
[in] aCid Category ID
[in] aPrice Product price
[in] aDescr Product detailed description
[in] aQty Number of stocked items
[in] isDel True if the product is not available
Returns:
An instance of the new product

References KEY_PRD_AVAILABILITY, KEY_PRD_CID, KEY_PRD_DELETED, KEY_PRD_DESCR, KEY_PRD_NAME, KEY_PRD_PID, KEY_PRD_PRICE, Product(), ManagedObject::setBoolForKey(), ManagedObject::setFloatForKey(), ManagedObject::setIntForKey(), and ManagedObject::setValueForKey().

Referenced by UserMenu::addNewProduct().

int Product::getAvailability (  ) 

Return stock availability.

Returns:
An integer representing the availability

References ManagedObject::intForKey(), and KEY_PRD_AVAILABILITY.

Referenced by Basket::addProduct().

auto_ptr< Category > Product::getCategory (  ) 

Returns product category.

Returns:
An instance of class Category which the product belongs

References Category::categoryByID(), ManagedObject::intForKey(), and KEY_PRD_CID.

Referenced by ProductProxy::getCategory(), and operator<<().

float Product::getPrice (  ) 

Return the price.

Returns:
A float representing the price

References ManagedObject::floatForKey(), and KEY_PRD_PRICE.

Referenced by Basket::addProduct(), and ProductProxy::getPrice().

string Product::primaryKey (  )  [virtual]

Primary key.

Returns the primary for entity "products" (KEY_PRD_PID)

Returns:
The primary key of the entity

Implements ManagedObject.

References KEY_PRD_PID.

Referenced by Basket::addProduct(), and Basket::removeProduct().

Product * Product::productByID ( int  aPid  )  [static]

Returns a product with given ID.

Parameters:
[in] aPid The requested product ID
Returns:
A pointer to the requested Product, NULL if not found

References Database::getConnection(), Singleton< Database >::instance(), Product(), and SQL_PRODUCT_PROXY.

Referenced by UserMenu::changeProductDetail().

void Product::showCompatibleProducts ( int  aPid  )  [static]

Show all configurations which include a given product.

Parameters:
[in] aPid Given product ID

References Database::getConnection(), Singleton< Database >::instance(), and Database::printResult().

Referenced by UserMenu::showConfigurationByProduct().


Friends And Related Function Documentation

ostream& operator<< ( ostream &  aStream,
Product p 
) [friend]

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

Generated by  doxygen 1.6.2