Trader.cpp

Go to the documentation of this file.
00001 // Trader.cpp,v 1.82 2006/03/14 06:14:35 jtc Exp
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 // The following #include is needed only for the instantiation pragmas.
00012 #include "orbsvcs/Trader/Trader_Interfaces.h"
00013 
00014 ACE_RCSID (Trader,
00015            Trader,
00016            "Trader.cpp,v 1.82 2006/03/14 06:14:35 jtc Exp")
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   // Allow scoped identifiers
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         // Treat escaped identifiers the same way as IDL
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         // First character must be alpha
00135         for (size_t i = 0; i < length; ++i)
00136           {
00137             if (! (ACE_OS::ace_isalnum (ident[i])
00138                    || ident[i] == '_'))
00139               {
00140                 // Subsequent characters is not alpha, numeric, or '_'
00141                 return_value = 0;
00142                 break;
00143               }
00144           }
00145       }
00146     else
00147       return_value = 0;
00148 
00149     if (pos)
00150       {
00151         // More identifiers
00152         ident = pos + 2;
00153         pos = ACE_OS::strstr (ident, double_colon);
00154       }
00155     else
00156       {
00157         // Last or only identifier
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   // @@ Seth, There is no way to propagate the exception out.
00248   ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00249 
00250   ACE_DECLARE_NEW_CORBA_ENV;
00251   this->type_repos_ = new_value;
00252   // @@ What can we do even if we catch this?
00253   this->service_type_repos_ =
00254     CosTradingRepos::ServiceTypeRepository::_narrow (new_value ACE_ENV_ARG_PARAMETER);
00255 }
00256 
00257 CosTradingRepos::ServiceTypeRepository_ptr
00258 TAO_Support_Attributes_i::service_type_repos (void) const
00259 {
00260   return this->service_type_repos_.ptr ();
00261 }
00262 
00263 
00264 TAO_Import_Attributes_i::
00265 TAO_Import_Attributes_i (TAO_Lockable &locker)
00266   : locker_ (locker),
00267     def_search_card_ (200),
00268     max_search_card_ (500),
00269     def_match_card_ (200),
00270     max_match_card_ (500),
00271     def_return_card_ (200),
00272     max_return_card_ (500),
00273     max_list_ (0),
00274     def_hop_count_ (5),
00275     max_hop_count_ (10),
00276     def_follow_policy_ (CosTrading::if_no_local),
00277     max_follow_policy_ (CosTrading::always)
00278 {
00279 }
00280 
00281 
00282 TAO_Import_Attributes_i::~TAO_Import_Attributes_i (void)
00283 {
00284 }
00285 
00286 CORBA::ULong
00287 TAO_Import_Attributes_i::def_search_card (void) const
00288 {
00289   ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), 10);
00290   return this->def_search_card_;
00291 }
00292 
00293 void
00294 TAO_Import_Attributes_i::def_search_card (CORBA::ULong new_value)
00295 {
00296   ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00297 
00298   if (new_value > this->max_search_card_)
00299     this->def_search_card_ = this->max_search_card_;
00300   else
00301     this->def_search_card_ = new_value;
00302 }
00303 
00304 CORBA::ULong
00305 TAO_Import_Attributes_i::max_search_card (void) const
00306 {
00307   ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), 10);
00308   return this->max_search_card_;
00309 }
00310 
00311 void
00312 TAO_Import_Attributes_i::max_search_card (CORBA::ULong new_value)
00313 {
00314   ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00315 
00316   this->max_search_card_ = new_value;
00317 
00318   if (this->def_search_card_ > this->max_search_card_)
00319     this->def_search_card_ = this->max_search_card_;
00320 }
00321 
00322 CORBA::ULong
00323 TAO_Import_Attributes_i::def_match_card (void) const
00324 {
00325   ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), 10);
00326   return this->def_match_card_;
00327 }
00328 
00329 void
00330 TAO_Import_Attributes_i::def_match_card (CORBA::ULong new_value)
00331 {
00332   ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00333 
00334   if (new_value > this->max_match_card_)
00335     this->def_match_card_ = this->max_match_card_;
00336   else
00337     this->def_match_card_ = new_value;
00338 }
00339 
00340 CORBA::ULong
00341 TAO_Import_Attributes_i::max_match_card (void) const
00342 {
00343   ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), 10);
00344   return this->max_match_card_;
00345 }
00346 
00347 void
00348 TAO_Import_Attributes_i::max_match_card (CORBA::ULong new_value)
00349 {
00350   ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00351   this->max_match_card_ = new_value;
00352 
00353   if (this->def_match_card_ > this->max_match_card_)
00354     this->def_match_card_ = this->max_match_card_;
00355 }
00356 
00357 CORBA::ULong
00358 TAO_Import_Attributes_i::def_return_card (void) const
00359 {
00360   ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), 10);
00361   return this->def_return_card_;
00362 }
00363 
00364 void
00365 TAO_Import_Attributes_i::def_return_card (CORBA::ULong new_value)
00366 {
00367   ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00368 
00369   if (new_value > this->max_return_card_)
00370     this->def_return_card_ = this->max_return_card_;
00371   else
00372     this->def_return_card_ = new_value;
00373 }
00374 
00375 CORBA::ULong
00376 TAO_Import_Attributes_i::max_return_card (void) const
00377 {
00378   ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), 10);
00379   return this->max_return_card_;
00380 }
00381 
00382 void
00383 TAO_Import_Attributes_i::max_return_card (CORBA::ULong new_value)
00384 {
00385   ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00386   this->max_return_card_ = new_value;
00387 
00388   if (this->def_return_card_ > this->max_return_card_)
00389     this->def_return_card_ = this->max_return_card_;
00390 }
00391 
00392 CORBA::ULong
00393 TAO_Import_Attributes_i::max_list (void) const
00394 {
00395   ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), 0);
00396   return this->max_list_;
00397 }
00398 
00399 void
00400 TAO_Import_Attributes_i::max_list (CORBA::ULong new_value)
00401 {
00402   ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00403   this->max_list_ = new_value;
00404 }
00405 
00406 CORBA::ULong
00407 TAO_Import_Attributes_i::def_hop_count (void) const
00408 {
00409   ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), 0);
00410   return this->def_hop_count_;
00411 }
00412 
00413 void
00414 TAO_Import_Attributes_i::def_hop_count (CORBA::ULong new_value)
00415 {
00416   ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00417 
00418   if (new_value > this->max_hop_count_)
00419     this->def_hop_count_ = this->max_hop_count_;
00420   else
00421     this->def_hop_count_ = new_value;
00422 }
00423 
00424 CORBA::ULong
00425 TAO_Import_Attributes_i::max_hop_count (void) const
00426 {
00427   ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), 0);
00428   return this->max_hop_count_;
00429 }
00430 
00431 void
00432 TAO_Import_Attributes_i::max_hop_count (CORBA::ULong new_value)
00433 {
00434   ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00435   this->max_hop_count_ = new_value;
00436 
00437   if (this->def_hop_count_ > this->max_hop_count_)
00438     this->def_hop_count_ = this->max_hop_count_;
00439 }
00440 
00441 CosTrading::FollowOption
00442 TAO_Import_Attributes_i::def_follow_policy (void) const
00443 {
00444   ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), CosTrading::local_only);
00445   return this->def_follow_policy_;
00446 }
00447 
00448 void
00449 TAO_Import_Attributes_i::def_follow_policy (CosTrading::FollowOption new_value)
00450 {
00451   ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00452 
00453   if (new_value > this->max_follow_policy_)
00454     this->def_follow_policy_ = this->max_follow_policy_;
00455   else
00456     this->def_follow_policy_ = new_value;
00457 }
00458 
00459 CosTrading::FollowOption
00460 TAO_Import_Attributes_i::max_follow_policy (void) const
00461 {
00462   ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (), CosTrading::local_only);
00463   return this->max_follow_policy_;
00464 }
00465 
00466 void
00467 TAO_Import_Attributes_i::max_follow_policy (CosTrading::FollowOption new_value)
00468 {
00469   ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00470   this->max_follow_policy_ = new_value;
00471 
00472   if (this->def_follow_policy_ > this->max_follow_policy_)
00473     this->def_follow_policy_ = this->max_follow_policy_;
00474 }
00475 
00476 
00477 TAO_Trading_Components_i::TAO_Trading_Components_i (TAO_Lockable &locker)
00478   : locker_ (locker),
00479     lookup_ (CosTrading::Lookup::_nil ()),
00480     register_ (CosTrading::Register::_nil ()),
00481     link_ (CosTrading::Link::_nil ()),
00482     proxy_ (CosTrading::Proxy::_nil ()),
00483     admin_ (CosTrading::Admin::_nil ())
00484 {
00485 }
00486 
00487 TAO_Trading_Components_i::~TAO_Trading_Components_i (void)
00488 {
00489 }
00490 
00491 CosTrading::Lookup_ptr
00492 TAO_Trading_Components_i::lookup_if (void) const
00493 {
00494   ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (),
00495                          CosTrading::Lookup::_nil ());
00496   return this->lookup_.ptr ();
00497 }
00498 
00499 void
00500 TAO_Trading_Components_i::lookup_if (CosTrading::Lookup_ptr new_value)
00501 {
00502   ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00503   this->lookup_ = new_value;
00504 }
00505 
00506 CosTrading::Register_ptr
00507 TAO_Trading_Components_i::register_if (void) const
00508 {
00509   ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (),
00510                          CosTrading::Register::_nil ());
00511   return this->register_.ptr ();
00512 }
00513 
00514 void
00515 TAO_Trading_Components_i::register_if (CosTrading::Register_ptr new_value)
00516 {
00517   ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00518   this->register_ = new_value;
00519 }
00520 
00521 CosTrading::Link_ptr
00522 TAO_Trading_Components_i::link_if (void) const
00523 {
00524   ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (),
00525                          CosTrading::Link::_nil ());
00526   return this->link_.ptr ();
00527 }
00528 
00529 void
00530 TAO_Trading_Components_i::link_if (CosTrading::Link_ptr new_value)
00531 {
00532   ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00533   this->link_ = new_value;
00534 }
00535 
00536 CosTrading::Proxy_ptr
00537 TAO_Trading_Components_i::proxy_if (void) const
00538 {
00539   ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (),
00540                          CosTrading::Proxy::_nil ());
00541   return this->proxy_.ptr ();
00542 }
00543 
00544 void
00545 TAO_Trading_Components_i::proxy_if (CosTrading::Proxy_ptr new_value)
00546 {
00547   ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00548   this->proxy_ = new_value;
00549 }
00550 
00551 CosTrading::Admin_ptr
00552 TAO_Trading_Components_i::admin_if (void) const
00553 {
00554   ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (),
00555                          CosTrading::Admin::_nil ());
00556   return this->admin_.ptr ();
00557 }
00558 
00559 void
00560 TAO_Trading_Components_i::admin_if (CosTrading::Admin_ptr new_value)
00561 {
00562   ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00563   this->admin_ = new_value;
00564 }
00565 
00566 
00567 TAO_Link_Attributes_i::TAO_Link_Attributes_i (TAO_Lockable &locker)
00568   :locker_ (locker),
00569    max_link_follow_policy_ (CosTrading::local_only)
00570 {
00571 }
00572 
00573 TAO_Link_Attributes_i::~TAO_Link_Attributes_i (void)
00574 {
00575 }
00576 
00577 CosTrading::FollowOption
00578 TAO_Link_Attributes_i::max_link_follow_policy (void) const
00579 {
00580   ACE_READ_GUARD_RETURN (ACE_Lock, ace_mon, this->locker_.lock (),
00581                          CosTrading::local_only);
00582   return this->max_link_follow_policy_;
00583 }
00584 
00585 void
00586 TAO_Link_Attributes_i::max_link_follow_policy (CosTrading::FollowOption new_value)
00587 {
00588   ACE_WRITE_GUARD (ACE_Lock, ace_mon, this->locker_.lock ());
00589   this->max_link_follow_policy_ = new_value;
00590 }
00591 
00592 bool
00593 operator< (const CosTradingRepos::ServiceTypeRepository::IncarnationNumber &l,
00594            const CosTradingRepos::ServiceTypeRepository::IncarnationNumber &r)
00595 {
00596   if (l.high < r.high)
00597     return true;
00598   else if (l.high == r.high)
00599     return (l.low < r.low);
00600   else
00601     return false;
00602 }
00603 
00604 bool
00605 operator> (const CosTradingRepos::ServiceTypeRepository::IncarnationNumber &l,
00606            const CosTradingRepos::ServiceTypeRepository::IncarnationNumber &r)
00607 {
00608   return (r < l);
00609 }
00610 
00611 bool
00612 operator== (const CosTrading::Admin::OctetSeq& left,
00613             const CosTrading::Admin::OctetSeq& right)
00614 {
00615   bool return_value = false;
00616 
00617   const CORBA::ULong left_length = left.length ();
00618   const CORBA::ULong right_length = right.length ();
00619 
00620   if (left_length == right_length)
00621     {
00622       return_value = true;
00623 
00624       for (CORBA::ULong i = 0; i < left_length; ++i)
00625         {
00626           if (left[i] != right[i])
00627             {
00628               return_value = false;
00629               break;
00630             }
00631         }
00632     }
00633 
00634   return return_value;
00635 }
00636 
00637 TAO_END_VERSIONED_NAMESPACE_DECL
00638 
00639 #include "ace/Arg_Shifter.h"
00640 #include "orbsvcs/Trader/Trader_T.h"
00641 
00642 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00643 
00644 TAO_Trader_Factory::TAO_TRADER*
00645 TAO_Trader_Factory::create_trader (int& argc, ACE_TCHAR** argv)
00646 {
00647   TAO_Trader_Factory trader_factory (argc, argv);
00648   return trader_factory.manufacture_trader ();
00649 }
00650 
00651 TAO_Trader_Factory::TAO_Trader_Factory (int& argc, ACE_TCHAR** argv)
00652   : conformance_ (TAO_TRADER_LINKED),
00653     threadsafe_ (0),
00654     supports_dynamic_properties_ (1),
00655     supports_modifiable_properties_ (1),
00656     def_search_card_ (20),
00657     max_search_card_ (50),
00658     def_match_card_ (20),
00659     max_match_card_ (50),
00660     def_return_card_ (20),
00661     max_return_card_ (50),
00662     def_hop_count_ (5),
00663     max_hop_count_ (10),
00664     def_follow_policy_ (CosTrading::if_no_local),
00665     max_follow_policy_ (CosTrading::always)
00666 {
00667   this->parse_args (argc, argv);
00668 }
00669 
00670 TAO_Trader_Factory::TAO_TRADER *
00671 TAO_Trader_Factory::manufacture_trader (void)
00672 {
00673   typedef TAO_Trader<ACE_Null_Mutex, ACE_Null_Mutex> TRADER;
00674 
00675 #if defined ACE_HAS_THREADS
00676   typedef TAO_Trader<TAO_SYNCH_MUTEX, TAO_SYNCH_RW_MUTEX>  MT_TRADER;
00677 #else
00678   typedef TAO_Trader<ACE_Null_Mutex, ACE_Null_Mutex>  MT_TRADER;
00679 #endif /* ACE_HAS_THREADS */
00680 
00681   TAO_TRADER* return_value = 0;
00682   int components = static_cast<int> (TAO_Trader_Base::LOOKUP);
00683 
00684   if (this->conformance_ >= TAO_TRADER_SIMPLE)
00685     components |= static_cast<int> (TAO_Trader_Base::REGISTER);
00686 
00687   if (this->conformance_ >= TAO_TRADER_STANDALONE)
00688     components |= static_cast<int> (TAO_Trader_Base::ADMIN);
00689 
00690   if (this->conformance_ >= TAO_TRADER_LINKED)
00691     components |= static_cast<int> (TAO_Trader_Base::LINK);
00692 
00693   if (this->threadsafe_)
00694     ACE_NEW_RETURN (return_value,
00695                     MT_TRADER (static_cast<TAO_Trader_Base::Trader_Components> (components)),
00696                     0);
00697   else
00698     ACE_NEW_RETURN (return_value,
00699                     TRADER (static_cast<TAO_Trader_Base::Trader_Components> (components)),
00700                     0);
00701 
00702   TAO_Import_Attributes_i &import_attributes =
00703     return_value->import_attributes ();
00704   TAO_Support_Attributes_i &support_attributes =
00705     return_value->support_attributes ();
00706 
00707   import_attributes.def_search_card (this->def_search_card_);
00708   import_attributes.max_search_card (this->max_search_card_);
00709   import_attributes.def_match_card (this->def_match_card_);
00710   import_attributes.max_match_card (this->max_match_card_);
00711   import_attributes.def_return_card (this->def_return_card_);
00712   import_attributes.max_return_card (this->max_return_card_);
00713   import_attributes.def_hop_count (this->def_hop_count_);
00714   import_attributes.max_hop_count (this->max_hop_count_);
00715   import_attributes.def_follow_policy (this->def_follow_policy_);
00716   import_attributes.max_follow_policy (this->max_follow_policy_);
00717   support_attributes.supports_modifiable_properties (this->supports_modifiable_properties_);
00718   support_attributes.supports_dynamic_properties (this->supports_dynamic_properties_);
00719 
00720   return return_value;
00721 }
00722 
00723 void
00724 TAO_Trader_Factory::parse_args (int& argc, ACE_TCHAR** argv)
00725 {
00726   ACE_Arg_Shifter arg_shifter (argc, argv);
00727 
00728   while (arg_shifter.is_anything_left ())
00729     {
00730       const ACE_TCHAR* current_arg = arg_shifter.get_current ();
00731 
00732       if (ACE_OS::strcmp (current_arg, ACE_TEXT("-TSthreadsafe")) == 0)
00733         {
00734           arg_shifter.consume_arg ();
00735           this->threadsafe_ = 1;
00736         }
00737       else if (ACE_OS::strcmp (current_arg, ACE_TEXT("-TSconformance")) == 0)
00738         {
00739           arg_shifter.consume_arg ();
00740           if (arg_shifter.is_parameter_next ())
00741             {
00742               const ACE_TCHAR* conformance_str = arg_shifter.get_current ();
00743 
00744               if (ACE_OS::strcasecmp (conformance_str, ACE_TEXT("Linked")) == 0)
00745                 this->conformance_ = TAO_TRADER_LINKED;
00746               else if (ACE_OS::strcasecmp (conformance_str, ACE_TEXT("Query")) == 0)
00747                 this->conformance_ = TAO_TRADER_QUERY;
00748               else if (ACE_OS::strcasecmp (conformance_str, ACE_TEXT("Simple")) == 0)
00749                 this->conformance_ = TAO_TRADER_SIMPLE;
00750               else if (ACE_OS::strcasecmp (conformance_str, ACE_TEXT("Standalone")) == 0)
00751                 this->conformance_ = TAO_TRADER_STANDALONE;
00752 
00753               arg_shifter.consume_arg ();
00754             }
00755         }
00756       else if (ACE_OS::strcmp (current_arg, ACE_TEXT("-TSsupports_dynamic_properties")) == 0)
00757         {
00758           arg_shifter.consume_arg ();
00759           if (arg_shifter.is_parameter_next ())
00760             {
00761               const ACE_TCHAR* arg_str = arg_shifter.get_current ();
00762 
00763               if (ACE_OS::strcasecmp (arg_str, ACE_TEXT("true")) == 0)
00764                 this->supports_dynamic_properties_ = 1;
00765               else if (ACE_OS::strcasecmp (arg_str, ACE_TEXT("false")) == 0)
00766                 this->supports_dynamic_properties_ = 0;
00767 
00768               arg_shifter.consume_arg ();
00769             }
00770 
00771         }
00772       else if (ACE_OS::strcmp (current_arg, ACE_TEXT("-TSsupports_modifiable_properties")) == 0)
00773         {
00774           arg_shifter.consume_arg ();
00775           if (arg_shifter.is_parameter_next ())
00776             {
00777               const ACE_TCHAR* arg_str = arg_shifter.get_current ();
00778 
00779               if (ACE_OS::strcasecmp (arg_str, ACE_TEXT("true")) == 0)
00780                 this->supports_modifiable_properties_ = 1;
00781               else if (ACE_OS::strcasecmp (arg_str, ACE_TEXT("false")) == 0)
00782                 this->supports_modifiable_properties_ = 0;
00783 
00784               arg_shifter.consume_arg ();
00785             }
00786         }
00787       else if (ACE_OS::strcmp (current_arg, ACE_TEXT("-TSdef_search_card")) == 0 ||
00788                ACE_OS::strcmp (current_arg, ACE_TEXT("-TSmax_search_card")) == 0 ||
00789                ACE_OS::strcmp (current_arg, ACE_TEXT("-TSdef_match_card")) == 0 ||
00790                ACE_OS::strcmp (current_arg, ACE_TEXT("-TSmax_match_card")) == 0 ||
00791                ACE_OS::strcmp (current_arg, ACE_TEXT("-TSdef_return_card")) == 0 ||
00792                ACE_OS::strcmp (current_arg, ACE_TEXT("-TSmax_return_card")) == 0 ||
00793                ACE_OS::strcmp (current_arg, ACE_TEXT("-TSdef_hop_count")) == 0 ||
00794                ACE_OS::strcmp (current_arg, ACE_TEXT("-TSmax_hop_count")) == 0)
00795         {
00796           arg_shifter.consume_arg ();
00797           if (arg_shifter.is_parameter_next ())
00798             {
00799               CORBA::ULong value =
00800                 static_cast<CORBA::ULong> (ACE_OS::atoi (arg_shifter.get_current ()));
00801               arg_shifter.consume_arg ();
00802 
00803               if (ACE_OS::strstr (current_arg, ACE_TEXT("card")))
00804                 {
00805                   if (ACE_OS::strstr (current_arg, ACE_TEXT("max")))
00806                     {
00807                       if (ACE_OS::strstr (current_arg, ACE_TEXT("search")))
00808                         this->max_search_card_ = value;
00809                       else if (ACE_OS::strstr (current_arg, ACE_TEXT("match")))
00810                         this->max_match_card_ = value;
00811                       else
00812                         this->max_return_card_ = value;
00813                     }
00814                   else
00815                     {
00816                       if (ACE_OS::strstr (current_arg, ACE_TEXT("search")))
00817                         this->def_search_card_ = value;
00818                       else if (ACE_OS::strstr (current_arg, ACE_TEXT("match")))
00819                         this->def_match_card_ = value;
00820                       else
00821                         this->def_return_card_ = value;
00822                     }
00823                 }
00824               else
00825                 {
00826                   if (ACE_OS::strstr (current_arg, ACE_TEXT("max")))
00827                     this->max_hop_count_ = value;
00828                   else
00829                     this->def_hop_count_ = value;
00830                 }
00831             }
00832         }
00833       else if (ACE_OS::strcmp (current_arg, ACE_TEXT("-TSdef_follow_policy")) == 0
00834                || ACE_OS::strcmp (current_arg, ACE_TEXT("-TSmax_follow_policy")) == 0)
00835         {
00836           arg_shifter.consume_arg ();
00837           if (arg_shifter.is_parameter_next ())
00838             {
00839               const ACE_TCHAR* arg_str = arg_shifter.get_current ();
00840               CosTrading::FollowOption follow_option;
00841 
00842               if (ACE_OS::strcasecmp (arg_str, ACE_TEXT("always")) == 0)
00843                 follow_option = CosTrading::always;
00844               else if (ACE_OS::strcasecmp (arg_str, ACE_TEXT("if_no_local")) == 0)
00845                 follow_option = CosTrading::if_no_local;
00846               else if (ACE_OS::strcasecmp (arg_str, ACE_TEXT("local_only")) == 0)
00847                 follow_option = CosTrading::local_only;
00848               else if (ACE_OS::strstr (current_arg, ACE_TEXT("def")))
00849                 follow_option = this->def_follow_policy_;
00850               else
00851                 follow_option = this->max_follow_policy_;
00852 
00853               if (ACE_OS::strstr (current_arg, ACE_TEXT("def")))
00854                 this->def_follow_policy_ = follow_option;
00855               else
00856                 this->max_follow_policy_ = follow_option;
00857 
00858               arg_shifter.consume_arg ();
00859             }
00860         }
00861       else
00862         arg_shifter.ignore_arg ();
00863     }
00864 }
00865 
00866 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 13:59:58 2006 for TAO_CosTrader by doxygen 1.3.6