00001
00002
00003 #include "orbsvcs/Trader/Trader.h"
00004 #include "orbsvcs/Trader/Offer_Iterators_T.h"
00005 #include "ace/Thread_Mutex.h"
00006 #include "ace/RW_Thread_Mutex.h"
00007 #include "ace/OS_NS_strings.h"
00008 #include "ace/OS_NS_string.h"
00009 #include "ace/OS_NS_ctype.h"
00010
00011
00012 #include "orbsvcs/Trader/Trader_Interfaces.h"
00013
00014 ACE_RCSID (Trader,
00015 Trader,
00016 "$Id: Trader.cpp 78268 2007-05-04 14:44:48Z johnnyw $")
00017
00018 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00019
00020 TAO_Trader_Base::TAO_Trader_Base (void)
00021 : trading_components_ (*this),
00022 import_attributes_ (*this),
00023 support_attributes_ (*this),
00024 link_attributes_ (*this)
00025 {
00026 }
00027
00028 TAO_Trader_Base::~TAO_Trader_Base (void)
00029 {
00030 }
00031
00032 TAO_Import_Attributes_i &
00033 TAO_Trader_Base::import_attributes (void)
00034 {
00035 return this->import_attributes_;
00036 }
00037
00038 const TAO_Import_Attributes_i &
00039 TAO_Trader_Base::import_attributes (void) const
00040 {
00041 return this->import_attributes_;
00042 }
00043
00044 TAO_Support_Attributes_i &
00045 TAO_Trader_Base::support_attributes (void)
00046 {
00047 return this->support_attributes_;
00048 }
00049
00050 const TAO_Support_Attributes_i &
00051 TAO_Trader_Base::support_attributes (void) const
00052 {
00053 return this->support_attributes_;
00054 }
00055
00056 TAO_Link_Attributes_i &
00057 TAO_Trader_Base::link_attributes (void)
00058 {
00059 return this->link_attributes_;
00060 }
00061
00062 const TAO_Link_Attributes_i &
00063 TAO_Trader_Base::link_attributes (void) const
00064 {
00065 return this->link_attributes_;
00066 }
00067
00068 TAO_Trading_Components_i &
00069 TAO_Trader_Base::trading_components (void)
00070 {
00071 return this->trading_components_;
00072 }
00073
00074 const TAO_Trading_Components_i &
00075 TAO_Trader_Base::trading_components (void) const
00076 {
00077 return this->trading_components_;
00078 }
00079
00080 CORBA::Boolean
00081 TAO_Trader_Base::is_valid_property_name (const char* ident)
00082 {
00083 bool return_value = false;
00084
00085 if (ident == 0)
00086 return return_value;
00087
00088 size_t length = ACE_OS::strlen (ident);
00089 if (length >= 1 && ACE_OS::ace_isalpha (ident[0]))
00090 {
00091 return_value = true;
00092 for (size_t i = 0; i < length; i++)
00093 {
00094 if (! (ACE_OS::ace_isalnum (ident[i]) || ident[i] == '_'))
00095 {
00096 return_value = false;
00097 break;
00098 }
00099 }
00100 }
00101
00102 return return_value;
00103 }
00104
00105 CORBA::Boolean
00106 TAO_Trader_Base::is_valid_identifier_name (const char* ident)
00107 {
00108 static char const * const double_colon = "::";
00109
00110 if (ident == 0)
00111 return 0;
00112
00113 int return_value = 1;
00114
00115
00116 CORBA::Boolean done = 0;
00117 char const * pos =
00118 ACE_OS::strstr (ident,
00119 double_colon);
00120
00121 do
00122 {
00123 if ('_' == ident[0])
00124 {
00125
00126 ++ident;
00127 }
00128
00129 size_t length =
00130 pos ? pos - ident : ACE_OS::strlen (ident);
00131
00132 if (length >= 1 && ACE_OS::ace_isalpha (ident[0]))
00133 {
00134
00135 for (size_t i = 0; i < length; ++i)
00136 {
00137 if (! (ACE_OS::ace_isalnum (ident[i])
00138 || ident[i] == '_'))
00139 {
00140
00141 return_value = 0;
00142 break;
00143 }
00144 }
00145 }
00146 else
00147 return_value = 0;
00148
00149 if (pos)
00150 {
00151
00152 ident = pos + 2;
00153 pos = ACE_OS::strstr (ident, double_colon);
00154 }
00155 else
00156 {
00157
00158 done = 1;
00159 }
00160 }
00161 while (!done);
00162
00163 return return_value;
00164 }
00165
00166 TAO_Lockable::~TAO_Lockable (void)
00167 {
00168 }
00169
00170 TAO_Support_Attributes_i::
00171 TAO_Support_Attributes_i (TAO_Lockable &locker)
00172 : locker_ (locker),
00173 supports_modifiable_properties_ (1),
00174 supports_dynamic_properties_ (1),
00175 supports_proxy_offers_ (0),
00176 type_repos_ (CosTrading::TypeRepository::_nil ()),
00177 service_type_repos_ (CosTradingRepos::ServiceTypeRepository::_nil ())
00178 {
00179 }
00180
00181 TAO_Support_Attributes_i::~TAO_Support_Attributes_i (void)
00182 {
00183 }
00184
00185 CORBA::Boolean
00186 TAO_Support_Attributes_i::supports_modifiable_properties (void) const
00187 {
00188 ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (),
00189 0);
00190 return this->supports_modifiable_properties_;
00191 }
00192
00193 void
00194 TAO_Support_Attributes_i::
00195 supports_modifiable_properties (CORBA::Boolean new_value)
00196 {
00197 ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00198 this->supports_modifiable_properties_ = new_value;
00199 }
00200
00201 CORBA::Boolean
00202 TAO_Support_Attributes_i::supports_dynamic_properties (void) const
00203 {
00204 ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (),
00205 0);
00206
00207 return this->supports_dynamic_properties_;
00208 }
00209
00210 void
00211 TAO_Support_Attributes_i::
00212 supports_dynamic_properties (CORBA::Boolean new_value)
00213 {
00214 ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00215 this->supports_dynamic_properties_ = new_value;
00216 }
00217
00218 CORBA::Boolean
00219 TAO_Support_Attributes_i::supports_proxy_offers (void) const
00220 {
00221 ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (),
00222 0);
00223
00224 return this->supports_proxy_offers_;
00225 }
00226
00227 void
00228 TAO_Support_Attributes_i::
00229 supports_proxy_offers (CORBA::Boolean new_value)
00230 {
00231 ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00232 this->supports_proxy_offers_ = new_value;
00233 }
00234
00235 CosTrading::TypeRepository_ptr
00236 TAO_Support_Attributes_i::type_repos (void) const
00237 {
00238 ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (),
00239 CosTrading::TypeRepository::_nil ());
00240 return this->type_repos_.ptr ();
00241 }
00242
00243 void
00244 TAO_Support_Attributes_i::
00245 type_repos (CosTrading::TypeRepository_ptr new_value)
00246 {
00247
00248 ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00249
00250 this->type_repos_ = new_value;
00251
00252 this->service_type_repos_ =
00253 CosTradingRepos::ServiceTypeRepository::_narrow (new_value);
00254 }
00255
00256 CosTradingRepos::ServiceTypeRepository_ptr
00257 TAO_Support_Attributes_i::service_type_repos (void) const
00258 {
00259 return this->service_type_repos_.ptr ();
00260 }
00261
00262
00263 TAO_Import_Attributes_i::
00264 TAO_Import_Attributes_i (TAO_Lockable &locker)
00265 : locker_ (locker),
00266 def_search_card_ (200),
00267 max_search_card_ (500),
00268 def_match_card_ (200),
00269 max_match_card_ (500),
00270 def_return_card_ (200),
00271 max_return_card_ (500),
00272 max_list_ (0),
00273 def_hop_count_ (5),
00274 max_hop_count_ (10),
00275 def_follow_policy_ (CosTrading::if_no_local),
00276 max_follow_policy_ (CosTrading::always)
00277 {
00278 }
00279
00280
00281 TAO_Import_Attributes_i::~TAO_Import_Attributes_i (void)
00282 {
00283 }
00284
00285 CORBA::ULong
00286 TAO_Import_Attributes_i::def_search_card (void) const
00287 {
00288 ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), 10);
00289 return this->def_search_card_;
00290 }
00291
00292 void
00293 TAO_Import_Attributes_i::def_search_card (CORBA::ULong new_value)
00294 {
00295 ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00296
00297 if (new_value > this->max_search_card_)
00298 this->def_search_card_ = this->max_search_card_;
00299 else
00300 this->def_search_card_ = new_value;
00301 }
00302
00303 CORBA::ULong
00304 TAO_Import_Attributes_i::max_search_card (void) const
00305 {
00306 ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), 10);
00307 return this->max_search_card_;
00308 }
00309
00310 void
00311 TAO_Import_Attributes_i::max_search_card (CORBA::ULong new_value)
00312 {
00313 ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00314
00315 this->max_search_card_ = new_value;
00316
00317 if (this->def_search_card_ > this->max_search_card_)
00318 this->def_search_card_ = this->max_search_card_;
00319 }
00320
00321 CORBA::ULong
00322 TAO_Import_Attributes_i::def_match_card (void) const
00323 {
00324 ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), 10);
00325 return this->def_match_card_;
00326 }
00327
00328 void
00329 TAO_Import_Attributes_i::def_match_card (CORBA::ULong new_value)
00330 {
00331 ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00332
00333 if (new_value > this->max_match_card_)
00334 this->def_match_card_ = this->max_match_card_;
00335 else
00336 this->def_match_card_ = new_value;
00337 }
00338
00339 CORBA::ULong
00340 TAO_Import_Attributes_i::max_match_card (void) const
00341 {
00342 ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), 10);
00343 return this->max_match_card_;
00344 }
00345
00346 void
00347 TAO_Import_Attributes_i::max_match_card (CORBA::ULong new_value)
00348 {
00349 ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00350 this->max_match_card_ = new_value;
00351
00352 if (this->def_match_card_ > this->max_match_card_)
00353 this->def_match_card_ = this->max_match_card_;
00354 }
00355
00356 CORBA::ULong
00357 TAO_Import_Attributes_i::def_return_card (void) const
00358 {
00359 ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), 10);
00360 return this->def_return_card_;
00361 }
00362
00363 void
00364 TAO_Import_Attributes_i::def_return_card (CORBA::ULong new_value)
00365 {
00366 ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00367
00368 if (new_value > this->max_return_card_)
00369 this->def_return_card_ = this->max_return_card_;
00370 else
00371 this->def_return_card_ = new_value;
00372 }
00373
00374 CORBA::ULong
00375 TAO_Import_Attributes_i::max_return_card (void) const
00376 {
00377 ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), 10);
00378 return this->max_return_card_;
00379 }
00380
00381 void
00382 TAO_Import_Attributes_i::max_return_card (CORBA::ULong new_value)
00383 {
00384 ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00385 this->max_return_card_ = new_value;
00386
00387 if (this->def_return_card_ > this->max_return_card_)
00388 this->def_return_card_ = this->max_return_card_;
00389 }
00390
00391 CORBA::ULong
00392 TAO_Import_Attributes_i::max_list (void) const
00393 {
00394 ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), 0);
00395 return this->max_list_;
00396 }
00397
00398 void
00399 TAO_Import_Attributes_i::max_list (CORBA::ULong new_value)
00400 {
00401 ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00402 this->max_list_ = new_value;
00403 }
00404
00405 CORBA::ULong
00406 TAO_Import_Attributes_i::def_hop_count (void) const
00407 {
00408 ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), 0);
00409 return this->def_hop_count_;
00410 }
00411
00412 void
00413 TAO_Import_Attributes_i::def_hop_count (CORBA::ULong new_value)
00414 {
00415 ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00416
00417 if (new_value > this->max_hop_count_)
00418 this->def_hop_count_ = this->max_hop_count_;
00419 else
00420 this->def_hop_count_ = new_value;
00421 }
00422
00423 CORBA::ULong
00424 TAO_Import_Attributes_i::max_hop_count (void) const
00425 {
00426 ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), 0);
00427 return this->max_hop_count_;
00428 }
00429
00430 void
00431 TAO_Import_Attributes_i::max_hop_count (CORBA::ULong new_value)
00432 {
00433 ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00434 this->max_hop_count_ = new_value;
00435
00436 if (this->def_hop_count_ > this->max_hop_count_)
00437 this->def_hop_count_ = this->max_hop_count_;
00438 }
00439
00440 CosTrading::FollowOption
00441 TAO_Import_Attributes_i::def_follow_policy (void) const
00442 {
00443 ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), CosTrading::local_only);
00444 return this->def_follow_policy_;
00445 }
00446
00447 void
00448 TAO_Import_Attributes_i::def_follow_policy (CosTrading::FollowOption new_value)
00449 {
00450 ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00451
00452 if (new_value > this->max_follow_policy_)
00453 this->def_follow_policy_ = this->max_follow_policy_;
00454 else
00455 this->def_follow_policy_ = new_value;
00456 }
00457
00458 CosTrading::FollowOption
00459 TAO_Import_Attributes_i::max_follow_policy (void) const
00460 {
00461 ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), CosTrading::local_only);
00462 return this->max_follow_policy_;
00463 }
00464
00465 void
00466 TAO_Import_Attributes_i::max_follow_policy (CosTrading::FollowOption new_value)
00467 {
00468 ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00469 this->max_follow_policy_ = new_value;
00470
00471 if (this->def_follow_policy_ > this->max_follow_policy_)
00472 this->def_follow_policy_ = this->max_follow_policy_;
00473 }
00474
00475
00476 TAO_Trading_Components_i::TAO_Trading_Components_i (TAO_Lockable &locker)
00477 : locker_ (locker),
00478 lookup_ (CosTrading::Lookup::_nil ()),
00479 register_ (CosTrading::Register::_nil ()),
00480 link_ (CosTrading::Link::_nil ()),
00481 proxy_ (CosTrading::Proxy::_nil ()),
00482 admin_ (CosTrading::Admin::_nil ())
00483 {
00484 }
00485
00486 TAO_Trading_Components_i::~TAO_Trading_Components_i (void)
00487 {
00488 }
00489
00490 CosTrading::Lookup_ptr
00491 TAO_Trading_Components_i::lookup_if (void) const
00492 {
00493 ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (),
00494 CosTrading::Lookup::_nil ());
00495 return this->lookup_.ptr ();
00496 }
00497
00498 void
00499 TAO_Trading_Components_i::lookup_if (CosTrading::Lookup_ptr new_value)
00500 {
00501 ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00502 this->lookup_ = new_value;
00503 }
00504
00505 CosTrading::Register_ptr
00506 TAO_Trading_Components_i::register_if (void) const
00507 {
00508 ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (),
00509 CosTrading::Register::_nil ());
00510 return this->register_.ptr ();
00511 }
00512
00513 void
00514 TAO_Trading_Components_i::register_if (CosTrading::Register_ptr new_value)
00515 {
00516 ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00517 this->register_ = new_value;
00518 }
00519
00520 CosTrading::Link_ptr
00521 TAO_Trading_Components_i::link_if (void) const
00522 {
00523 ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (),
00524 CosTrading::Link::_nil ());
00525 return this->link_.ptr ();
00526 }
00527
00528 void
00529 TAO_Trading_Components_i::link_if (CosTrading::Link_ptr new_value)
00530 {
00531 ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00532 this->link_ = new_value;
00533 }
00534
00535 CosTrading::Proxy_ptr
00536 TAO_Trading_Components_i::proxy_if (void) const
00537 {
00538 ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (),
00539 CosTrading::Proxy::_nil ());
00540 return this->proxy_.ptr ();
00541 }
00542
00543 void
00544 TAO_Trading_Components_i::proxy_if (CosTrading::Proxy_ptr new_value)
00545 {
00546 ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00547 this->proxy_ = new_value;
00548 }
00549
00550 CosTrading::Admin_ptr
00551 TAO_Trading_Components_i::admin_if (void) const
00552 {
00553 ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (),
00554 CosTrading::Admin::_nil ());
00555 return this->admin_.ptr ();
00556 }
00557
00558 void
00559 TAO_Trading_Components_i::admin_if (CosTrading::Admin_ptr new_value)
00560 {
00561 ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00562 this->admin_ = new_value;
00563 }
00564
00565
00566 TAO_Link_Attributes_i::TAO_Link_Attributes_i (TAO_Lockable &locker)
00567 :locker_ (locker),
00568 max_link_follow_policy_ (CosTrading::local_only)
00569 {
00570 }
00571
00572 TAO_Link_Attributes_i::~TAO_Link_Attributes_i (void)
00573 {
00574 }
00575
00576 CosTrading::FollowOption
00577 TAO_Link_Attributes_i::max_link_follow_policy (void) const
00578 {
00579 ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (),
00580 CosTrading::local_only);
00581 return this->max_link_follow_policy_;
00582 }
00583
00584 void
00585 TAO_Link_Attributes_i::max_link_follow_policy (CosTrading::FollowOption new_value)
00586 {
00587 ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00588 this->max_link_follow_policy_ = new_value;
00589 }
00590
00591 bool
00592 operator< (const CosTradingRepos::ServiceTypeRepository::IncarnationNumber &l,
00593 const CosTradingRepos::ServiceTypeRepository::IncarnationNumber &r)
00594 {
00595 if (l.high < r.high)
00596 return true;
00597 else if (l.high == r.high)
00598 return (l.low < r.low);
00599 else
00600 return false;
00601 }
00602
00603 bool
00604 operator> (const CosTradingRepos::ServiceTypeRepository::IncarnationNumber &l,
00605 const CosTradingRepos::ServiceTypeRepository::IncarnationNumber &r)
00606 {
00607 return (r < l);
00608 }
00609
00610 bool
00611 operator== (const CosTrading::Admin::OctetSeq& left,
00612 const CosTrading::Admin::OctetSeq& right)
00613 {
00614 bool return_value = false;
00615
00616 const CORBA::ULong left_length = left.length ();
00617 const CORBA::ULong right_length = right.length ();
00618
00619 if (left_length == right_length)
00620 {
00621 return_value = true;
00622
00623 for (CORBA::ULong i = 0; i < left_length; ++i)
00624 {
00625 if (left[i] != right[i])
00626 {
00627 return_value = false;
00628 break;
00629 }
00630 }
00631 }
00632
00633 return return_value;
00634 }
00635
00636 TAO_END_VERSIONED_NAMESPACE_DECL
00637
00638 #include "ace/Arg_Shifter.h"
00639 #include "orbsvcs/Trader/Trader_T.h"
00640
00641 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00642
00643 TAO_Trader_Factory::TAO_TRADER*
00644 TAO_Trader_Factory::create_trader (int& argc, ACE_TCHAR** argv)
00645 {
00646 TAO_Trader_Factory trader_factory (argc, argv);
00647 return trader_factory.manufacture_trader ();
00648 }
00649
00650 TAO_Trader_Factory::TAO_Trader_Factory (int& argc, ACE_TCHAR** argv)
00651 : conformance_ (TAO_TRADER_LINKED),
00652 threadsafe_ (0),
00653 supports_dynamic_properties_ (1),
00654 supports_modifiable_properties_ (1),
00655 def_search_card_ (20),
00656 max_search_card_ (50),
00657 def_match_card_ (20),
00658 max_match_card_ (50),
00659 def_return_card_ (20),
00660 max_return_card_ (50),
00661 def_hop_count_ (5),
00662 max_hop_count_ (10),
00663 def_follow_policy_ (CosTrading::if_no_local),
00664 max_follow_policy_ (CosTrading::always)
00665 {
00666 this->parse_args (argc, argv);
00667 }
00668
00669 TAO_Trader_Factory::TAO_TRADER *
00670 TAO_Trader_Factory::manufacture_trader (void)
00671 {
00672 typedef TAO_Trader<ACE_Null_Mutex, ACE_Null_Mutex> TRADER;
00673
00674 #if defined ACE_HAS_THREADS
00675 typedef TAO_Trader<TAO_SYNCH_MUTEX, TAO_SYNCH_RW_MUTEX> MT_TRADER;
00676 #else
00677 typedef TAO_Trader<ACE_Null_Mutex, ACE_Null_Mutex> MT_TRADER;
00678 #endif
00679
00680 TAO_TRADER* return_value = 0;
00681 int components = static_cast<int> (TAO_Trader_Base::LOOKUP);
00682
00683 if (this->conformance_ >= TAO_TRADER_SIMPLE)
00684 components |= static_cast<int> (TAO_Trader_Base::REGISTER);
00685
00686 if (this->conformance_ >= TAO_TRADER_STANDALONE)
00687 components |= static_cast<int> (TAO_Trader_Base::ADMIN);
00688
00689 if (this->conformance_ >= TAO_TRADER_LINKED)
00690 components |= static_cast<int> (TAO_Trader_Base::LINK);
00691
00692 if (this->threadsafe_)
00693 ACE_NEW_RETURN (return_value,
00694 MT_TRADER (static_cast<TAO_Trader_Base::Trader_Components> (components)),
00695 0);
00696 else
00697 ACE_NEW_RETURN (return_value,
00698 TRADER (static_cast<TAO_Trader_Base::Trader_Components> (components)),
00699 0);
00700
00701 TAO_Import_Attributes_i &import_attributes =
00702 return_value->import_attributes ();
00703 TAO_Support_Attributes_i &support_attributes =
00704 return_value->support_attributes ();
00705
00706 import_attributes.max_search_card (this->max_search_card_);
00707 import_attributes.def_search_card (this->def_search_card_);
00708 import_attributes.max_match_card (this->max_match_card_);
00709 import_attributes.def_match_card (this->def_match_card_);
00710 import_attributes.max_return_card (this->max_return_card_);
00711 import_attributes.def_return_card (this->def_return_card_);
00712 import_attributes.max_hop_count (this->max_hop_count_);
00713 import_attributes.def_hop_count (this->def_hop_count_);
00714 import_attributes.max_follow_policy (this->max_follow_policy_);
00715 import_attributes.def_follow_policy (this->def_follow_policy_);
00716 support_attributes.supports_modifiable_properties (this->supports_modifiable_properties_);
00717 support_attributes.supports_dynamic_properties (this->supports_dynamic_properties_);
00718
00719 return return_value;
00720 }
00721
00722 void
00723 TAO_Trader_Factory::parse_args (int& argc, ACE_TCHAR** argv)
00724 {
00725 ACE_Arg_Shifter arg_shifter (argc, argv);
00726
00727 while (arg_shifter.is_anything_left ())
00728 {
00729 const ACE_TCHAR* current_arg = arg_shifter.get_current ();
00730
00731 if (ACE_OS::strcmp (current_arg, ACE_TEXT("-TSthreadsafe")) == 0)
00732 {
00733 arg_shifter.consume_arg ();
00734 this->threadsafe_ = 1;
00735 }
00736 else if (ACE_OS::strcmp (current_arg, ACE_TEXT("-TSconformance")) == 0)
00737 {
00738 arg_shifter.consume_arg ();
00739 if (arg_shifter.is_parameter_next ())
00740 {
00741 const ACE_TCHAR* conformance_str = arg_shifter.get_current ();
00742
00743 if (ACE_OS::strcasecmp (conformance_str, ACE_TEXT("Linked")) == 0)
00744 this->conformance_ = TAO_TRADER_LINKED;
00745 else if (ACE_OS::strcasecmp (conformance_str, ACE_TEXT("Query")) == 0)
00746 this->conformance_ = TAO_TRADER_QUERY;
00747 else if (ACE_OS::strcasecmp (conformance_str, ACE_TEXT("Simple")) == 0)
00748 this->conformance_ = TAO_TRADER_SIMPLE;
00749 else if (ACE_OS::strcasecmp (conformance_str, ACE_TEXT("Standalone")) == 0)
00750 this->conformance_ = TAO_TRADER_STANDALONE;
00751
00752 arg_shifter.consume_arg ();
00753 }
00754 }
00755 else if (ACE_OS::strcmp (current_arg, ACE_TEXT("-TSsupports_dynamic_properties")) == 0)
00756 {
00757 arg_shifter.consume_arg ();
00758 if (arg_shifter.is_parameter_next ())
00759 {
00760 const ACE_TCHAR* arg_str = arg_shifter.get_current ();
00761
00762 if (ACE_OS::strcasecmp (arg_str, ACE_TEXT("true")) == 0)
00763 this->supports_dynamic_properties_ = 1;
00764 else if (ACE_OS::strcasecmp (arg_str, ACE_TEXT("false")) == 0)
00765 this->supports_dynamic_properties_ = 0;
00766
00767 arg_shifter.consume_arg ();
00768 }
00769
00770 }
00771 else if (ACE_OS::strcmp (current_arg, ACE_TEXT("-TSsupports_modifiable_properties")) == 0)
00772 {
00773 arg_shifter.consume_arg ();
00774 if (arg_shifter.is_parameter_next ())
00775 {
00776 const ACE_TCHAR* arg_str = arg_shifter.get_current ();
00777
00778 if (ACE_OS::strcasecmp (arg_str, ACE_TEXT("true")) == 0)
00779 this->supports_modifiable_properties_ = 1;
00780 else if (ACE_OS::strcasecmp (arg_str, ACE_TEXT("false")) == 0)
00781 this->supports_modifiable_properties_ = 0;
00782
00783 arg_shifter.consume_arg ();
00784 }
00785 }
00786 else if (ACE_OS::strcmp (current_arg, ACE_TEXT("-TSdef_search_card")) == 0 ||
00787 ACE_OS::strcmp (current_arg, ACE_TEXT("-TSmax_search_card")) == 0 ||
00788 ACE_OS::strcmp (current_arg, ACE_TEXT("-TSdef_match_card")) == 0 ||
00789 ACE_OS::strcmp (current_arg, ACE_TEXT("-TSmax_match_card")) == 0 ||
00790 ACE_OS::strcmp (current_arg, ACE_TEXT("-TSdef_return_card")) == 0 ||
00791 ACE_OS::strcmp (current_arg, ACE_TEXT("-TSmax_return_card")) == 0 ||
00792 ACE_OS::strcmp (current_arg, ACE_TEXT("-TSdef_hop_count")) == 0 ||
00793 ACE_OS::strcmp (current_arg, ACE_TEXT("-TSmax_hop_count")) == 0)
00794 {
00795 arg_shifter.consume_arg ();
00796 if (arg_shifter.is_parameter_next ())
00797 {
00798 CORBA::ULong value =
00799 static_cast<CORBA::ULong> (ACE_OS::atoi (arg_shifter.get_current ()));
00800 arg_shifter.consume_arg ();
00801
00802 if (ACE_OS::strstr (current_arg, ACE_TEXT("card")))
00803 {
00804 if (ACE_OS::strstr (current_arg, ACE_TEXT("max")))
00805 {
00806 if (ACE_OS::strstr (current_arg, ACE_TEXT("search")))
00807 this->max_search_card_ = value;
00808 else if (ACE_OS::strstr (current_arg, ACE_TEXT("match")))
00809 this->max_match_card_ = value;
00810 else
00811 this->max_return_card_ = value;
00812 }
00813 else
00814 {
00815 if (ACE_OS::strstr (current_arg, ACE_TEXT("search")))
00816 this->def_search_card_ = value;
00817 else if (ACE_OS::strstr (current_arg, ACE_TEXT("match")))
00818 this->def_match_card_ = value;
00819 else
00820 this->def_return_card_ = value;
00821 }
00822 }
00823 else
00824 {
00825 if (ACE_OS::strstr (current_arg, ACE_TEXT("max")))
00826 this->max_hop_count_ = value;
00827 else
00828 this->def_hop_count_ = value;
00829 }
00830 }
00831 }
00832 else if (ACE_OS::strcmp (current_arg, ACE_TEXT("-TSdef_follow_policy")) == 0
00833 || ACE_OS::strcmp (current_arg, ACE_TEXT("-TSmax_follow_policy")) == 0)
00834 {
00835 arg_shifter.consume_arg ();
00836 if (arg_shifter.is_parameter_next ())
00837 {
00838 const ACE_TCHAR* arg_str = arg_shifter.get_current ();
00839 CosTrading::FollowOption follow_option;
00840
00841 if (ACE_OS::strcasecmp (arg_str, ACE_TEXT("always")) == 0)
00842 follow_option = CosTrading::always;
00843 else if (ACE_OS::strcasecmp (arg_str, ACE_TEXT("if_no_local")) == 0)
00844 follow_option = CosTrading::if_no_local;
00845 else if (ACE_OS::strcasecmp (arg_str, ACE_TEXT("local_only")) == 0)
00846 follow_option = CosTrading::local_only;
00847 else if (ACE_OS::strstr (current_arg, ACE_TEXT("def")))
00848 follow_option = this->def_follow_policy_;
00849 else
00850 follow_option = this->max_follow_policy_;
00851
00852 if (ACE_OS::strstr (current_arg, ACE_TEXT("def")))
00853 this->def_follow_policy_ = follow_option;
00854 else
00855 this->max_follow_policy_ = follow_option;
00856
00857 arg_shifter.consume_arg ();
00858 }
00859 }
00860 else
00861 arg_shifter.ignore_arg ();
00862 }
00863 }
00864
00865 TAO_END_VERSIONED_NAMESPACE_DECL