OSB_LIB::AnCList Class Reference

Collaboration diagram for OSB_LIB::AnCList:

Collaboration graph
[legend]
List of all members.

Detailed Description

Manager for associate list and contract list.

Definition at line 254 of file anclist.h.

Public Types

Public Member Functions

Search functions:
Associate object list maintenance.
Contract object list maintenance
Support for pers. products:

Private Types

Private Member Functions

Private Attributes

Friends

Classes


Member Typedef Documentation

typedef std::set<Associate::Oid> OSB_LIB::AnCList::AssociateIds [private]

STL set of associate object ids.

Definition at line 259 of file anclist.h.

typedef std::map< Id<Contract>, Contract> OSB_LIB::AnCList::ContractMap

STL container type used to store the object.

Definition at line 294 of file anclist.h.

typedef std::map< Id<PersProduct>, Id<Contract> > OSB_LIB::AnCList::PersProductMap

Map pers. product id -> contract id.

Definition at line 296 of file anclist.h.


Constructor & Destructor Documentation

OSB_LIB::AnCList::AnCList (  )  [inline]

Default constructor.

Definition at line 300 of file anclist.h.

OSB_LIB::AnCList::AnCList ( const AnCList rhs  ) 

Copy constructor: reset the pointer in associate.

OSB_LIB::AnCList::~AnCList (  ) 

Destructor: clear the pointer in associate.


Member Function Documentation

Associate* OSB_LIB::AnCList::associate ( const Associate::Oid asId  ) 

Find associate for given oid from associate list.

Parameters:
asId Object id of associate.
Returns:
Pointer to associate if found,
else 0.

const AssociateList& OSB_LIB::AnCList::associateList (  )  const [inline]

Get all loaded associates.

Definition at line 310 of file anclist.h.

References aList_.

Contract* OSB_LIB::AnCList::contract ( const Contract::Oid coId  ) 

Get a writable contract for given oid from contract list.

Parameters:
coId Object id of the contract.
Returns:
Pointer to contract if found,
else 0.

const ContractMap& OSB_LIB::AnCList::contractMap (  )  const [inline]

Get all loaded contracts.

Definition at line 316 of file anclist.h.

References cMap_.

bool OSB_LIB::AnCList::create ( OSB_DB::Session session,
const Associate::Oid owner,
Contract contract 
)

Create a contract in the database.

Parameters:
session Database session to use.
owner Associate that owns the contract.
contract Contract to create.
Returns:
True if it is successful.

bool OSB_LIB::AnCList::create ( OSB_DB::Session session,
Associate assoc 
)

Add an associate.

Create an assoicate entry to the database and add it to the object list. Session will be committed if successful.

Parameters:
session Database session to use.
assoc Associate to be added.
Returns:
true if successful, else false.

bool OSB_LIB::AnCList::delAssoc ( const OSB_DB::Session session,
const Associate::Oid  asId 
) [private]

Delete the associate and all its children and contracts.

Parameters:
session Database session to use.
asId Object id of associate to delete.
Returns:
True if it is successful.
Exceptions:
OsbException if the associate is not found.
OsbException if a contract of the associate is not found.
Deletes all contracts of the associate and calls itself recursively for each of the associate's children.

Reads any missing associate or contract from the database and throws it this fails.

void OSB_LIB::AnCList::erase ( const Contract::Oid  coId  )  [private]

Erase contract from the list.

Parameters:
coId Id of the contract to erase.
The function removes the pers. products of the contract from ppMap_ and the calls erase on cMap_.
It should only be called by the contract's owner, who is responsible to deal with the erased contract.

const Contract* OSB_LIB::AnCList::findContract ( const Contract::Oid coId  )  const

Find contract for given oid from contract list.

Parameters:
coId Object id of the contract.
Returns:
Pointer to contract if found,
else 0.

Associate& OSB_LIB::AnCList::getAssociate ( const Associate::Oid asId  ) 

Find associate for given oid from associate list.

Parameters:
asId Object id of associate.
Returns:
Ref to the found associate.
Exceptions:
OsbException if the associate can not be found.
  • object not found.

Contract& OSB_LIB::AnCList::getContract ( const Contract::Oid coId  ) 

Find contract for given oid from contract list.

Parameters:
coId Object id of the contract.
Returns:
Ref to the found contract.
Exceptions:
OsbException if the contract is not found.

const Contract& OSB_LIB::AnCList::getContract ( const Contract::Oid coId  )  const

Find contract for given oid from contract list.

Parameters:
coId Object id of the contract.
Returns:
Ref to the found contract.
Exceptions:
OsbException if the contract is not found.

void OSB_LIB::AnCList::insert ( const Contract co  )  [private]

Insert a contract into the list.

Parameters:
co Contract to add.
Adds the contract to cMap_ and maintains ppMap_ accordingly. An that exists in cMap_ it is first erased.

