The class Category represents a logical group of products of the same nature; it’s associated with the entity category of the ER model and derives directly from ManagedObject. More...
#include <Category.h>
Public Member Functions | |
Category () | |
Class constructor. | |
string | primaryKey () |
Returns the primary for entity "categories" (KEY_CAT_CID). | |
string | getName () |
Returns category name. | |
Static Public Member Functions | |
static Category * | categoryByID (int aCid) |
Fetch a category by specifing its ID. | |
static Category * | factory (string aValue) |
Create a new category. | |
static vector< Category * > & | catalog () |
Returns the list of available categories. | |
Friends | |
ostream & | operator<< (ostream &, Category &) |
The class Category represents a logical group of products of the same nature; it’s associated with the entity category of the ER model and derives directly from ManagedObject.
As requirements, each product must be assigned to a category, as well as category can contain zero or more than one product.
Category::Category | ( | ) |
vector< Category * > & Category::catalog | ( | ) | [static] |
Returns the list of available categories.
References Category(), Database::getConnection(), Singleton< Database >::instance(), KEY_CAT_CID, KEY_CAT_NAME, ManagedObject::setValueForKey(), and SQL_CATEGORY_CAT.
Referenced by UserMenu::addNewProduct(), and UserMenu::browseProductCatalog().
Category * Category::categoryByID | ( | int | aCid | ) | [static] |
Fetch a category by specifing its ID.
[in] | aCid | Category ID to be fetched |
References Category(), Database::getConnection(), Singleton< Database >::instance(), KEY_CAT_CID, KEY_CAT_NAME, ManagedObject::setIntForKey(), ManagedObject::setValueForKey(), and SQL_CATEGORY_BYID.
Referenced by Product::getCategory().
Category * Category::factory | ( | string | aValue | ) | [static] |
Create a new category.
Create a new category to be stored into the database; the method store need to be called to make changes persistent.
aValue | The category name |
References Category(), KEY_CAT_CID, KEY_CAT_NAME, ManagedObject::setIntForKey(), and ManagedObject::setValueForKey().
Referenced by UserMenu::addNewCategory().
string Category::getName | ( | ) |
Returns category name.
References KEY_CAT_NAME, and ManagedObject::valueForKey().
string Category::primaryKey | ( | ) | [virtual] |
Returns the primary for entity "categories" (KEY_CAT_CID).
Implements ManagedObject.
References KEY_CAT_CID.
ostream& operator<< | ( | ostream & | aStream, | |
Category & | c | |||
) | [friend] |