00001
00002
00003 #include "orbsvcs/PortableGroup/Portable_Group_Map.h"
00004 #include "tao/ORB_Core.h"
00005 #include "tao/TAO_Server_Request.h"
00006 #include "tao/CDR.h"
00007
00008 ACE_RCSID (PortableGroup,
00009 Portable_Group_Map,
00010 "$Id: Portable_Group_Map.cpp 76589 2007-01-25 18:04:11Z elliott_c $")
00011
00012 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00013
00014
00015 TAO_Portable_Group_Map::TAO_Portable_Group_Map ()
00016 {
00017 }
00018
00019
00020 TAO_Portable_Group_Map::~TAO_Portable_Group_Map (void)
00021 {
00022 for (Iterator i = this->map_.begin ();
00023 i != this->map_.end ();
00024 ++i)
00025 {
00026
00027 delete (*i).ext_id_;
00028
00029
00030 Map_Entry *entry = (*i).int_id_;
00031 while (entry)
00032 {
00033 Map_Entry *next = entry->next;
00034 delete entry;
00035 entry = next;
00036 }
00037
00038 }
00039
00040 this->map_.close ();
00041 }
00042
00043
00044 void
00045 TAO_Portable_Group_Map::add_groupid_objectkey_pair (
00046 PortableGroup::TagGroupTaggedComponent *group_id,
00047 const TAO::ObjectKey &key
00048 )
00049 {
00050 ACE_GUARD (TAO_SYNCH_MUTEX,
00051 guard,
00052 this->lock_);
00053
00054 Map_Entry *new_entry;
00055
00056
00057
00058 PortableGroup::TagGroupTaggedComponent_var safe_group = group_id;
00059
00060 ACE_NEW_THROW_EX (new_entry,
00061 Map_Entry (),
00062 CORBA::NO_MEMORY (
00063 CORBA::SystemException::_tao_minor_code (
00064 TAO::VMCID,
00065 ENOMEM),
00066 CORBA::COMPLETED_NO));
00067
00068
00069 new_entry->key = key;
00070
00071
00072 Map_Entry *entry;
00073 if (this->map_.find (group_id,
00074 entry) == 0)
00075 {
00076
00077 new_entry->next = entry->next;
00078 entry->next = new_entry;
00079 }
00080 else
00081 {
00082 new_entry->next = 0;
00083
00084
00085 int result =
00086 this->map_.bind (group_id,
00087 new_entry);
00088
00089 if (result != 0)
00090 {
00091 delete new_entry;
00092 throw CORBA::INTERNAL ();
00093 }
00094
00095
00096 (void) safe_group._retn ();
00097 }
00098 }
00099
00100 void
00101 TAO_Portable_Group_Map::remove_groupid_objectkey_pair (const PortableGroup::TagGroupTaggedComponent* ,
00102 const TAO::ObjectKey &)
00103 {
00104
00105 }
00106
00107
00108 void
00109 TAO_Portable_Group_Map::dispatch (PortableGroup::TagGroupTaggedComponent* group_id,
00110 TAO_ORB_Core *orb_core,
00111 TAO_ServerRequest &request,
00112 CORBA::Object_out forward_to)
00113 {
00114 ACE_GUARD (TAO_SYNCH_MUTEX,
00115 guard,
00116 this->lock_);
00117
00118
00119 Map_Entry *entry = 0;
00120 if (this->map_.find (group_id,
00121 entry) == 0)
00122 {
00123
00124
00125
00126
00127 TAO_InputCDR *tao_in = request.incoming ();
00128 ACE_Message_Block *msgblk =
00129 const_cast<ACE_Message_Block *> (tao_in->start ());
00130 char *read_ptr = msgblk->rd_ptr ();
00131
00132
00133 while (entry)
00134 {
00135 orb_core->adapter_registry ()->dispatch (entry->key,
00136 request,
00137 forward_to);
00138
00139
00140 msgblk->rd_ptr (read_ptr);
00141 entry = entry->next;
00142 }
00143 }
00144 }
00145
00146 u_long
00147 TAO_GroupId_Hash::operator () (const PortableGroup::TagGroupTaggedComponent *id) const
00148 {
00149 u_long hash =
00150 ACE::hash_pjw ((const char *) id->group_domain_id,
00151 ACE_OS::strlen ((const char *) id->group_domain_id));
00152
00153
00154
00155
00156 hash += (u_long) (id->object_group_id / 1);
00157
00158 hash += id->object_group_ref_version;
00159
00160 return hash;
00161 }
00162
00163 int
00164 TAO_GroupId_Equal_To::operator () (
00165 const PortableGroup::TagGroupTaggedComponent *lhs,
00166 const PortableGroup::TagGroupTaggedComponent *rhs) const
00167 {
00168 return
00169 ACE_OS::strcmp (lhs->group_domain_id, rhs->group_domain_id) == 0
00170 && lhs->object_group_id == rhs->object_group_id
00171 && lhs->object_group_ref_version == rhs->object_group_ref_version;
00172 }
00173
00174 TAO_END_VERSIONED_NAMESPACE_DECL