AnCList& OSB_LIB::AnCList::operator= ( const AnCList rhs  ) 

Assignment: reset the pointer in associate.

PersProduct* OSB_LIB::AnCList::persProduct ( const Id< PersProduct > &  ppId  ) 

Find a pers. product by its object id.

Parameters:
ppId Object id of the pers. product.
Returns:
Pointer to pers. product if found,
else 0.

void OSB_LIB::AnCList::read ( const OSB_DB::Session session,
const AssociateIds idList 
) [private]

Read a list of associates from the database.

Parameters:
session Database session to use.
idList List with associate ids to read.
Calls read(const OSB_DB::Session&, const Associate::Oid) for each entry in idList.

Note:
The function is private because non-existing associates are silently skipped.

PersProduct* OSB_LIB::AnCList::read ( const OSB_DB::Session session,
const Id< PersProduct ppId 
)

Read a pers. product from the database.

Parameters:
session Database session to use.
ppId Object id of the pers. product to read.
Returns:
The pointer to pers. product, it is never 0.
Exceptions:
PpReadFailed if the the pers. product does not exist in the database.
ContractReadFailed if the contract of the pers. product can not be read.
OsbException if the pers. product is not found within its contract.
If ppId is not found in ppMap_ the contract of the pers. product is read from the database.

Note:
We need a copy for ppId because the related pers. product is possibly deleted.

Contract* OSB_LIB::AnCList::read ( const OSB_DB::Session session,
const Contract::Oid  coId 
)

Read contract from the database.

Parameters:
session Database session to use.
coId Object id of the contract to read.
Returns:
The pointer to the contract in cMap_, it is never 0.
Exceptions:
ContractReadFailed if the contract can not be read from the database.
Reads the contract from the database and stores it in cMap_.

Note:
We need a copy for coId because the related contract is possibly deleted.

Associate* OSB_LIB::AnCList::read ( const OSB_DB::Session session,
const Associate::Oid  asId 
)

Read an associate from the database.

Parameters:
session Database session to use.
asId Object id of the associate to read.
Returns:
The pointer to the associate in aList_, it is never 0.
Exceptions:
AssocReadFailed if the associate can not be read from the database.
Reads the associate and all its contract from the database and stores them in aList_ and cMap_.

Caller must keep in mind that the children of the associate are not read from the database, thus a subsequent call to getAssociate() with the id of one of the associate's childs will fail.

Note:
We need a copy for asId because the related associate is possibly deleted.

void OSB_LIB::AnCList::refresh ( const OSB_DB::Session session  ) 

Refresh AnCList list from the database.

Parameters:
session Database session to use.

void OSB_LIB::AnCList::remove ( OSB_DB::Session session,
const Contract::Oid  coId 
)

Delete a contract from the database.

Parameters:
session Database session to use.
coId Object id of the contract to delete.

bool OSB_LIB::AnCList::remove ( OSB_DB::Session session,
const Associate::Oid  asId 
)

Delete an associate.

Delete an entry from the database, also delete it from the object list. Session will be committed if successful.

Parameters:
session Database session to use.
asId Object id of associate to be deleted.
Returns:
true if successful, else false.
Exceptions:
OsbException if the associate is not found in the list.

bool OSB_LIB::AnCList::replace ( const Contract contract  ) 

Replace a contract in the A&C list.

Parameters:
contract Contract to replace.
Replaces the contract if its object version is not less then the one of the current contract in the list.

Attention:
The function should be called only after a modification was successfully saved.

bool OSB_LIB::AnCList::replace ( const Associate assoc  ) 

Replace an associate in the A&C list.

Parameters:
assoc Associate to replace.
Replaces the associate if its object version is not less then the one of the associate currently in the list.

Replaces the associate if its object version is not less then the one of the current associate in the list.

Attention:
The function should be called only after a modification was successfully saved.

long OSB_LIB::AnCList::search ( const OSB_DB::Session session,
AnCFilter filter 
)

Search associates and contracts.

Parameters:
session Database session to use.
filter Filter to use.
Returns:
Number of associates loaded.
Reads all matching associates and contracts from database.

void OSB_LIB::AnCList::swap ( AnCList rhs  )  [private]

Swap the associate and contract list.


Friends And Related Function Documentation

friend class Associate [friend]

Provide access to remove(const Contract::Oid).

Definition at line 256 of file anclist.h.


Member Data Documentation

AssociateList OSB_LIB::AnCList::aList_ [private]

List of available associates.

Definition at line 658 of file anclist.h.

Referenced by associateList().

ContractMap OSB_LIB::AnCList::cMap_ [private]

List of available contracts.

Definition at line 660 of file anclist.h.

Referenced by contractMap().

PersProductMap OSB_LIB::AnCList::ppMap_ [private]

Map pers. product -> contract.

Definition at line 662 of file anclist.h.


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