summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TAO/orbsvcs/orbsvcs/Trader/Attributes.h1
-rw-r--r--TAO/orbsvcs/orbsvcs/Trader/Link.cpp57
-rw-r--r--TAO/orbsvcs/orbsvcs/Trader/Link.h11
-rw-r--r--TAO/orbsvcs/orbsvcs/Trader/Offer_Iterator_Collection.h6
-rw-r--r--TAO/orbsvcs/orbsvcs/Trader/Service_Type_Repository.cpp24
-rw-r--r--TAO/orbsvcs/orbsvcs/Trader/Service_Type_Repository.h10
-rw-r--r--TAO/orbsvcs/orbsvcs/Trader/Trader.cpp39
-rw-r--r--TAO/orbsvcs/orbsvcs/Trader/Trader.h35
-rw-r--r--TAO/orbsvcs/orbsvcs/Trader/stl.h6
9 files changed, 122 insertions, 67 deletions
diff --git a/TAO/orbsvcs/orbsvcs/Trader/Attributes.h b/TAO/orbsvcs/orbsvcs/Trader/Attributes.h
index 9f702eb1b09..c0e7c211d8e 100644
--- a/TAO/orbsvcs/orbsvcs/Trader/Attributes.h
+++ b/TAO/orbsvcs/orbsvcs/Trader/Attributes.h
@@ -19,6 +19,7 @@
#ifndef TAO_ATTRIBUTES_H
#define TAO_ATTRIBUTES_H
+#include "orbsvcs_export.h"
#include "orbsvcs/CosTradingS.h"
#include "Monitor.h"
diff --git a/TAO/orbsvcs/orbsvcs/Trader/Link.cpp b/TAO/orbsvcs/orbsvcs/Trader/Link.cpp
index 6d9574722f4..4cec6e0e243 100644
--- a/TAO/orbsvcs/orbsvcs/Trader/Link.cpp
+++ b/TAO/orbsvcs/orbsvcs/Trader/Link.cpp
@@ -37,7 +37,7 @@ TAO_Link<TRADER,MAP_LOCK_TYPE>::~TAO_Link (void)
}
template <class TRADER, class MAP_LOCK_TYPE> void
-TAO_Link<TRADER,MAP_LOCK_TYPE>::
+TAO_Link<TRADER, MAP_LOCK_TYPE>::
add_link (const char *name,
CosTrading::Lookup_ptr target,
CosTrading::FollowOption def_pass_on_follow_rule,
@@ -50,18 +50,13 @@ add_link (const char *name,
CosTrading::Link::DefaultFollowTooPermissive,
CosTrading::Link::LimitingFollowTooPermissive))
{
- TAO_WRITE_GUARD (MAP_LOCK_TYPE,
- ace_mon,
- this->links_.lock ());
-
// Ensure the link name is valid.
if (! TAO_Trader_Base::is_valid_identifier_name (name))
TAO_THROW (CosTrading::Link::IllegalLinkName (name));
// Ensure this isn't a duplicate link name.
- string link_name (name);
- LINKS::iterator links_iter = this->links_.find (link_name);
- if (links_iter != this->links_.end ())
+ TAO_String_Hash_Key link_name (name);
+ if (this->links_.find (link_name) == -1)
TAO_THROW (CosTrading::Link::DuplicateLinkName (name));
// Ensure the lookup_ptr isn't nil.
@@ -89,7 +84,7 @@ add_link (const char *name,
TAO_CHECK_ENV_RETURN_VOID (_env);
// Insert this link into the collection of links.
- this->links_.insert (link_name, link_info);
+ this->links_.bind (link_name, link_info);
}
template <class TRADER, class MAP_LOCK_TYPE> void
@@ -99,22 +94,17 @@ TAO_Link<TRADER,MAP_LOCK_TYPE>::remove_link (const char *name,
CosTrading::Link::IllegalLinkName,
CosTrading::Link::UnknownLinkName))
{
- TAO_WRITE_GUARD (MAP_LOCK_TYPE,
- ace_mon,
- this->links_.lock ());
-
// Ensure the link name is valid.
if (! TAO_Trader_Base::is_valid_identifier_name (name))
TAO_THROW (CosTrading::Link::IllegalLinkName (name));
// Ensure this isn't a duplicate link name.
- string link_name (name);
- LINKS::iterator links_iter = this->links_.find (link_name);
- if (links_iter == this->links_.end ())
+ TAO_String_Hash_Key link_name (name);
+ if (this->links_.find (link_name) == -1)
TAO_THROW (CosTrading::Link::UnknownLinkName (name));
// Erase the link state from the map.
- this->links_.erase (links_iter);
+ this->links_.unbind (links_iter);
}
template <class TRADER, class MAP_LOCK_TYPE> CosTrading::Link::LinkInfo *
@@ -134,37 +124,32 @@ TAO_Link<TRADER,MAP_LOCK_TYPE>::describe_link (const char *name,
TAO_THROW_RETURN (CosTrading::Link::IllegalLinkName (name), 0);
// Ensure this isn't a duplicate link name.
- string link_name (name);
- LINKS::iterator links_iter = this->links_.find (link_name);
- if (links_iter == this->links_.end ())
+ LINKS::ENTRY* link_entry;
+ TAO_String_Hash_Key link_name (name);
+ if (this->links_.find (link_name, link_entry) == -1)
TAO_THROW_RETURN (CosTrading::Link::UnknownLinkName (name), 0);
// return the link infor for this link name.
- return &(*links_iter).second;
+ return *(link_entry->int_id_);
}
template <class TRADER, class MAP_LOCK_TYPE> CosTrading::LinkNameSeq*
TAO_Link<TRADER,MAP_LOCK_TYPE>::list_links (CORBA::Environment& _env)
TAO_THROW_SPEC ((CORBA::SystemException))
{
- TAO_READ_GUARD_RETURN (MAP_LOCK_TYPE,
- ace_mon,
- this->links_.lock (),
- (CosTrading::LinkNameSeq*) 0);
-
// Allocate space for the link names.
CORBA::ULong size = this->links_.size (), i = 0;
CosTrading::LinkName* link_seq =
CosTrading::LinkNameSeq::allocbuf (size);
// Copy the link names into the buffer.
- for (LINKS::iterator links_iter = this->links_.begin ();
- links_iter != this->links_.end ();
+ for (LINKS::iterator links_iter (this->links_);
+ ! links_iter.done ();
links_iter++)
- link_seq[i++] = CORBA::string_dup ((*links_iter).first.data ());
+ link_seq[i++] = CORBA::string_dup ((*links_iter).int_id_.in ());
// Return a sequence of the buf names.
- return new CosTrading::LinkNameSeq (i, i, link_seq, 1);
+ return new CosTrading::LinkNameSeq (i, i, link_seq, CORBA::B_TRUE);
}
template <class TRADER, class MAP_LOCK_TYPE> void
@@ -179,18 +164,14 @@ modify_link (const char *name,
CosTrading::Link::DefaultFollowTooPermissive,
CosTrading::Link::LimitingFollowTooPermissive))
{
- TAO_WRITE_GUARD (MAP_LOCK_TYPE,
- ace_mon,
- this->links_.lock ());
-
// Ensure the link name is valid.
if (! TAO_Trader_Base::is_valid_identifier_name (name))
TAO_THROW (CosTrading::Link::IllegalLinkName (name));
// Ensure this isn't a duplicate link name.
- string link_name (name);
- LINKS::iterator links_iter = this->links_.find (link_name);
- if (links_iter == this->links_.end ())
+ LINKS::ENTRY* link_entry = 0;
+ TAO_String_Hash_Key link_name (name);
+ if (this->links_.find (link_name, link_entry) == -1)
TAO_THROW (CosTrading::Link::UnknownLinkName (name));
// Ensure that the default link behavior isn't stronger than the
@@ -206,7 +187,7 @@ modify_link (const char *name,
(limiting_follow_rule, this->max_link_follow_policy (_env)));
// Adjust the link settings
- CosTrading::Link::LinkInfo& link_info = (*links_iter).second;
+ CosTrading::Link::LinkInfo& link_info = link_entry->int_id_;
link_info.def_pass_on_follow_rule = def_pass_on_follow_rule;
link_info.limiting_follow_rule = limiting_follow_rule;
}
diff --git a/TAO/orbsvcs/orbsvcs/Trader/Link.h b/TAO/orbsvcs/orbsvcs/Trader/Link.h
index 6c38459aa19..7fbc1566cc4 100644
--- a/TAO/orbsvcs/orbsvcs/Trader/Link.h
+++ b/TAO/orbsvcs/orbsvcs/Trader/Link.h
@@ -19,9 +19,7 @@
#ifndef TAO_LINK_H
#define TAO_LINK_H
-#include "Attributes.h"
-#include "Monitor.h"
-#include "stl.h"
+#include "Trader.h"
template <class TRADER, class MAP_LOCK_TYPE>
class TAO_Link :
@@ -177,13 +175,14 @@ public:
private:
- typedef TAO_Monitor
+ typedef ACE_Hash_Map_Manager
<
- map <string, CosTrading::Link::LinkInfo, less <string> >,
+ TAO_String_Hash_Key,
+ CosTrading::Link::LinkInfo,
MAP_LOCK_TYPE
>
LINKS;
-
+
LINKS links_;
// The collection of link connecting this trader to others in the
// federation.
diff --git a/TAO/orbsvcs/orbsvcs/Trader/Offer_Iterator_Collection.h b/TAO/orbsvcs/orbsvcs/Trader/Offer_Iterator_Collection.h
index 33634adbd76..c6df2b6657d 100644
--- a/TAO/orbsvcs/orbsvcs/Trader/Offer_Iterator_Collection.h
+++ b/TAO/orbsvcs/orbsvcs/Trader/Offer_Iterator_Collection.h
@@ -57,10 +57,10 @@ public:
virtual CORBA::ULong max_left (CORBA::Environment &env)
TAO_THROW_SPEC ((CORBA::SystemException,
CosTrading::UnknownMaxLeft));
- // Determine how many offers are left in the collection
+ // Determine how many offers are left in the collection.
void add_offer_iterator (CosTrading::OfferIterator* offer_iter);
- // Add an iterator to the collection.
+ // Add an iterator to the collection.
private:
@@ -73,7 +73,7 @@ private:
// Cached value of the number of elements left in this iterator.
};
- typedef list<Iter_Info> OFFER_ITERS;
+ typedef deque<Iter_Info> OFFER_ITERS;
OFFER_ITERS iters_;
// The iterator collection.
diff --git a/TAO/orbsvcs/orbsvcs/Trader/Service_Type_Repository.cpp b/TAO/orbsvcs/orbsvcs/Trader/Service_Type_Repository.cpp
index 6351acb17fe..7f6fad392a3 100644
--- a/TAO/orbsvcs/orbsvcs/Trader/Service_Type_Repository.cpp
+++ b/TAO/orbsvcs/orbsvcs/Trader/Service_Type_Repository.cpp
@@ -68,7 +68,6 @@ add_type (const char * name,
{
PROP_MAP prop_map;
SUPER_TYPE_MAP super_map;
- CosTradingRepos::ServiceTypeRepository::TypeStruct info;
SERVICE_TYPE_MAP::iterator type_iterator;
CosTradingRepos::ServiceTypeRepository::IncarnationNumber inc_num;
@@ -114,12 +113,7 @@ add_type (const char * name,
// we can now use prop_map to construct a sequence of all properties the
// this type.
- info.if_name = if_name;
- info.props = props;
- info.super_types = super_types;
- info.masked = 0;
- info.incarnation = this->incarnation_;
- this->update_type_map (name, info, prop_map, super_map);
+ this->update_type_map (name, if_name, props, super_types, prop_map, super_map);
// increment incarnation number
this->incarnation_.low++;
@@ -358,7 +352,7 @@ unmask_type (const char * name,
mask = 0;
}
- void
+void
TAO_Service_Type_Repository::
validate_properties (const CosTradingRepos::ServiceTypeRepository::PropStructSeq& props,
PROP_MAP& prop_map,
@@ -377,8 +371,7 @@ validate_properties (const CosTradingRepos::ServiceTypeRepository::PropStructSeq
CosTradingRepos::ServiceTypeRepository::PropStruct* prop_struct =
(CosTradingRepos::ServiceTypeRepository::PropStruct *) &props[i];
- if (! prop_map.insert
- (make_pair (prop_name, prop_struct)).second)
+ if (! prop_map.insert (make_pair (prop_name, prop_struct)).second)
TAO_THROW (CosTrading::DuplicatePropertyName (n));
}
}
@@ -467,7 +460,9 @@ TAO_Service_Type_Repository
void
TAO_Service_Type_Repository::
update_type_map (const char* name,
- CosTradingRepos::ServiceTypeRepository::TypeStruct& info,
+ const char * if_name,
+ const CosTradingRepos::ServiceTypeRepository::PropStructSeq& props,
+ const CosTradingRepos::ServiceTypeRepository::ServiceTypeNameSeq& super_types,
PROP_MAP& prop_map,
SUPER_TYPE_MAP& super_map)
{
@@ -496,8 +491,11 @@ update_type_map (const char* name,
// all parameters are valid, create an entry for this service type
// in the this->type_map_.
- type.type_info_ = info;
+ type.type_info_.if_name = if_name;
+ type.type_info_.props = props;
+ type.type_info_.super_types = super_types;
+ type.type_info_.masked = CORBA::B_FALSE;
+ type.type_info_.incarnation = this->incarnation_;
type.all_prop_ = all_prop;
this->type_map_[name] = type;
-
}
diff --git a/TAO/orbsvcs/orbsvcs/Trader/Service_Type_Repository.h b/TAO/orbsvcs/orbsvcs/Trader/Service_Type_Repository.h
index 7c286268d43..69fd156396e 100644
--- a/TAO/orbsvcs/orbsvcs/Trader/Service_Type_Repository.h
+++ b/TAO/orbsvcs/orbsvcs/Trader/Service_Type_Repository.h
@@ -266,10 +266,12 @@ private:
// TAO_THROW_SPEC ((CosTradingRepos::ServiceTypeRepository::InterfaceTypeMismatch));
// Ensure that the interface type derives from its superclasses'.
- void update_type_map (const char* name,
- CosTradingRepos::ServiceTypeRepository::TypeStruct& type,
- PROP_MAP& prop_map,
- SUPER_TYPE_MAP& super_map);
+ void update_type_map (const char* name,
+ const char * if_name,
+ const CosTradingRepos::ServiceTypeRepository::PropStructSeq& props,
+ const CosTradingRepos::ServiceTypeRepository::ServiceTypeNameSeq& super_types,
+ PROP_MAP& prop_map,
+ SUPER_TYPE_MAP& super_map);
// Update the type map with the information contained in the
// TypeStruct, prop_map, and super_map.
diff --git a/TAO/orbsvcs/orbsvcs/Trader/Trader.cpp b/TAO/orbsvcs/orbsvcs/Trader/Trader.cpp
index bb143a32b39..df100fed09b 100644
--- a/TAO/orbsvcs/orbsvcs/Trader/Trader.cpp
+++ b/TAO/orbsvcs/orbsvcs/Trader/Trader.cpp
@@ -102,6 +102,45 @@ TAO_Trader_Base::is_valid_identifier_name (const char* ident)
return return_value;
}
+// = Methods to deal with ACE_Hash_Map_Manager.
+
+TAO_String_Hash_Key::TAO_String_Hash_Key (void)
+{
+}
+
+TAO_String_Hash_Key::TAO_String_Hash_Key (char * name)
+ : CORBA::String_var (name)
+{
+}
+
+TAO_String_Hash_Key::TAO_String_Hash_Key (const char * name)
+ : CORBA::String_var (name)
+{
+}
+
+TAO_String_Hash_Key::TAO_String_Hash_Key (const CORBA::String_var &src)
+ : CORBA::String_var (src)
+{
+}
+
+int
+TAO_String_Hash_Key::operator == (const TAO_String_Hash_Key &hash_key) const
+{
+ return ACE_OS::strcmp (this->in (), hash_key.in ()) == 0;
+}
+
+u_long
+TAO_String_Hash_Key::hash (void) const
+{
+ u_long ret = ACE::hash_pjw (this->in ());
+ return ret;
+}
+
+TAO_String_Hash_Key::~TAO_String_Hash_Key (void)
+{
+}
+
+
int
operator< (const CosTradingRepos::ServiceTypeRepository::IncarnationNumber &l,
const CosTradingRepos::ServiceTypeRepository::IncarnationNumber &r)
diff --git a/TAO/orbsvcs/orbsvcs/Trader/Trader.h b/TAO/orbsvcs/orbsvcs/Trader/Trader.h
index e71da9eda52..7b3b842751d 100644
--- a/TAO/orbsvcs/orbsvcs/Trader/Trader.h
+++ b/TAO/orbsvcs/orbsvcs/Trader/Trader.h
@@ -20,6 +20,7 @@
#define TAO_TRADER_BASE_H
#include "stl.h"
+#include "ace/Hash_Map_Manager.h"
#include "Attributes.h"
#include "Monitor.h"
@@ -103,6 +104,40 @@ protected:
// Stores and allows access/modification of trader's link attributes.
};
+// Miscellaneous Utilities
+
+// = Classes to deal with the ACE_Hash_Map_Manager.
+
+class TAO_ORBSVCS_Export TAO_String_Hash_Key : public CORBA::String_var
+{
+ // = TITLE
+ // Key for the Hash Table. The EXT_ID of the
+ // ACE_Hash_Map_Manager.
+public:
+ // = Initialization and termination methods.
+ TAO_String_Hash_Key (void);
+ // Default constructor.
+
+ TAO_String_Hash_Key (char * name);
+ // Constructor from a const string.
+
+ TAO_String_Hash_Key (const char * name);
+ // Constructor from a const string.
+
+ TAO_String_Hash_Key (const CORBA::String_var &hash_key);
+ // Copy constructor.
+
+ ~TAO_String_Hash_Key (void);
+ // Destructor.
+
+ int operator == (const TAO_String_Hash_Key &hash_key) const;
+ // The operator for hash binding and "find"ing.
+
+ u_long hash (void) const;
+ // The function that computes a hash value.
+};
+
+
int
operator> (const CosTradingRepos::ServiceTypeRepository::IncarnationNumber &l,
const CosTradingRepos::ServiceTypeRepository::IncarnationNumber &r);
diff --git a/TAO/orbsvcs/orbsvcs/Trader/stl.h b/TAO/orbsvcs/orbsvcs/Trader/stl.h
index e8cd874305e..300ac8ee9f6 100644
--- a/TAO/orbsvcs/orbsvcs/Trader/stl.h
+++ b/TAO/orbsvcs/orbsvcs/Trader/stl.h
@@ -23,8 +23,8 @@
#include<queue>
#include<stack>
-//#if defined (ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB) && \
-//(ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB != 0)
+#if defined (ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB) && \
+(ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB != 0)
using std::map;
using std::vector;
using std::string;
@@ -38,7 +38,7 @@ using std::pair;
using std::multimap;
using std::make_pair;
-//#endif // ACE_USES
+#endif // ACE_USES