The only purpose of the class is to provide a common base for product items and personalized product items. For new product item types, three classes should be defined:
Definition at line 81 of file productitem.h.
Unique identification of the product item type.
Definition at line 88 of file productitem.h.
OSB_LIB::ProductItemBase::ProductItemBase | ( | ) |
Empty constructor.
virtual OSB_LIB::ProductItemBase::~ProductItemBase | ( | ) | [virtual] |
Virtual destructor.
OSB_LIB::ProductItemBase::ProductItemBase | ( | const ProductItemBase & | rhs | ) | [protected] |
Copying for derived classes only.
const P * OSB_LIB::ProductItemBase::isa | ( | const P *& | ptr | ) | const |
P * OSB_LIB::ProductItemBase::isa | ( | P *& | ptr | ) |
Downcast to a derived class.
The function uses dynamic_cast<P*> to downcast an object of ProductItemBase to an object of a derived class.
ptr = dynamic_cast<P*>(this); return ptr;
The typical use is:
void foo(const ProductItemBase& pi) { ... Item* pItem; if (0 != pi.isa(pItem)) { // work with pItem } }
ptr | Pointer to cast to. It gets the result of the downcast. It's value will be 0 if the cast fails. |
Definition at line 713 of file productitem.h.
ProductItemBase& OSB_LIB::ProductItemBase::operator= | ( | const ProductItemBase & | rhs | ) | [protected] |
Assignment or derived classes only.
virtual Type OSB_LIB::ProductItemBase::type | ( | ) | const [pure virtual] |
The type of the product item.
The function returns the type of the product item. It is needed for only one reason: Corba clients must provide a configuration window that depends on the actual type.
No appropriate design can be provided: Unless on-line clients use the real product item type through-out the whole live cycle of an object, there must be a way to determine the actual type of a product item. No matter how clever we make our design, for on-line clients there will always be one step where they need to determine a product item's type in a switch-like statement. For this step I personally perfer to work with an enumeration type (and compiler warnings) rather than relying on dynamic casts (where errors can be detected only during run-time).
Implemented in OSB_LIB::PersAn, OSB_LIB::AnItem, OSB_LIB::PersCallingCard, OSB_LIB::CallingCardItem, OSB_LIB::PersCredit, OSB_LIB::CreditItem, OSB_LIB::DeviceItem, OSB_LIB::PersE164Item, OSB_LIB::E164Item, OSB_LIB::PersIpGroup, OSB_LIB::IpGroupItem, OSB_LIB::PersUimCard, OSB_LIB::PricelistItem, OSB_LIB::DescriptionItem, OSB_LIB::PersService, OSB_LIB::ServiceItem, OSB_LIB::PersTrunk, OSB_LIB::TrunkItem, OSB_LIB::PersTariffSystem, and OSB_LIB::TariffSystemItem.