OSB_LIB::Resource Class Reference

Inheritance diagram for OSB_LIB::Resource:

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

Collaboration graph
[legend]
List of all members.

Detailed Description

Resources: Network access and user identification.

The OSB rating process uses resources to identify the end user of the network and the services available for the user.

Technically speaking the requirement is as follows:
It must be possible to determine the personalized product that owns the resource at a given time. Then it is the responsibility of the personalized product to provide the information needed for rating: tariff system, services, credits, ... .
The link between a resource and a pers. product is established by PersItem, the base class of PersResource.

All "real-life" resources are derived from this abstract base that defines the functionality needed for rating.

Definition at line 87 of file resource.h.

Public Types

Public Member Functions

Construction and destruction:
All constructors initialize prepaid_ with false and status_ with rsCreated.

Read access to data members:
Database operations:
All concrete classes derived from Resource have to support the database operations read, insert, update and remove.
All methods are non-const: In general the object id or the object version will be modified during I/O operations.
All methods take a const session as argument, thus indicating that transactions will not be committed or rolled back.

Non-leaf classes derived from Resource must not implement these pure virtual functions.

Protected Member Functions

Change the status of the resource:
The members of this group support PersResource in changing the status.
In order to save the changes in the database, the member updStatus() must be called.
Derived class can overwrite the default implemenation.

Base class support for database operations:

Static Protected Member Functions

Protected Attributes

Private Attributes

Friends


Member Typedef Documentation

typedef ResourceNumber OSB_LIB::Resource::Number

Short-hand for the resource number.

Definition at line 107 of file resource.h.

typedef Id<Resource> OSB_LIB::Resource::Oid

Typesafe unique identifier, database link.

Definition at line 103 of file resource.h.

typedef ResourceType OSB_LIB::Resource::Type

Short-hand for the resource type.

Definition at line 105 of file resource.h.


Member Enumeration Documentation

enum OSB_LIB::Resource::Status

The status of resource.

Customer care and other on-line application need to assign a resource to a pers. product if it contains a ResourceItem.
A resource is available if its resource status is either rsAvailable OR rsQuarantine and quarantineEnd_ is less than the current system date.

Remarks:
Additional resource status may be added in future to support the purchase order process of resources.
Enumerator:
rsUnknown  Unknown resource status.
rsCreated  Resource is created and reserved,
this is the default status.
rsAvailable  Resource is available.
rsAssigned  Resource is assigned.
rsQuarantine  Resource is in quarantine time. For this status quarantineEnd_ stores the end of the quarantine period (not included).
rsDeactivated  Resource is deactivated and can not be used again.
rsLinked  The resource is linked to a device which determines its status.

Definition at line 121 of file resource.h.


Constructor & Destructor Documentation

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

Default constructor with optional object id.

OSB_LIB::Resource::Resource ( const Number rn,
const Id< Network > &  nw = IdNetwork >() 
) [explicit]

Constructor with resource number and optional network.

Parameters:
rn Resource number.
nw Id of the network.
Exceptions:
OsbException if rn is empty or too long.

OSB_LIB::Resource::Resource ( const Number rn,
const Id2< NetworkElement > &  ne 
)

Constructor with resource number and network element.

Parameters:
rn Resource number.
ne Id of the network element.
Exceptions:
OsbException if rn is empty or too long.

virtual OSB_LIB::Resource::~Resource (  )  [virtual]

Virtual destructor.

OSB_LIB::Resource::Resource ( const Resource rhs  )  [protected]

Copying for derived classes only.


Member Function Documentation

const Date& OSB_LIB::Resource::assigned (  )  const

Date of first time being assigned.

bool OSB_LIB::Resource::assignResource ( const OSB_DB::Session session  )  [protected]

Handle the assigned resource: set status to assigned.

The resource will be automatically created if it does not exist in the database.

Parameters:
session database session.
Exceptions:
OsbException from lock().
OsbException if the resource is not available (see isAvailable()).
Returns:
true if the resource was set to assigned into the database, else false.

bool OSB_LIB::Resource::canDel (  )  const

This resource can be remove?

Returns:
true if the resource can be remove,
else false.
For the common rule, a resource can not be removed once it is assigned.

