#include <NVList.h>
Collaboration diagram for CORBA::NVList:
Public Types | |
typedef NVList_ptr | _ptr_type |
typedef NVList_var | _var_type |
typedef NVList_out | _out_type |
Public Member Functions | |
ULong | count (void) const |
return the current number of elements in the list | |
NamedValue_ptr | add (Flags) |
add an element and just initialize the flags | |
NamedValue_ptr | add_item (const char *, Flags) |
add an element and initialize its name and flags | |
NamedValue_ptr | add_value (const char *, const Any &, Flags) |
initializes a value, name, and flags | |
NamedValue_ptr | add_item_consume (char *, Flags) |
NamedValue_ptr | add_value_consume (char *, Any_ptr, Flags) |
NamedValue_ptr | item (ULong n) |
retrieve the item at the nth location. Raises Bounds | |
void | remove (ULong n) |
remove element at index n. Raises Bounds | |
ULong | _incr_refcnt (void) |
ULong | _decr_refcnt (void) |
void | _tao_incoming_cdr (TAO_InputCDR &cdr, int flag, bool &lazy_evaluation) |
void | _tao_encode (TAO_OutputCDR &cdr, int flag) |
void | _tao_decode (TAO_InputCDR &cdr, int flag) |
Decode the NVList arguments from the cdr stream. | |
ptrdiff_t | _tao_target_alignment (void) |
Boolean | _lazy_has_arguments (void) const |
Static Public Member Functions | |
NVList * | _duplicate (NVList *) |
NVList * | _nil (void) |
Protected Member Functions | |
~NVList (void) | |
Destructor. | |
Private Member Functions | |
NVList (void) | |
NamedValue_ptr | add_element (Flags) |
void | evaluate (void) |
Private Attributes | |
ACE_Unbounded_Queue< NamedValue_ptr > | values_ |
Internal list of parameters stored as NamedValues. | |
ULong | max_ |
Maximum length of list. | |
ACE_Atomic_Op< TAO_SYNCH_MUTEX, unsigned long > | refcount_ |
Reference counter. | |
TAO_SYNCH_MUTEX | lock_ |
Protects the incoming pointer. | |
TAO_InputCDR * | incoming_ |
int | incoming_flag_ |
Friends | |
class | ::TAO_NVList_Adapter_Impl |
class | Request |
This is used in the (client side) DII (Dynamic Invocation Interface) to hold parameters, except for the return parameter. It's used in the same role in the (server side) DSI (Dynamic Skeleton Interface).
Each user (client, server) provides the typecode and memory for each parameter using an NVList, then talks to the ORB using a Request or ServerRequest pseudo-object. The ORB copies data to/from the IPC messages (e.g. IIOP::Request, IIOP::Response) as appropriate.
Definition at line 159 of file NVList.h.
|
|
|
|
|
|
|
Destructor. Protected destructor to enforce proper memory management through the reference counting mechanism. Definition at line 79 of file NVList.cpp. References ACE_Unbounded_Queue_Iterator< T >::advance(), ACE_Unbounded_Queue_Iterator< T >::done(), ACE_Unbounded_Queue_Iterator< T >::first(), and ACE_Unbounded_Queue_Iterator< T >::next().
00080 { 00081 // initialize an iterator and delete each NamedValue 00082 ACE_Unbounded_Queue_Iterator<CORBA::NamedValue_ptr> iter (this->values_); 00083 00084 for (iter.first (); !iter.done (); iter.advance ()) 00085 { 00086 CORBA::NamedValue_ptr *nv = 0; 00087 (void) iter.next (nv); 00088 delete *nv; 00089 } 00090 00091 this->max_ = 0; 00092 00093 // Remove the CDR stream if it is present. 00094 delete this->incoming_; 00095 } |
|
Constructor - cannot be instantiated directly other than through the CORBA::ORB::create_list method Definition at line 92 of file NVList.inl.
00093 : max_ (0), 00094 refcount_ (1), 00095 incoming_ (0), 00096 incoming_flag_ (0) 00097 { 00098 } |
|
Definition at line 69 of file NVList.cpp.
00070 { 00071 const CORBA::ULong new_count = --this->refcount_; 00072 00073 if (new_count == 0) 00074 delete this; 00075 00076 return new_count; 00077 } |
|
Definition at line 111 of file NVList.inl. References _incr_refcnt().
00112 { 00113 if (x != 0) 00114 { 00115 x->_incr_refcnt (); 00116 } 00117 00118 return x; 00119 } |
|
Definition at line 63 of file NVList.cpp. Referenced by _duplicate().
00064 { 00065 return ++this->refcount_; 00066 } |
|
If this list is used by a DII request, this will tell us if our CDR stream contains any marshaled arguments (needed for GIOP 1.2). Definition at line 456 of file NVList.cpp. References count(), and ACE_InputCDR::length().
|
|
Definition at line 123 of file NVList.inl.
00124 {
00125 return 0;
00126 }
|
|
Decode the NVList arguments from the cdr stream.
Definition at line 373 of file NVList.cpp. References ACE_BIT_DISABLED, ACE_DEBUG, ACE_TEXT, ACE_TEXT_CHAR_TO_TCHAR, ACE_Unbounded_Queue_Iterator< T >::advance(), ACE_Unbounded_Queue_Iterator< T >::done(), ACE_Unbounded_Queue_Iterator< T >::first(), LM_DEBUG, ACE_Unbounded_Queue_Iterator< T >::next(), and TAO_debug_level. Referenced by _tao_incoming_cdr(), and evaluate().
00374 { 00375 if (TAO_debug_level > 3) 00376 { 00377 ACE_DEBUG ((LM_DEBUG, 00378 ACE_TEXT ("TAO (%P|%t) : NVList::_tao_decode\n"))); 00379 } 00380 00381 // Then unmarshal each "in" and "inout" parameter. 00382 ACE_Unbounded_Queue_Iterator<CORBA::NamedValue_ptr> i (this->values_); 00383 00384 for (i.first (); !i.done (); i.advance ()) 00385 { 00386 CORBA::NamedValue_ptr *item = 0; 00387 (void) i.next (item); 00388 00389 CORBA::NamedValue_ptr nv = *item; 00390 00391 // check if it is an in or inout parameter 00392 // @@ this is where we assume that the NVList is coming from 00393 // a Server-side request, we could probably handle both 00394 // cases with a flag, but there is no clear need for that. 00395 if (ACE_BIT_DISABLED (nv->flags (), flag)) 00396 { 00397 continue; 00398 } 00399 00400 if (TAO_debug_level > 3) 00401 { 00402 ACE_DEBUG ((LM_DEBUG, 00403 ACE_TEXT ("TAO (%P|%t) : NVList::_tao_decode - %s\n"), 00404 ACE_TEXT_CHAR_TO_TCHAR (nv->name ()? nv->name () : "(no name given)" ))); 00405 } 00406 00407 CORBA::Any_ptr any = nv->value (); 00408 any->impl ()->_tao_decode (incoming 00409 ); 00410 } 00411 } |
|
Encode the NVList into the CDR stream. flag masks the type of arguments (IN, OUT or INOUT) that are to be marshaled. Definition at line 292 of file NVList.cpp. References ACE_BIT_DISABLED, ACE_DEBUG, ACE_GUARD, ACE_TEXT, ACE_TEXT_CHAR_TO_TCHAR, ACE_Unbounded_Queue_Iterator< T >::advance(), ACE_Unbounded_Queue_Iterator< T >::done(), ACE_Unbounded_Queue_Iterator< T >::first(), LM_DEBUG, ACE_Unbounded_Queue_Iterator< T >::next(), TAO_Marshal_Object::perform_append(), TAO_debug_level, TAO_SYNCH_MUTEX, and ACE_OutputCDR::write_octet_array_mb().
00293 { 00294 ACE_GUARD (TAO_SYNCH_MUTEX, 00295 ace_mon, 00296 this->lock_); 00297 00298 if (this->incoming_ != 0) 00299 { 00300 if (this->max_ == 0) 00301 { 00302 // The list is empty aggresively reduce copies and just send 00303 // the CDR stream, we assume that 00304 // TAO_Server_Request::init_reply 00305 // has inserted appropiated padding already to make this 00306 // operation correct 00307 cdr.write_octet_array_mb (this->incoming_->start ()); 00308 return; 00309 } 00310 00311 // Then unmarshal each "in" and "inout" parameter. 00312 ACE_Unbounded_Queue_Iterator<CORBA::NamedValue_ptr> i (this->values_); 00313 00314 for (i.first (); !i.done (); i.advance ()) 00315 { 00316 CORBA::NamedValue_ptr *item = 0; 00317 (void) i.next (item); 00318 00319 CORBA::NamedValue_ptr nv = *item; 00320 00321 if (ACE_BIT_DISABLED (nv->flags (), flag)) 00322 { 00323 continue; 00324 } 00325 00326 if (TAO_debug_level > 3) 00327 { 00328 const char* arg = nv->name (); 00329 00330 if (arg == 0) 00331 { 00332 arg = "(nil)"; 00333 } 00334 00335 ACE_DEBUG ((LM_DEBUG, 00336 ACE_TEXT ("NVList::_tao_encode - parameter <%s>\n"), 00337 ACE_TEXT_CHAR_TO_TCHAR (arg))); 00338 } 00339 CORBA::TypeCode_ptr tc = nv->value ()->_tao_get_typecode (); 00340 (void) TAO_Marshal_Object::perform_append (tc, 00341 this->incoming_, 00342 &cdr); 00343 } 00344 00345 delete this->incoming_; 00346 this->incoming_ = 0; 00347 return; 00348 } 00349 00350 // The list is already evaluated, we cannot optimize the copies, go 00351 // ahead with the slow way to do things. 00352 00353 // Then marshal each "in" and "inout" parameter. 00354 ACE_Unbounded_Queue_Iterator<CORBA::NamedValue_ptr> i (this->values_); 00355 00356 for (i.first (); !i.done (); i.advance ()) 00357 { 00358 CORBA::NamedValue_ptr *item = 0; 00359 (void) i.next (item); 00360 00361 CORBA::NamedValue_ptr nv = *item; 00362 00363 if (ACE_BIT_DISABLED (nv->flags (), flag)) 00364 { 00365 continue; 00366 } 00367 00368 nv->value ()->impl ()->marshal_value (cdr); 00369 } 00370 } |
|
Set the incoming CDR stream, this is used by TAO to perform lazy evaluation of the NVList in an incoming ServerRequest. The is used to check which parameters (IN, OUT and/or INOUT) are to be extracted Definition at line 259 of file NVList.cpp. References _tao_decode(), ACE_GUARD, ACE_NEW, incoming_flag_, and TAO_SYNCH_MUTEX.
00262 { 00263 // If the list is empty then using lazy evaluation is the only 00264 // choice. 00265 // @@ There are other cases where we can use lazy evaluation, for 00266 // example if the list is not empty but the anys own all their 00267 // objects. 00268 if (lazy_evaluation == false && this->max_ == 0) 00269 { 00270 lazy_evaluation = true; 00271 } 00272 00273 if (lazy_evaluation == false) 00274 { 00275 this->_tao_decode (cdr, flag); 00276 return; 00277 } 00278 00279 ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_); 00280 00281 if (this->incoming_ != 0) 00282 { 00283 delete this->incoming_; 00284 this->incoming_ = 0; 00285 } 00286 00287 ACE_NEW (this->incoming_, TAO_InputCDR (cdr)); 00288 this->incoming_flag_ = flag; 00289 } |
|
Return the required alignment to marshal the NVList without any re-alignment. It returns ACE_CDR::MAX_ALIGNMENT to indicate errors. Definition at line 414 of file NVList.cpp. References ACE_GUARD_RETURN, ACE_Message_Block::rd_ptr(), ACE_InputCDR::start(), and TAO_SYNCH_MUTEX.
00415 { 00416 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, 00417 ace_mon, 00418 this->lock_, 00419 ACE_CDR::MAX_ALIGNMENT); 00420 00421 if (this->incoming_ == 0) 00422 { 00423 return ACE_CDR::MAX_ALIGNMENT; 00424 } 00425 00426 const char* rd = this->incoming_->start ()->rd_ptr (); 00427 ptrdiff_t t = ptrdiff_t (rd) % ACE_CDR::MAX_ALIGNMENT; 00428 00429 if (t < 0) 00430 { 00431 t += ACE_CDR::MAX_ALIGNMENT; 00432 } 00433 00434 return t; 00435 } |
|
add an element and just initialize the flags
Definition at line 99 of file NVList.cpp. References add_element().
00100 { 00101 // call the helper to allocate a NamedValue element (if necessary) 00102 return this->add_element (flags); 00103 } |
|
Helper to increase the list size. This is used by all the add_ methods of the NVList class Definition at line 211 of file NVList.cpp. References ACE_BIT_DISABLED, ACE_NEW_THROW_EX, ACE_Unbounded_Queue< NamedValue_ptr >::enqueue_tail(), evaluate(), and values_. Referenced by add(), add_item(), add_item_consume(), and add_value().
00212 { 00213 this->evaluate (); 00214 00215 if (ACE_BIT_DISABLED (flags, 00216 CORBA::ARG_IN | CORBA::ARG_OUT | CORBA::ARG_INOUT)) 00217 { 00218 throw ::CORBA::BAD_PARAM (); 00219 } 00220 00221 CORBA::NamedValue_ptr nv; 00222 00223 // allocate a new NamedValue 00224 ACE_NEW_THROW_EX (nv, 00225 CORBA::NamedValue, 00226 CORBA::NO_MEMORY ()); 00227 00228 // set the flags and enqueue in the queue 00229 nv->flags_ = flags; 00230 00231 if (this->values_.enqueue_tail (nv) == -1) 00232 { 00233 delete nv; 00234 return 0; 00235 } 00236 00237 this->max_++; 00238 return nv; // success 00239 } |
|
add an element and initialize its name and flags
Definition at line 107 of file NVList.cpp. References add_element(), and CORBA::string_dup().
00108 { 00109 // call the helper to allocate a NamedValue element 00110 CORBA::NamedValue_ptr nv = this->add_element (flags); 00111 00112 if (nv) 00113 { 00114 // now initialize the fields 00115 nv->name_ = CORBA::string_dup (name); 00116 return nv; 00117 } 00118 else 00119 { 00120 return 0; 00121 } 00122 } |
|
just like add_item. In addition, memory management of char * name is taken over by the NVList Definition at line 154 of file NVList.cpp. References add_element().
00155 { 00156 00157 // call the helper to allocate a NamedValue element 00158 CORBA::NamedValue_ptr nv = this->add_element (flags); 00159 00160 if (nv) 00161 { 00162 // now initialize the fields 00163 00164 // consume the name 00165 nv->name_ = name; 00166 return nv; 00167 } 00168 else 00169 { 00170 return 0; 00171 } 00172 } |
|
initializes a value, name, and flags
Definition at line 126 of file NVList.cpp. References add_element(), and CORBA::string_dup().
00129 { 00130 // Call the helper to allocate a NamedValue element. 00131 CORBA::NamedValue_ptr nv = this->add_element (flags); 00132 00133 if (nv) 00134 { 00135 nv->name_ = CORBA::string_dup (name); 00136 00137 // With the original Any implementation, we had alternate 00138 // paths for the assignment based on the IN_COPY_VALUE flag. 00139 // Now that the Any's contained Any_Impl is refcounted, the 00140 // distinction between the ORB "copying" or "borrowing" the 00141 // memory is irrelevant. The IN_COPY_VALUE flag was not 00142 // checked anywhere else in the ORB anyway. 00143 nv->any_ = value; 00144 return nv; 00145 } 00146 else 00147 { 00148 return 0; 00149 } 00150 } |
|
just like add_value. In addition, the NVList controls the memory management of the char *name and Any *value parameter |
|
return the current number of elements in the list
Definition at line 102 of file NVList.inl. Referenced by _lazy_has_arguments().
00103 { 00104 (const_cast<CORBA::NVList *> (this))->evaluate (); 00105 00106 return this->max_; 00107 } |
|
Lazy evaluation routine to fill up the Anys in the NVList from the CDR stream. Definition at line 438 of file NVList.cpp. References _tao_decode(), ACE_GUARD, ACE_Auto_Basic_Ptr< X >::get(), incoming_flag_, and TAO_SYNCH_MUTEX. Referenced by add_element(), and item().
00439 { 00440 ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_); 00441 00442 if (this->incoming_ == 0) 00443 { 00444 return; 00445 } 00446 00447 auto_ptr<TAO_InputCDR> incoming (this->incoming_); 00448 this->incoming_ = 0; 00449 00450 this->_tao_decode (*(incoming.get ()), 00451 this->incoming_flag_ 00452 ); 00453 } |
|
retrieve the item at the nth location. Raises Bounds
Definition at line 243 of file NVList.cpp. References evaluate(), ACE_Unbounded_Queue< NamedValue_ptr >::get(), and values_.
|
|
remove element at index n. Raises Bounds
Definition at line 203 of file NVList.cpp.
00204 { 00205 // not implemented 00206 // @@ (ASG) - TODO 00207 } |
|
|
|
|
|
When the NVList is used as part of a Server Request we can simply store the CDR buffer and perform lazy evaluation to compute the Anys. |
|
The flags used to check which parameters are actually extracted from the buffer Definition at line 283 of file NVList.h. Referenced by _tao_incoming_cdr(), and evaluate(). |
|
Protects the incoming pointer.
|
|
Maximum length of list.
|
|
Reference counter.
|
|
Internal list of parameters stored as NamedValues.
Definition at line 263 of file NVList.h. Referenced by add_element(), and item(). |