TAO_Service_Offer_Iterator< LOCK_TYPE > Class Template Reference

TAO_Service_Offer_Iterator iterates over the set of exported offers for a given type. Handily, it takes care of all the necessary locking, acquiring them in the constructor, and releasing them in the destructor. More...

#include <Offer_Database.h>

Collaboration diagram for TAO_Service_Offer_Iterator< LOCK_TYPE >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef TAO_Offer_Database<
LOCK_TYPE > 
Offer_Database

Public Member Functions

 TAO_Service_Offer_Iterator (const char *type, TAO_Offer_Database< LOCK_TYPE > &offer_database)
 ~TAO_Service_Offer_Iterator (void)
 Release all the locks acquired.

int has_more_offers (void)
 Returns 1 if there are more offers, 0 otherwise.

CosTrading::OfferId get_id (void)
 Get the id for the current offer.

CosTrading::Offerget_offer (void)
 Returns the next offer in the series.

void next_offer (void)
 Advances the iterator 1.


Private Attributes

TAO_Offer_Database< LOCK_TYPE > & stm_
 Lock the top_level map.

LOCK_TYPE * lock_
 Lock for the internal map.

TAO_Offer_Map::iteratoroffer_iter_
 Iterator over the actual offer map.

const char * type_
 The name of the type. Used for constructing offer ids.


Detailed Description

template<class LOCK_TYPE>
class TAO_Service_Offer_Iterator< LOCK_TYPE >

TAO_Service_Offer_Iterator iterates over the set of exported offers for a given type. Handily, it takes care of all the necessary locking, acquiring them in the constructor, and releasing them in the destructor.

Definition at line 164 of file Offer_Database.h.


Member Typedef Documentation

template<class LOCK_TYPE>
typedef TAO_Offer_Database<LOCK_TYPE> TAO_Service_Offer_Iterator< LOCK_TYPE >::Offer_Database
 

Definition at line 168 of file Offer_Database.h.


Constructor & Destructor Documentation

template<class LOCK_TYPE>
TAO_Service_Offer_Iterator< LOCK_TYPE >::TAO_Service_Offer_Iterator const char *  type,
TAO_Offer_Database< LOCK_TYPE > &  offer_database
 

Definition at line 321 of file Offer_Database.cpp.

References ACE_NEW, TAO_Service_Offer_Iterator< LOCK_TYPE >::offer_iter_, and TAO_Service_Offer_Iterator< LOCK_TYPE >::stm_.

00323   : stm_ (offer_database),
00324     lock_ (0),
00325     offer_iter_ (0),
00326     type_ (type)
00327 {
00328   CORBA::String_var service_type (type);
00329 
00330   if (this->stm_.db_lock_.acquire_read () == -1)
00331     return;
00332 
00333   ACE_TYPENAME TAO_Offer_Database<LOCK_TYPE>::Offer_Map_Entry* entry = 0;
00334   if (this->stm_.offer_db_.find (service_type, entry) == -1)
00335     return;
00336   else
00337     {
00338       this->lock_ = &entry->lock_;
00339       if (this->lock_->acquire_read () == -1)
00340         return;
00341 
00342       ACE_NEW (offer_iter_,
00343                TAO_Offer_Map::iterator (*entry->offer_map_));
00344     }
00345 }

template<class LOCK_TYPE>
TAO_Service_Offer_Iterator< LOCK_TYPE >::~TAO_Service_Offer_Iterator void   ) 
 

Release all the locks acquired.

Definition at line 348 of file Offer_Database.cpp.

References TAO_Service_Offer_Iterator< LOCK_TYPE >::offer_iter_, and TAO_Service_Offer_Iterator< LOCK_TYPE >::stm_.

00349 {
00350   this->stm_.db_lock_.release ();
00351 
00352   if (this->lock_ != 0)
00353     {
00354       this->lock_->release ();
00355       delete this->offer_iter_;
00356     }
00357 }


