2 #include "tao/PortableServer/Key_Adapters.h"
5 #include "ace/OS_NS_string.h"
8 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
10 TAO_Incremental_Key_Generator::TAO_Incremental_Key_Generator ()
16 TAO_Incremental_Key_Generator::operator() (PortableServer::ObjectId
&id
)
18 const size_t cntr_size
= sizeof this->counter_
;
19 // Resize to accommodate the counter.
20 id
.length (cntr_size
);
23 ACE_OS::memcpy (id
.get_buffer (),
31 ////////////////////////////////////////////////////////////////////////////////
34 TAO_ObjectId_Hash::operator () (const PortableServer::ObjectId
&id
) const
36 return ACE::hash_pjw ((const char *) id
.get_buffer (),
40 ////////////////////////////////////////////////////////////////////////////////
43 TAO_Ignore_Original_Key_Adapter::encode (const PortableServer::ObjectId
&,
44 const ACE_Active_Map_Manager_Key
&active_key
,
45 PortableServer::ObjectId
&modified_key
)
47 // Size of active key.
48 size_t const active_key_size
= active_key
.size ();
50 // Resize to accommodate both the original data and the new active key.
51 modified_key
.length (static_cast <CORBA::ULong
> (active_key_size
));
53 // Copy active key data into user key.
54 active_key
.encode (modified_key
.get_buffer ());
61 TAO_Ignore_Original_Key_Adapter::decode (const PortableServer::ObjectId
&modified_key
,
62 ACE_Active_Map_Manager_Key
&active_key
)
64 // Read off value of index and generation.
65 active_key
.decode (modified_key
.get_buffer ());
72 TAO_Ignore_Original_Key_Adapter::decode (const PortableServer::ObjectId
&modified_key
,
73 PortableServer::ObjectId
&original_key
)
75 // Smartly copy all the data; <original_key does not own the data>.
76 original_key
.replace (modified_key
.maximum (),
77 modified_key
.length (),
78 const_cast <CORBA::Octet
*>
79 (modified_key
.get_buffer ()),
86 ////////////////////////////////////////////////////////////////////////////////
89 TAO_Preserve_Original_Key_Adapter::encode (const PortableServer::ObjectId
&original_key
,
90 const ACE_Active_Map_Manager_Key
&active_key
,
91 PortableServer::ObjectId
&modified_key
)
93 // Size of active key.
94 size_t const active_key_size
= active_key
.size ();
96 // Resize to accommodate both the original data and the new active key.
97 modified_key
.length (static_cast <CORBA::ULong
> (active_key_size
)
98 + original_key
.length ());
100 // Copy active key data into user key.
101 active_key
.encode (modified_key
.get_buffer ());
103 // Copy the original key after the active key.
104 ACE_OS::memcpy (modified_key
.get_buffer () + active_key_size
,
105 original_key
.get_buffer (),
106 original_key
.length ());
113 TAO_Preserve_Original_Key_Adapter::decode (const PortableServer::ObjectId
&modified_key
,
114 ACE_Active_Map_Manager_Key
&active_key
)
116 // Read off value of index and generation.
117 active_key
.decode (modified_key
.get_buffer ());
124 TAO_Preserve_Original_Key_Adapter::decode (const PortableServer::ObjectId
&modified_key
,
125 PortableServer::ObjectId
&original_key
)
127 // Size of active key.
128 size_t const active_key_size
= ACE_Active_Map_Manager_Key::size ();
130 // Smartly copy all the data; <original_key does not own the data>.
131 original_key
.replace (static_cast <CORBA::ULong
>
132 (modified_key
.maximum () - active_key_size
),
133 static_cast <CORBA::ULong
>
134 (modified_key
.length () - active_key_size
),
135 const_cast <CORBA::Octet
*>
136 (modified_key
.get_buffer ()) + active_key_size
,
143 TAO_END_VERSIONED_NAMESPACE_DECL