virtual bool OSB_LIB::Resource::canUpd (  )  const [virtual]

This resource can be update?

Returns:
true if the resource can be updated, else false.
For the common rule, resources can be updated only if it is not assigned.
The concrete class which is the exception needs to overwrite the method.

Reimplemented in OSB_LIB::Ip4Address.

bool OSB_LIB::Resource::deassignResource ( const OSB_DB::Session session  )  [protected]

Handle the deassigned resource: set status to deassigned.

Parameters:
session database session.
Exceptions:
OsbException if the object has been changed or deleted.
Returns:
true if the resource was set to deassigned in the database, else false.

const Id<Device> OSB_LIB::Resource::deviceId (  )  const

The device to which the resource is linked.

It is not set if the resource is not linked to a device.

OSB_LIB::Status OSB_LIB::Resource::getPersResourceStatus ( const OSB_DB::Session session,
const DateTime ts = DateTime::now() 
) const [protected]

Determine the status of the pers. node of the resource.

Parameters:
session Database session to use.
ts Date and time for which the pers. product node should be determined. Default is current date time.
Exceptions:
OsbException if more than one assignment of the resource for ts exists.
Returns:
The effective status of the pers. node that has (had) the resource assigned at ts.

static void OSB_LIB::Resource::handleObjectStatus ( ObjectStatus  os,
const Oid id 
) [static, protected]

Evalute the object status of a resource.

Parameters:
os Object status to evaluate.
id The id of the resource for which os is valid.
Exceptions:
ObjectDeleted 
ObjectModified 
ObjectBusy if noWait is true and the resource is locked by another database session.

void OSB_LIB::Resource::incObjVs ( const OSB_DB::Session session  )  [protected]

Increment the object version in the database.

Parameters:
session Database session to use.
Exceptions:
OsbException (internal error) if the update of the object version in the database fails.
The function should be used only after a successful call of a lock() function.

bool OSB_LIB::Resource::insBase ( const OSB_DB::Session session  )  [protected]

Insert common resource data to the database.

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

virtual bool OSB_LIB::Resource::insert ( const OSB_DB::Session session  )  [pure virtual]

Insert the resource into the database.

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

Implemented in OSB_LIB::AccessNumber, OSB_LIB::CallingCard, OSB_LIB::E164Resource, OSB_LIB::ImsiResource, OSB_LIB::Ip4Address, OSB_LIB::IpGroup, and OSB_LIB::TrunkResource.

virtual bool OSB_LIB::Resource::isAvailable (  )  const [virtual]

Check if the resource is available.

Returns:
true if the resource available, else false.
Note that the function is virtual.
This default implementation returns true if the status is rsAvailable or rsQuarantine and the quarantine time has expired.

Reimplemented in OSB_LIB::Ip4Address.

bool OSB_LIB::Resource::isPrepaid (  )  const

Prepaid resource?

Returns:
true if the resource is a prepaid resource,
else false.

void OSB_LIB::Resource::lock ( const OSB_DB::Session session,
bool  noWait 
) const [protected]

Lock a resource in the database.

Parameters:
session Database session to use.
noWait Don't wait for database locks?
Exceptions:
OsbException from handleObjectStatus().

const Id2<NetworkElement>& OSB_LIB::Resource::neId (  )  const

Network element id of the resource.

Returns:
The id of the network element to which the resource belongs.
It is not set if the resource is not assigned to a network element.

const Id<Network> OSB_LIB::Resource::nwId (  )  const

Network id of the resource.

Returns:
The id of the network to which the resource belongs.
It is not set if the resource is not assigned to a network.

long OSB_LIB::Resource::objVs (  )  const

Object version as in NETWORK_RESOURCE.

const Oid& OSB_LIB::Resource::oid (  )  const

Resource id as in NETWORK_RESOURCE.

Resource& OSB_LIB::Resource::operator= ( const Resource rhs  )  [protected]

Assignment for derived classes only.

const Id<InventoryPool> OSB_LIB::Resource::poolId (  )  const

The inventory pool of the resource.

It is not set if the resource was not assigned to a pool.

