OSB_LIB::PersResource Class Reference

Inheritance diagram for OSB_LIB::PersResource:

Inheritance graph
[legend]
Collaboration diagram for OSB_LIB::PersResource:

Collaboration graph
[legend]
List of all members.

Detailed Description

Resource as personalized product item.

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_;
      }

Remarks:
Copy constructor by compiler.

Definition at line 137 of file resourceitem.h.

Public Types

Public Member Functions

Access to the assigned resource:
NOTE to the developpers: add wrappers to the assigned resource as needed, but be sure to pay attention to the fact that the pointer to the assigned resource may be 0!
E.g., resourceId() returns an object and not a const reference because of this.

Protected Member Functions

Database operations:
Database operations on a personalized resource only make sense if a Resource is assigned:
The operations do not only maintain the link table PERS_ITEM, but also the respective entry in NETWORK_RESOURCE.

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.

Private Member Functions


Member Typedef Documentation

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.


Constructor & Destructor Documentation

OSB_LIB::PersResource::PersResource ( const Oid oid = Oid()  )  [explicit]

Default constructor with optional object id.

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


Member Function Documentation

virtual bool OSB_LIB::PersResource::changeAssignTs ( const OSB_DB::Session session,
const DateTime newTs 
) [protected, virtual]

Change the assignment time of a pers. resource.

Parameters:
session Database session to use.
newTs Changed assignment date and time.
Returns:
true if the assignment time was changed, else false.
Exceptions:
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.

Parameters:
resourceId Object id of the resource.
Returns:
A pointer to the resource, its object id must be resourceId.
The returned pointer must be owned by the object on which the method is called, the ownership is NOT transferred to the caller.
The implementation must ensure that the return value is never 0, i.e., throw std::bad_alloc is memory allocation fails.

Remarks:
This member is needed by readPersResource() where the product item is being constructed from the database.
A possible implementation is (it is not mandatory that an existing resource is deleted and created again):
          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_;
          }

Note:
Because gcc (and possibly other compilers) support covariant returns only recently, the return type should remain 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.

Parameters:
session Database session to use.
Returns:
true in case of success, else false.

Reimplemented from OSB_LIB::PersProductItem.

bool OSB_LIB::PersResource::delPersResource ( const OSB_DB::Session session  )  [protected]

Delete a pers. resource from the database.

Parameters:
session Database session to use.
Returns:
true if the pers. resource was found and deleted from the database, else false.
Exceptions:
OsbException if no resource is assigned.

bool OSB_LIB::PersResource::insPersResource ( const OSB_DB::Session session  )  [protected]

Insert a pers. resource to the database.

Parameters:
session Database session to use.
Returns:
true if the pers. resource item was updated in the database, else false.
Exceptions:
OsbException if no resource is assigned.
The assigned resource will be automatically created if it does not exist in the database.
The function uses a OSB_DB::PersResourceGw to maintain the link between the pers. item and the subscribed resource.

virtual Resource* OSB_LIB::PersResource::oldResource (  )  [private, pure virtual]

Non-const access to the previous assigned resource.

Returns:
A pointer to the previous assigned resource. It is 0 if no old resource is assigned.

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.

Returns:
A pointer to the old assigned resource, it is 0 if no old resource is assigned.

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.

Parameters:
session Database session to use.
Returns:
true in case of success, else false.
Exceptions:
OsbException if no old resource exists.
OsbException if no new resource is assigned.
See documentation of base class for more detail.

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.

Parameters:
session Database session to use.
Exceptions:
OsbException Resource type specific exceptions from Resource::read().
Returns:
true if the pers. resource item was read from the database, else false.

virtual Resource* OSB_LIB::PersResource::resource (  )  [private, pure virtual]

Non-const access to the assigned resource.

Returns:
A pointer to the assigned resource. It is 0 if no resource is assigned.

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.

Returns:
A pointer to the assigned resource, it is 0 if no resource is assigned.

Implemented in OSB_LIB::PersAn, OSB_LIB::PersCallingCard, OSB_LIB::PersE164Item, OSB_LIB::PersIpGroup, and OSB_LIB::PersTrunk.

bool OSB_LIB::PersResource::resourceAssigned (  )  const

Resource assigned to the pers. resource?

Returns:
true if a resource is assigned, else false.
The implementation is:
          return (0 != resource());

Id<Resource> OSB_LIB::PersResource::resourceId (  )  const

The id of the assigned resource.

Returns:
The object id of the assigned resource. It is not set if no resource is assigned.


The documentation for this class was generated from the following file:
Generated on Sat Sep 2 14:12:57 2006 for OSB Library by  doxygen 1.4.7