OSB_LIB::PersCredit Class Reference

Inheritance diagram for OSB_LIB::PersCredit:

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

Collaboration graph
[legend]
List of all members.

Detailed Description

Credit as personalized product item.

Remarks:
Copy constructor by compiler.

Definition at line 68 of file credit.h.

Public Types

Public Member Functions

Static Public Attributes

Private Member Functions

Database operations

Private Attributes

Friends


Member Typedef Documentation

typedef std::auto_ptr<PersCredit> OSB_LIB::PersCredit::AutoPtr

Short-cut for an auto pointer.

For details see quality manual, implementation patterns: Virtual copy construction.

Reimplemented from OSB_LIB::PersProductItem.

Definition at line 76 of file credit.h.


Constructor & Destructor Documentation

OSB_LIB::PersCredit::PersCredit ( const Oid oid = Oid(),
const Money credit = Money() 
) [inline, explicit]

Default constructor with optional object id and credit.

Definition at line 80 of file credit.h.

OSB_LIB::PersCredit::PersCredit ( const Money credit  )  [inline, explicit]

Constructor with credit.

Definition at line 89 of file credit.h.


Member Function Documentation

bool OSB_LIB::PersCredit::add ( const OSB_DB::Session session,
const Money money,
long  objVs,
bool  uptodate 
)

Top up the credit and update it in the database.

This function based on the same currency code, otherwise it will throw OsbException.
The caller should read data from database and then lock it before using this function.

Parameters:
session Oracle session.
money Money to be added.
objVs Old Object version. It will be updated to the new one.
uptodate Return true if the object version is uptodate.
Exceptions:
OsbException It throws OsbException(169) if currency code mismatch currency code.
Returns:
Return true if credit updated successfully.

virtual bool OSB_LIB::PersCredit::canConfig (  )  const [virtual]

The configuration type of credit item.

Implements OSB_LIB::PersProductItem.

AutoPtr OSB_LIB::PersCredit::clone (  )  const

Virtual copy construction.

For details see quality manual, implementation patterns.

Reimplemented from OSB_LIB::PersProductItem.

PersProductItem* OSB_LIB::PersCredit::clone_ (  )  const [private, virtual]

Internal virtual copy constructor.

For details see quality manual, implementation patterns.

Implements OSB_LIB::PersProductItem.

const Money& OSB_LIB::PersCredit::credit (  )  const [inline]

Access credit of credit item.

Definition at line 117 of file credit.h.

References credit_.

bool OSB_LIB::PersCredit::deduct ( const OSB_DB::Session session,
const Money money,
long  objVs,
bool  uptodate 
)

Deduct the credit and update it in the database.

This function based on the same currency code, otherwise it will throw OsbException.
The caller should read data from database and then lock it before using this function.

Parameters:
session Oracle session.
money Money to be deducted.
objVs Old Object version. It will be updated to the new one.
uptodate Return true if the object version is uptodate.
Exceptions:
OsbException It throws OsbException(169) if currency code mismatch currency code.
Returns:
Return true if credit updated successfully.

bool OSB_LIB::PersCredit::delSpecific ( const OSB_DB::Session session  )  [private, virtual]

Delete a personalized credit from the database.

Parameters:
session Database session to use, transactions are not commited.
Returns:
True if the item was found and deleted from the database, else false.

Implements OSB_LIB::PersProductItem.

bool OSB_LIB::PersCredit::insSpecific ( const OSB_DB::Session session  )  [private, virtual]

Insert a personalized credit to the database.

Parameters:
session Database session to use, transactions are not commited.
Returns:
True if the item was inserted into the database.

Implements OSB_LIB::PersProductItem.

bool OSB_LIB::PersCredit::lock ( const OSB_DB::Session session  ) 

Lock the credit in the database.

Lock() does not commit. The lock applies to all sessions. If the locker commits, it can also be used across multiple transactions. In this case, any database session can later release the lock.
If the locker does not commit, all other sessions see the lock as held.
In the meantime, only the session that set the lock can release it by calling unlock(). The effect of this unlock is only visible for this session (i.e., within the same transaction, it can subsequently set the lock again).
In any case, the resource is only seen as released from another session after the transaction which unlocked it is completed.
There is no blocking mode for lock(). It always works in non-blocking mode.

Parameters:
session Oracle session.
Returns:
True if the lock was acquired.
False if the lock is already held (or the credit does not exist in the database).

virtual std::string OSB_LIB::PersCredit::personalization (  )  const [virtual]

Personalization of pers credit.

Provide the personalization of a CreditItem as string. The content is the credit.

Returns:
Credit of credit item as a string.

Implements OSB_LIB::PersProductItem.

bool OSB_LIB::PersCredit::readSpecific ( const OSB_DB::Session session  )  [private, virtual]

Read the specific credit from the database.

Parameters:
session Oracle session.
Returns:
True if success.

Implements OSB_LIB::PersProductItem.

Type OSB_LIB::PersCredit::type (  )  const [virtual]

Get the product item type id.

Implements OSB_LIB::ProductItemBase.

bool OSB_LIB::PersCredit::unlock ( const OSB_DB::Session session,
bool  nowait 
)

Unlock the credit in the database.

Unlock() does not commit. However, other sessions see the lock as released only after the transaction which unlocked it is completed.
Calling unlock() for a lock which is not held has no effect.
If unlock() is called in blocking mode from a session other than that which acquired the lock and before the locker commits, then unlock will block until the locker completes its transaction. If unlock() is called in non-blocking mode, it returns false in this case.

Parameters:
session Oracle session.
nowait If the argument is false (blocking mode) then unlock() waits for the database resource to be released if it is busy.
If it is true (non-blocking mode), unlock() immediately returns false if the lock could not be released because the database resource was busy.
Returns:
True if the lock was not set or was set and successfully released (or the credit does not exist in the database).
False if unlock() was called in non-blocking mode and the lock could not be released.

bool OSB_LIB::PersCredit::updSpecific ( const OSB_DB::Session session  )  [private, virtual]

Update a personalized credit in the database.

Parameters:
session Database session to use, transactions are not commited.
Returns:
True if the item was found and updated in the database, else false.

Implements OSB_LIB::PersProductItem.


Friends And Related Function Documentation

friend class OSB_DB::PersCreditGw [friend]

Allow the gateway to set the data members.

Definition at line 70 of file credit.h.


Member Data Documentation

Money OSB_LIB::PersCredit::credit_ [private]

The current credit.

Definition at line 275 of file credit.h.

Referenced by credit().

const Type OSB_LIB::PersCredit::type_ [static]

The type of this product item: PiType::piCredit.

Definition at line 73 of file credit.h.


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