Member Function Documentation

template<class LOCK_TYPE>
CosTrading::OfferId TAO_Service_Offer_Iterator< LOCK_TYPE >::get_id void   ) 
 

Get the id for the current offer.

Definition at line 360 of file Offer_Database.cpp.

References TAO_Offer_Database< LOCK_TYPE >::generate_offer_id(), and TAO_Service_Offer_Iterator< LOCK_TYPE >::offer_iter_.

00361 {
00362   return (this->offer_iter_ != 0)
00363     ? TAO_Offer_Database<LOCK_TYPE>::generate_offer_id (this->type_, (**this->offer_iter_).ext_id_)
00364     : 0;
00365 }

template<class LOCK_TYPE>
CosTrading::Offer * TAO_Service_Offer_Iterator< LOCK_TYPE >::get_offer void   ) 
 

Returns the next offer in the series.

Definition at line 375 of file Offer_Database.cpp.

References TAO_Service_Offer_Iterator< LOCK_TYPE >::offer_iter_.

00376 {
00377   return (this->offer_iter_ != 0) ? (**this->offer_iter_).int_id_ : 0;
00378 }

template<class LOCK_TYPE>
int TAO_Service_Offer_Iterator< LOCK_TYPE >::has_more_offers void   ) 
 

Returns 1 if there are more offers, 0 otherwise.

Definition at line 368 of file Offer_Database.cpp.

References TAO_Service_Offer_Iterator< LOCK_TYPE >::offer_iter_.

00369 {
00370   return (this->offer_iter_ != 0) ? ! this->offer_iter_->done () : 0;
00371 }

template<class LOCK_TYPE>
void TAO_Service_Offer_Iterator< LOCK_TYPE >::next_offer void   ) 
 

Advances the iterator 1.

Definition at line 381 of file Offer_Database.cpp.

References TAO_Service_Offer_Iterator< LOCK_TYPE >::offer_iter_.

00382 {
00383   if (this->offer_iter_ != 0)
00384     this->offer_iter_->advance ();
00385 }


Member Data Documentation

template<class LOCK_TYPE>
LOCK_TYPE* TAO_Service_Offer_Iterator< LOCK_TYPE >::lock_ [private]
 

Lock for the internal map.

Definition at line 195 of file Offer_Database.h.

template<class LOCK_TYPE>
TAO_Offer_Map::iterator* TAO_Service_Offer_Iterator< LOCK_TYPE >::offer_iter_ [private]
 

Iterator over the actual offer map.

Definition at line 198 of file Offer_Database.h.

Referenced by TAO_Service_Offer_Iterator< LOCK_TYPE >::get_id(), TAO_Service_Offer_Iterator< LOCK_TYPE >::get_offer(), TAO_Service_Offer_Iterator< LOCK_TYPE >::has_more_offers(), TAO_Service_Offer_Iterator< LOCK_TYPE >::next_offer(), TAO_Service_Offer_Iterator< LOCK_TYPE >::TAO_Service_Offer_Iterator(), and TAO_Service_Offer_Iterator< LOCK_TYPE >::~TAO_Service_Offer_Iterator().

template<class LOCK_TYPE>
TAO_Offer_Database<LOCK_TYPE>& TAO_Service_Offer_Iterator< LOCK_TYPE >::stm_ [private]
 

Lock the top_level map.

Definition at line 192 of file Offer_Database.h.

Referenced by TAO_Service_Offer_Iterator< LOCK_TYPE >::TAO_Service_Offer_Iterator(), and TAO_Service_Offer_Iterator< LOCK_TYPE >::~TAO_Service_Offer_Iterator().

template<class LOCK_TYPE>
const char* TAO_Service_Offer_Iterator< LOCK_TYPE >::type_ [private]
 

The name of the type. Used for constructing offer ids.

Definition at line 201 of file Offer_Database.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 14:01:13 2006 for TAO_CosTrader by doxygen 1.3.6