This base class is responsible to maintain the link between a personalized item and its optionally assigned network resource.
All derived concrete classes should have a member that points to their assigned resource of the corresponding type. Example:
class CallingCard : public Resource { ... }; class PersCallingCard : public PersResource { public: // Real life: the member is virtual: do not inline. const Resource* resource() const { return callingCard_; } private: CallingCard* callingCard_; }
Definition at line 137 of file resourceitem.h.
Remember that derived classes have to implement the pure virtual I/O operations required by PersProductItem, e.g., readSpecific(). For this they preferably use the database methods of this base class.
typedef std::auto_ptr<PersResource> OSB_LIB::PersResource::AutoPtr |
Short-cut for an auto pointer.
For details see quality manual, implementation patterns: Virtual copy construction.
Reimplemented from OSB_LIB::PersProductItem.
Reimplemented in OSB_LIB::PersAn, OSB_LIB::PersCallingCard, OSB_LIB::PersE164Item, OSB_LIB::PersIpGroup, and OSB_LIB::PersTrunk.
Definition at line 140 of file resourceitem.h.
Default constructor with optional object id.
oid | Object id of PersProductItem. This is not the the resource id! |
OSB_LIB::PersResource::PersResource | ( | const PersResource & | rhs | ) | [protected] |
Copying for derived classes only.
virtual bool OSB_LIB::PersResource::changeAssignTs | ( | const OSB_DB::Session & | session, | |
const DateTime & | newTs | |||
) | [protected, virtual] |
Change the assignment time of a pers. resource.
session | Database session to use. | |
newTs | Changed assignment date and time. |
OsbException | if newTs creates an overlap with another assignment of the resource. | |
OsbException | if the assigned resource was modified. |
Reimplemented from OSB_LIB::PersProductItem.
AutoPtr OSB_LIB::PersResource::clone | ( | ) | const |
Virtual copy construction.
For details see quality manual, implementation patterns.
Reimplemented from OSB_LIB::PersProductItem.
Reimplemented in OSB_LIB::PersAn, OSB_LIB::PersCallingCard, OSB_LIB::PersE164Item, OSB_LIB::PersIpGroup, and OSB_LIB::PersTrunk.
virtual Resource* OSB_LIB::PersResource::createResource | ( | const Id< Resource > & | resourceId | ) | [private, pure virtual] |
Create an empty resource.
resourceId | Object id of the resource. |
class PersTrunk : public PersResource { ... private: TrunkResource* resource_; }; Resource* PersTrunk::createResource( const Resource::Oid& resourceId ) { // Make sure the resource id matches. if (0 != resource_) { if (resourceId != resource->oid()) { delete resource_; resource_ = 0; } } // Create the trunk resource if needed. if (0 == resource_) { // This either succeeds or throw std::bad_alloc. resource_ = new TrunkResource(resourceId); } return resource_; }
virtual bool OSB_LIB::PersResource::deassignOld | ( | const OSB_DB::Session & | session | ) | [protected, virtual] |
Deassign the pers. product item in the database.
The function is called when the status of the pers node is not created.
It calls deassignOldBase() to set the deassign date of the base class.
Derived class may reimplement it if they have specific things to do.
session | Database session to use. |
Reimplemented from OSB_LIB::PersProductItem.
bool OSB_LIB::PersResource::delPersResource | ( | const OSB_DB::Session & | session | ) | [protected] |
Delete a pers. resource from the database.
session | Database session to use. |
OsbException | if no resource is assigned. |
bool OSB_LIB::PersResource::insPersResource | ( | const OSB_DB::Session & | session | ) | [protected] |
Insert a pers. resource to the database.
session | Database session to use. |
OsbException | if no resource is assigned. |
virtual Resource* OSB_LIB::PersResource::oldResource | ( | ) | [private, pure virtual] |
Non-const access to the previous assigned resource.
Implemented in OSB_LIB::PersAn, OSB_LIB::PersCallingCard, OSB_LIB::PersE164Item, OSB_LIB::PersIpGroup, and OSB_LIB::PersTrunk.
virtual const Resource* OSB_LIB::PersResource::oldResource | ( | ) | const [pure virtual] |
Access to the old assigned resource.
Implemented in OSB_LIB::PersAn, OSB_LIB::PersCallingCard, OSB_LIB::PersE164Item, OSB_LIB::PersIpGroup, and OSB_LIB::PersTrunk.
PersResource& OSB_LIB::PersResource::operator= | ( | const PersResource & | rhs | ) | [protected] |
Assignment for derived classes only.
virtual bool OSB_LIB::PersResource::overwrite | ( | const OSB_DB::Session & | session | ) | [protected, virtual] |
Overwrite a pers. resource in the database.
session | Database session to use. |
OsbException | if no old resource exists. | |
OsbException | if no new resource is assigned. |
Reimplemented from OSB_LIB::PersProductItem.
virtual std::string OSB_LIB::PersResource::personalization | ( | ) | const [virtual] |
Personalization: The resource number.
By default, the personalization of a resource is the fully qualified resource number. Derived classes may overwrite the default behaviour where it is not suitable:
A E164 phone number, e.g., is usually provided without country code, but instead starts with the national access code: "079 4006070" instead of "41 79 4006070".
Implements OSB_LIB::PersProductItem.
Reimplemented in OSB_LIB::PersE164Item.
bool OSB_LIB::PersResource::readPersResource | ( | const OSB_DB::Session & | session | ) | [protected] |
(Re)read a pers. resource item from the database.
session | Database session to use. |
OsbException | Resource type specific exceptions from Resource::read(). |
virtual Resource* OSB_LIB::PersResource::resource | ( | ) | [private, pure virtual] |
Non-const access to the assigned resource.
Implemented in OSB_LIB::PersAn, OSB_LIB::PersCallingCard, OSB_LIB::PersE164Item, OSB_LIB::PersIpGroup, and OSB_LIB::PersTrunk.
virtual const Resource* OSB_LIB::PersResource::resource | ( | ) | const [pure virtual] |
Access to the assigned resource.
Implemented in OSB_LIB::PersAn, OSB_LIB::PersCallingCard, OSB_LIB::PersE164Item, OSB_LIB::PersIpGroup, and OSB_LIB::PersTrunk.
bool OSB_LIB::PersResource::resourceAssigned | ( | ) | const |
The id of the assigned resource.