diff options
author | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-04-07 17:14:20 +0000 |
---|---|---|
committer | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-04-07 17:14:20 +0000 |
commit | a0af4517dd908245d12ca05b4895033cecad4826 (patch) | |
tree | 3c1ff4952d51f56a09922786025f8760bcc13d09 /TAO/orbsvcs/orbsvcs/Trader/Offer_Database.cpp | |
parent | c42c7a935e6c79194b005e6b7fc7a7d92392c639 (diff) | |
download | ATCD-a0af4517dd908245d12ca05b4895033cecad4826.tar.gz |
ChangeLogTag:Wed Apr 7 12:03:33 1999 Carlos O'Ryan <coryan@cs.wustl.edu>
Diffstat (limited to 'TAO/orbsvcs/orbsvcs/Trader/Offer_Database.cpp')
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Trader/Offer_Database.cpp | 111 |
1 files changed, 55 insertions, 56 deletions
diff --git a/TAO/orbsvcs/orbsvcs/Trader/Offer_Database.cpp b/TAO/orbsvcs/orbsvcs/Trader/Offer_Database.cpp index caa2c2c2a3c..4aa178f59ac 100644 --- a/TAO/orbsvcs/orbsvcs/Trader/Offer_Database.cpp +++ b/TAO/orbsvcs/orbsvcs/Trader/Offer_Database.cpp @@ -22,12 +22,12 @@ TAO_Offer_Database<LOCK_TYPE>::~TAO_Offer_Database (void) type_iter++) { Offer_Map_Entry* offer_map_entry = (*type_iter).int_id_; - + { // Artificial scope, so the guard will release the lock before // we delete the lock along with the offer_map_entry. ACE_WRITE_GUARD (LOCK_TYPE, ace_mon, offer_map_entry->lock_); - + for (TAO_Offer_Map::iterator offer_iter (*offer_map_entry->offer_map_); ! offer_iter.done (); offer_iter++) @@ -47,13 +47,13 @@ TAO_Offer_Database<LOCK_TYPE>::~TAO_Offer_Database (void) template <class LOCK_TYPE> CosTrading::OfferId TAO_Offer_Database<LOCK_TYPE>:: insert_offer (const char* type, CosTrading::Offer* offer) -{ +{ CosTrading::OfferId return_value = 0; ACE_TYPENAME Offer_Database::ENTRY* database_entry = 0; - TAO_String_Hash_Key service_type (type); + TAO_String_Hash_Key service_type (type); ACE_READ_GUARD_RETURN (LOCK_TYPE, ace_mon, this->db_lock_, 0); - + if (this->offer_db_.find (service_type, database_entry) == -1) { // If there's no entry for the service type, create one. @@ -71,14 +71,14 @@ insert_offer (const char* type, CosTrading::Offer* offer) ACE_WRITE_GUARD_RETURN (LOCK_TYPE, ace_mon, this->db_lock_, 0); this->offer_db_.bind (service_type, new_offer_map_entry, database_entry); } - + if (this->db_lock_.acquire_read () == -1) return 0; } Offer_Map_Entry* offer_map_entry = database_entry->int_id_; ACE_WRITE_GUARD_RETURN (LOCK_TYPE, ace_mon2, offer_map_entry->lock_, 0); - + // Add the offer to the service offer table for this service type. offer_map_entry->offer_map_->bind (offer_map_entry->counter_, offer); return_value = this->generate_offer_id (type, offer_map_entry->counter_); @@ -92,11 +92,11 @@ TAO_Offer_Database<LOCK_TYPE>:: remove_offer (const char* type, CORBA::ULong id) { ACE_READ_GUARD_RETURN (LOCK_TYPE, ace_mon, this->db_lock_, -1); - + int return_value = -1; ACE_TYPENAME Offer_Database::ENTRY* db_entry = 0; - TAO_String_Hash_Key service_type (type); - + TAO_String_Hash_Key service_type (type); + if (this->offer_db_.find (service_type, db_entry) == 0) { CosTrading::Offer* offer = 0; @@ -104,7 +104,7 @@ remove_offer (const char* type, CORBA::ULong id) if (offer_map_entry->lock_.acquire_write () == -1) return -1; - + return_value = offer_map_entry->offer_map_->unbind (id, offer); delete offer; @@ -117,7 +117,7 @@ remove_offer (const char* type, CORBA::ULong id) else { // Promote the database lock. Will be released by - // guard. + // guard. if (this->db_lock_.acquire_write () == -1) return -1; @@ -132,7 +132,7 @@ remove_offer (const char* type, CORBA::ULong id) // Delete the database resources for this type. delete offer_map_entry->offer_map_; delete offer_map_entry; - } + } } else if (offer_map_entry->lock_.release () == -1) return -1; @@ -140,13 +140,13 @@ remove_offer (const char* type, CORBA::ULong id) return return_value; } - + template <class LOCK_TYPE> int TAO_Offer_Database<LOCK_TYPE>:: remove_offer (const CosTrading::OfferId offer_id, - CORBA::Environment& TAO_IN_ENV) + CORBA::Environment& TAO_IN_ENV) TAO_THROW_SPEC ((CosTrading::IllegalOfferId, - CosTrading::UnknownOfferId)) + CosTrading::UnknownOfferId)) { char* stype = 0; CORBA::ULong index; @@ -163,10 +163,10 @@ remove_offer (const CosTrading::OfferId offer_id, template <class LOCK_TYPE> CosTrading::Offer* TAO_Offer_Database<LOCK_TYPE>:: lookup_offer (const CosTrading::OfferId offer_id, - char*& type_name, - CORBA::Environment& TAO_IN_ENV) + char*& type_name, + CORBA::Environment& TAO_IN_ENV) TAO_THROW_SPEC ((CosTrading::IllegalOfferId, - CosTrading::UnknownOfferId)) + CosTrading::UnknownOfferId)) { CORBA::ULong index; CosTrading::Offer* offer = 0; @@ -183,9 +183,9 @@ lookup_offer (const CosTrading::OfferId offer_id, template <class LOCK_TYPE> CosTrading::Offer* TAO_Offer_Database<LOCK_TYPE>:: lookup_offer (const CosTrading::OfferId offer_id, - CORBA::Environment& TAO_IN_ENV) + CORBA::Environment& TAO_IN_ENV) TAO_THROW_SPEC ((CosTrading::IllegalOfferId, - CosTrading::UnknownOfferId)) + CosTrading::UnknownOfferId)) { char* type_name; CORBA::ULong index; @@ -199,7 +199,7 @@ lookup_offer (const CosTrading::OfferId offer_id, return offer; } - + template <class LOCK_TYPE> CosTrading::Offer* TAO_Offer_Database<LOCK_TYPE>:: lookup_offer (const char* type, CORBA::ULong id) @@ -208,11 +208,11 @@ lookup_offer (const char* type, CORBA::ULong id) CosTrading::Offer* return_value = 0; ACE_TYPENAME Offer_Database::ENTRY* db_entry = 0; - TAO_String_Hash_Key service_type (type); - + TAO_String_Hash_Key service_type (type); + if (this->offer_db_.find (service_type, db_entry) == 0) { - Offer_Map_Entry* offer_map_entry = db_entry->int_id_; + Offer_Map_Entry* offer_map_entry = db_entry->int_id_; ACE_READ_GUARD_RETURN (LOCK_TYPE, ace_mon, offer_map_entry->lock_, 0); TAO_Offer_Map::ENTRY* offer_entry_ptr = 0; @@ -228,12 +228,12 @@ template <class LOCK_TYPE> TAO_Offer_Id_Iterator* TAO_Offer_Database<LOCK_TYPE>::retrieve_all_offer_ids (void) { // Fill an TAO_Offer_Id_Iterator with the offer_ids of all offers - // exported to the TAO_Offer_Database. Iterates through the entire + // exported to the TAO_Offer_Database. Iterates through the entire // map, cramming offer_id strings into a newly constructed - // TAO_Offer_Id_Iterator. + // TAO_Offer_Id_Iterator. TAO_Offer_Id_Iterator* id_iterator = new TAO_Offer_Id_Iterator (); ACE_READ_GUARD_RETURN (LOCK_TYPE, ace_mon, this->db_lock_, 0); - + for (ACE_TYPENAME Offer_Database::iterator type_iter (this->offer_db_); ! type_iter.done (); type_iter++) @@ -242,34 +242,34 @@ TAO_Offer_Database<LOCK_TYPE>::retrieve_all_offer_ids (void) Offer_Map_Entry* offer_map_entry = (*type_iter).int_id_; ACE_READ_GUARD_RETURN (LOCK_TYPE, ace_mon, offer_map_entry->lock_, 0); - + for (TAO_Offer_Map::iterator offer_iter (*offer_map_entry->offer_map_); - ! offer_iter.done (); - offer_iter++) - { - CORBA::ULong offer_index = (*offer_iter).ext_id_; - CosTrading::OfferId offer_id = - this->generate_offer_id (type_name, offer_index); - - id_iterator->insert_id (offer_id); - } - } - + ! offer_iter.done (); + offer_iter++) + { + CORBA::ULong offer_index = (*offer_iter).ext_id_; + CosTrading::OfferId offer_id = + this->generate_offer_id (type_name, offer_index); + + id_iterator->insert_id (offer_id); + } + } + return id_iterator; } template <class LOCK_TYPE> void TAO_Offer_Database<LOCK_TYPE>:: parse_offer_id (const CosTrading::OfferId offer_id, - char*&service_type, - CORBA::ULong& id, - CORBA::Environment& TAO_IN_ENV) + char*&service_type, + CORBA::ULong& id, + CORBA::Environment& TAO_IN_ENV) TAO_THROW_SPEC ((CosTrading::IllegalOfferId)) { // Get service type: it is everything from 17th character to the end. service_type = (char *) offer_id + 16; - - // Get id: temporarily put the end of string character where the service + + // Get id: temporarily put the end of string character where the service // type starts, convert to number, replace the character back. char* start_of_type = (char *) (offer_id + 16); char temp = *start_of_type; @@ -288,7 +288,7 @@ generate_offer_id (const char *service_type_name, CORBA::ULong id) { // holds final id string. int total_size = 16 + ACE_OS::strlen (service_type_name); - + // hold portions of id string. CosTrading::OfferId offer_id = CORBA::string_alloc (total_size); char* return_value = 0; @@ -304,14 +304,14 @@ generate_offer_id (const char *service_type_name, CORBA::ULong id) template <class LOCK_TYPE> TAO_Service_Offer_Iterator<LOCK_TYPE>:: TAO_Service_Offer_Iterator (const char* type, - TAO_Offer_Database<LOCK_TYPE>& offer_database) + TAO_Offer_Database<LOCK_TYPE>& offer_database) : stm_ (offer_database), lock_ (0), offer_iter_ (0), type_ (type) { TAO_String_Hash_Key service_type (type); - + if (this->stm_.db_lock_.acquire_read () == -1) return; @@ -322,18 +322,18 @@ TAO_Service_Offer_Iterator (const char* type, { this->lock_ = &entry->lock_; if (this->lock_->acquire_read () == -1) - return; - + return; + ACE_NEW (offer_iter_, - TAO_Offer_Map::iterator (*entry->offer_map_)); + TAO_Offer_Map::iterator (*entry->offer_map_)); } } template <class LOCK_TYPE> TAO_Service_Offer_Iterator<LOCK_TYPE>::~TAO_Service_Offer_Iterator (void) -{ +{ this->stm_.db_lock_.release (); - + if (this->lock_ != 0) { this->lock_->release (); @@ -346,7 +346,7 @@ TAO_Service_Offer_Iterator<LOCK_TYPE>::get_id (void) { return (this->offer_iter_ != 0) ? TAO_Offer_Database<LOCK_TYPE>::generate_offer_id (this->type_, (**this->offer_iter_).ext_id_) - : 0; + : 0; } template <class LOCK_TYPE> int @@ -355,7 +355,7 @@ TAO_Service_Offer_Iterator<LOCK_TYPE>::has_more_offers (void) return (this->offer_iter_ != 0) ? ! this->offer_iter_->done () : 0; } - + template <class LOCK_TYPE> CosTrading::Offer* TAO_Service_Offer_Iterator<LOCK_TYPE>::get_offer (void) { @@ -370,4 +370,3 @@ TAO_Service_Offer_Iterator<LOCK_TYPE>::next_offer (void) } #endif /* TAO_OFFER_DATABASE_C */ - |