const Date& OSB_LIB::Resource::quarantineEnd (  )  const

End of quarantine period.

Returns:
Date if the resource status is `rsQuarantine',
else Date::notSet() in all other cases.

virtual bool OSB_LIB::Resource::read ( const OSB_DB::Session session  )  [pure virtual]

Read the resource from the database.

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

Implemented in OSB_LIB::AccessNumber, OSB_LIB::CallingCard, OSB_LIB::E164Resource, OSB_LIB::ImsiResource, OSB_LIB::Ip4Address, OSB_LIB::IpGroup, and OSB_LIB::TrunkResource.

bool OSB_LIB::Resource::readBase ( const OSB_DB::Session session  )  [protected]

Read common resource data from the database.

Parameters:
session Database session to use.
Returns:
true in case of success, else false.
Derived classes typically use the function as follows:
          class TrunkResource : public Resource {
              friend class Gateway;
          public:
              bool read(const Session& session)
              {
                   bool rc = readBase(session);
                   if (rc) {
                       Gateway gw(session);
                       rc = gw.fetch(*this);
                   }
                   return rc;
              }
          };

virtual bool OSB_LIB::Resource::remove ( const OSB_DB::Session session  )  [pure virtual]

Delete the resource from the database.

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

Implemented in OSB_LIB::AccessNumber, OSB_LIB::CallingCard, OSB_LIB::E164Resource, OSB_LIB::ImsiResource, OSB_LIB::Ip4Address, OSB_LIB::IpGroup, and OSB_LIB::TrunkResource.

bool OSB_LIB::Resource::removeBase ( const OSB_DB::Session session,
bool  isLocked 
) [protected]

Delete common resource data from the database.

Parameters:
session Database session to use.
isLocked Flag if the resource is already locked in the database.
Exceptions:
OsbException the resource is already assigned.
  • the object has been changed or deleted
  • it is assigned already.
Returns:
true in case of success, else false.
Derived classes typically use the function as follows:
          class TrunkResource : public Resource {
              friend class Gateway;
          public:
              bool remove(const Session& session)
              {
                   lock(session, false);
                   Gateway gw(session);
                   bool rc = gw.remove(*this);
                   if (rc) {
                       rc = removeBase(session, true);
                   }
                   return rc;
              }
          };

const Number& OSB_LIB::Resource::resourceNumber (  )  const

Read access to unique resource number.

Returns:
Fully qualified resource number: The identification of the network's end user relies on this value.
Remarks:
In case of a E164 phone number, e.g., the resource number will include the country and national destination code.
For a calling card user, it will be the PIN.

virtual void OSB_LIB::Resource::setAssigned (  )  [protected, virtual]

Set the status to assigned.

Sets the status of the resource to rsAssigned and clears quarantineEnd_. The assigned_ will be set to current date if it is null.

virtual void OSB_LIB::Resource::setAvailable (  )  [protected, virtual]

Set the status to available.

Sets the status of the resource to rsAvailable and clears quarantineEnd_.

virtual void OSB_LIB::Resource::setDeassigned (  )  [protected, virtual]

Set the status to deassigned.

Sets the status of the resource to rsQuarantine and clears quarantineEnd_. If later the status is updated in the database (by calling updStatus), the status and the quarantine end are set as defined by RESOURCE_TYPE.

void OSB_LIB::Resource::setDevice ( const Id< Device > &  deviceId  ) 

Set the device to which the resource is linked.

Parameters:
deviceId The id of the device.
Exceptions:
OsbException if the resource is already linked to a device.

void OSB_LIB::Resource::setPool ( const Id< InventoryPool > &  poolId  ) 

Set the inventory pool.

Parameters:
poolId The id of the new inventory pool.

virtual void OSB_LIB::Resource::setStatus ( const Status  newStatus  )  [virtual]

Set the resource status.

Parameters:
newStatus New status of the resource.
Exceptions:
OsbException if the current status is assigned.
OsbException if newStatus is assigned or quarantine.
Note:
The function is virtual, derived classes can override this default implementation.

const Status OSB_LIB::Resource::status (  )  const

Status of the resource.

virtual Type OSB_LIB::Resource::typeId (  )  const [pure virtual]

The type of the concrete resource.

Returns:
One of the values defined for Type, never rtUnknown.

Implemented in OSB_LIB::AccessNumber, OSB_LIB::CallingCard, OSB_LIB::E164Resource, OSB_LIB::ImsiResource, OSB_LIB::Ip4Address, OSB_LIB::IpGroup, and OSB_LIB::TrunkResource.

bool OSB_LIB::Resource::unassignResource ( const OSB_DB::Session session  )  [protected]

Handle the assigned resource: set status to unassigned.

Parameters:
session database session.
Exceptions:
OsbException if the object has been changed or deleted.
Returns:
true if the resource was set to unassigned into the database, else false.

void OSB_LIB::Resource::updAssigned ( const OSB_DB::Session session,
const DateTime firstAss 
) [protected]

Set the first assignment date in the database.

Parameters:
session Database session to use.
firstAss Date of the resource's first assignment.
Exceptions:
OsbException from lock().

virtual void OSB_LIB::Resource::updData ( const OSB_DB::Session session  )  [pure virtual]

Update the resource in the database.

Parameters:
session Database session to use.
Returns:
true in case of success, else false.
Exceptions:
OsbException from lock().
OsbException from incObjVs().

Implemented in OSB_LIB::AccessNumber, OSB_LIB::CallingCard, OSB_LIB::E164Resource, OSB_LIB::ImsiResource, OSB_LIB::Ip4Address, OSB_LIB::IpGroup, and OSB_LIB::TrunkResource.

void OSB_LIB::Resource::updDataBase ( const OSB_DB::Session session  )  [protected]

Update common resource data to the database.

Parameters:
session Database session to use.
Returns:
true in case of success, else false.
The function only update the prepaid flag and the inventory pool.

void OSB_LIB::Resource::updStatus ( const OSB_DB::Session session,
bool  isLocked 
)

Update the status of a resource in the database.

Parameters:
session Database session to use.
isLocked Flag if the resource is already locked in the database.
Exceptions:
OsbException from lock().
OsbException from incObjVs().


Friends And Related Function Documentation

friend class Device [friend]

Allow to set the device id.

Definition at line 100 of file resource.h.

friend class OSB_DB::ResourceGw [friend]

The gateway needs to set (and ev. read) private data members.

Definition at line 92 of file resource.h.

friend class PersResource [friend]

Allow a personalized resource to update the status in the database.

Definition at line 98 of file resource.h.


Member Data Documentation

Date OSB_LIB::Resource::assigned_ [private]

Date of first time being assigned.

Definition at line 659 of file resource.h.

Id<Device> OSB_LIB::Resource::deviceId_ [private]

The device to which the resource is linked.

Definition at line 662 of file resource.h.

Id2<NetworkElement> OSB_LIB::Resource::neId_ [protected]

Id of the network and network element.

The first part identifies the network of the resource, it is not set if the resource is not assigned to a specific network (note that this implies that the 2nd part is not set either).
The second part identifies the network element to which the resource belongs, it is not set if the resource is not assigned to a specific network element.

Definition at line 685 of file resource.h.

long OSB_LIB::Resource::objVs_ [private]

Object version.

Definition at line 648 of file resource.h.

Oid OSB_LIB::Resource::oid_ [private]

Unique object id, database link.

Definition at line 646 of file resource.h.

Id<InventoryPool> OSB_LIB::Resource::poolId_ [private]

The inventory pool of the resource.

Definition at line 664 of file resource.h.

bool OSB_LIB::Resource::prepaid_ [protected]

Flag if the resource is prepaid.

Definition at line 687 of file resource.h.

Date OSB_LIB::Resource::quarantineEnd_ [private]

End of quarantine period.

This member should be set if the resource status is rsQuarantine and Date::notSet() in all other cases.

Definition at line 657 of file resource.h.

Number OSB_LIB::Resource::resourceNumber_ [protected]

Unique resource number.

The resource number must be unique within a network element, a network or world-wide.

Definition at line 673 of file resource.h.

Status OSB_LIB::Resource::status_ [private]

Status of the resource.

Definition at line 650 of file resource.h.


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