Go to the documentation of this file.00001
00002
00003 #include "tao/PortableServer/Key_Adapters.h"
00004
00005 #include "ace/ACE.h"
00006 #include "ace/OS_NS_string.h"
00007 #include "ace/Map_T.h"
00008
00009 ACE_RCSID (PortableServer,
00010 Key_Adapters,
00011 "$Id: Key_Adapters.cpp 82351 2008-07-22 08:15:32Z johnnyw $")
00012
00013
00014
00015 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00016
00017 TAO_Incremental_Key_Generator::TAO_Incremental_Key_Generator (void)
00018 : counter_ (0)
00019 {
00020 }
00021
00022 int
00023 TAO_Incremental_Key_Generator::operator() (PortableServer::ObjectId &id)
00024 {
00025
00026 id.length (sizeof this->counter_);
00027
00028
00029 ACE_OS::memcpy (id.get_buffer (),
00030 &++this->counter_,
00031 sizeof this->counter_);
00032
00033
00034 return 0;
00035 }
00036
00037
00038
00039 u_long
00040 TAO_ObjectId_Hash::operator () (const PortableServer::ObjectId &id) const
00041 {
00042 return ACE::hash_pjw ((const char *) id.get_buffer (),
00043 id.length ());
00044 }
00045
00046
00047
00048 int
00049 TAO_Ignore_Original_Key_Adapter::encode (const PortableServer::ObjectId &,
00050 const ACE_Active_Map_Manager_Key &active_key,
00051 PortableServer::ObjectId &modified_key)
00052 {
00053
00054 size_t const active_key_size = active_key.size ();
00055
00056
00057 modified_key.length (static_cast <CORBA::ULong> (active_key_size));
00058
00059
00060 active_key.encode (modified_key.get_buffer ());
00061
00062
00063 return 0;
00064 }
00065
00066 int
00067 TAO_Ignore_Original_Key_Adapter::decode (const PortableServer::ObjectId &modified_key,
00068 ACE_Active_Map_Manager_Key &active_key)
00069 {
00070
00071 active_key.decode (modified_key.get_buffer ());
00072
00073
00074 return 0;
00075 }
00076
00077 int
00078 TAO_Ignore_Original_Key_Adapter::decode (const PortableServer::ObjectId &modified_key,
00079 PortableServer::ObjectId &original_key)
00080 {
00081
00082 original_key.replace (modified_key.maximum (),
00083 modified_key.length (),
00084 const_cast <CORBA::Octet *>
00085 (modified_key.get_buffer ()),
00086 0);
00087
00088
00089 return 0;
00090 }
00091
00092
00093
00094 int
00095 TAO_Preserve_Original_Key_Adapter::encode (const PortableServer::ObjectId &original_key,
00096 const ACE_Active_Map_Manager_Key &active_key,
00097 PortableServer::ObjectId &modified_key)
00098 {
00099
00100 size_t const active_key_size = active_key.size ();
00101
00102
00103 modified_key.length (static_cast <CORBA::ULong> (active_key_size)
00104 + original_key.length ());
00105
00106
00107 active_key.encode (modified_key.get_buffer ());
00108
00109
00110 ACE_OS::memcpy (modified_key.get_buffer () + active_key_size,
00111 original_key.get_buffer (),
00112 original_key.length ());
00113
00114
00115 return 0;
00116 }
00117
00118 int
00119 TAO_Preserve_Original_Key_Adapter::decode (const PortableServer::ObjectId &modified_key,
00120 ACE_Active_Map_Manager_Key &active_key)
00121 {
00122
00123 active_key.decode (modified_key.get_buffer ());
00124
00125
00126 return 0;
00127 }
00128
00129 int
00130 TAO_Preserve_Original_Key_Adapter::decode (const PortableServer::ObjectId &modified_key,
00131 PortableServer::ObjectId &original_key)
00132 {
00133
00134 size_t const active_key_size = ACE_Active_Map_Manager_Key::size ();
00135
00136
00137 original_key.replace (static_cast <CORBA::ULong>
00138 (modified_key.maximum () - active_key_size),
00139 static_cast <CORBA::ULong>
00140 (modified_key.length () - active_key_size),
00141 const_cast <CORBA::Octet *>
00142 (modified_key.get_buffer ()) + active_key_size,
00143 0);
00144
00145
00146 return 0;
00147 }
00148
00149 TAO_END_VERSIONED_NAMESPACE_DECL
00150