TAO_Trader_Factory Class Reference

Uses command line arguments to construct a trader instance with the correct interface support, locking, and policy settings. More...

#include <Trader.h>

List of all members.

Public Types

typedef TAO_Trader_Base TAO_TRADER

Static Public Member Functions

TAO_TRADERcreate_trader (int &argc, ACE_TCHAR **argv)

Protected Member Functions

 TAO_Trader_Factory (int &argc, ACE_TCHAR **argv)

Private Types

enum  Conformance { TAO_TRADER_QUERY, TAO_TRADER_SIMPLE, TAO_TRADER_STANDALONE, TAO_TRADER_LINKED }

Private Member Functions

TAO_TRADERmanufacture_trader (void)
void parse_args (int &argc, ACE_TCHAR **argv)
TAO_Trader_Factoryoperator= (const TAO_Trader_Factory &)
 TAO_Trader_Factory (const TAO_Trader_Factory &)

Private Attributes

Conformance conformance_
CORBA::Boolean threadsafe_
CORBA::Boolean supports_dynamic_properties_
CORBA::Boolean supports_modifiable_properties_
CORBA::ULong def_search_card_
CORBA::ULong max_search_card_
CORBA::ULong def_match_card_
CORBA::ULong max_match_card_
CORBA::ULong def_return_card_
CORBA::ULong max_return_card_
CORBA::ULong def_hop_count_
CORBA::ULong max_hop_count_
CosTrading::FollowOption def_follow_policy_
CosTrading::FollowOption max_follow_policy_


Detailed Description

Uses command line arguments to construct a trader instance with the correct interface support, locking, and policy settings.

Definition at line 53 of file Trader.h.


Member Typedef Documentation

typedef TAO_Trader_Base TAO_Trader_Factory::TAO_TRADER
 

Definition at line 57 of file Trader.h.

Referenced by manufacture_trader().


Member Enumeration Documentation

enum TAO_Trader_Factory::Conformance [private]
 

Enumeration values:
TAO_TRADER_QUERY 
TAO_TRADER_SIMPLE 
TAO_TRADER_STANDALONE 
TAO_TRADER_LINKED 

Definition at line 87 of file Trader.h.


Constructor & Destructor Documentation

TAO_Trader_Factory::TAO_Trader_Factory int &  argc,
ACE_TCHAR **  argv
[protected]
 

Definition at line 651 of file Trader.cpp.

References parse_args().

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 }

TAO_Trader_Factory::TAO_Trader_Factory const TAO_Trader_Factory  )  [private]
 


Member Function Documentation

TAO_END_VERSIONED_NAMESPACE_DECL TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_Trader_Factory::TAO_TRADER * TAO_Trader_Factory::create_trader int &  argc,
ACE_TCHAR **  argv
[static]
 

Creates an instance of the trader according to parameters whose default values can be overrided with the following command line arguments:

-TSthreadsafe, default is not thread-safe -TSconformance {query, simple, stand-alone, linked}, default is linked -TSsupports_dynamic_properties {true, false}, default is true -TSsupports_modifiable_propertise {true, false}, default is true -TSdef_search_card {integer}, default is 20 -TSmax_search_card {integer}, default is 50 -TSdef_match_card {integer}, default is 20 -TSmax_match_card {integer}, default is 50 -TSdef_return_card {integer}, default is 20 -TSmax_return_card {integer}, default is 50 -TSdef_hop_count {integer}, default is 5, -TSmax_hop_count {integer}, default is 10 -TSdef_follow_policy {always,if_no_local,local_only}, default is if_no_local, -TSmax_follow_policy {always,if_no_local,local_only}, default is always

Definition at line 645 of file Trader.cpp.

References manufacture_trader().

00646 {
00647   TAO_Trader_Factory trader_factory (argc, argv);
00648   return trader_factory.manufacture_trader ();
00649 }

TAO_Trader_Factory::TAO_TRADER * TAO_Trader_Factory::manufacture_trader void   )  [private]
 

Definition at line 671 of file Trader.cpp.

References ACE_NEW_RETURN, conformance_, TAO_Import_Attributes_i::def_follow_policy(), TAO_Import_Attributes_i::def_hop_count(), TAO_Import_Attributes_i::def_match_card(), TAO_Import_Attributes_i::def_return_card(), TAO_Import_Attributes_i::def_search_card(), TAO_Trader_Base::import_attributes(), TAO_Import_Attributes_i::max_follow_policy(), TAO_Import_Attributes_i::max_hop_count(), TAO_Import_Attributes_i::max_match_card(), TAO_Import_Attributes_i::max_return_card(), TAO_Import_Attributes_i::max_search_card(), TAO_Trader_Base::support_attributes(), TAO_Support_Attributes_i::supports_dynamic_properties(), TAO_Support_Attributes_i::supports_modifiable_properties(), TAO_TRADER, TAO_TRADER_LINKED, TAO_TRADER_SIMPLE, TAO_TRADER_STANDALONE, and threadsafe_.

Referenced by create_trader().

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 }

TAO_Trader_Factory& TAO_Trader_Factory::operator= const TAO_Trader_Factory  )  [private]
 

void TAO_Trader_Factory::parse_args int &  argc,
ACE_TCHAR **  argv
[private]
 

Definition at line 724 of file Trader.cpp.

References ACE_Arg_Shifter, ACE_TCHAR, ACE_TEXT, ACE_OS::atoi(), conformance_, def_follow_policy_, def_hop_count_, def_match_card_, def_return_card_, def_search_card_, max_follow_policy_, max_hop_count_, max_match_card_, max_return_card_, max_search_card_, ACE_OS::strcasecmp(), ACE_OS::strcmp(), ACE_OS::strstr(), supports_dynamic_properties_, supports_modifiable_properties_, TAO_TRADER_LINKED, TAO_TRADER_QUERY, TAO_TRADER_SIMPLE, TAO_TRADER_STANDALONE, and threadsafe_.

Referenced by TAO_Trader_Factory().

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 }


Member Data Documentation

Conformance TAO_Trader_Factory::conformance_ [private]
 

Definition at line 101 of file Trader.h.

Referenced by manufacture_trader(), and parse_args().

CosTrading::FollowOption TAO_Trader_Factory::def_follow_policy_ [private]
 

Definition at line 113 of file Trader.h.

Referenced by parse_args().

CORBA::ULong TAO_Trader_Factory::def_hop_count_ [private]
 

Definition at line 111 of file Trader.h.

Referenced by parse_args().

CORBA::ULong TAO_Trader_Factory::def_match_card_ [private]
 

Definition at line 107 of file Trader.h.

Referenced by parse_args().

CORBA::ULong TAO_Trader_Factory::def_return_card_ [private]
 

Definition at line 109 of file Trader.h.

Referenced by parse_args().

CORBA::ULong TAO_Trader_Factory::def_search_card_ [private]
 

Definition at line 105 of file Trader.h.

Referenced by parse_args().

CosTrading::FollowOption TAO_Trader_Factory::max_follow_policy_ [private]
 

Definition at line 114 of file Trader.h.

Referenced by parse_args().

CORBA::ULong TAO_Trader_Factory::max_hop_count_ [private]
 

Definition at line 112 of file Trader.h.

Referenced by parse_args().

CORBA::ULong TAO_Trader_Factory::max_match_card_ [private]
 

Definition at line 108 of file Trader.h.

Referenced by parse_args().

CORBA::ULong TAO_Trader_Factory::max_return_card_ [private]
 

Definition at line 110 of file Trader.h.

Referenced by parse_args().

CORBA::ULong TAO_Trader_Factory::max_search_card_ [private]
 

Definition at line 106 of file Trader.h.

Referenced by parse_args().

CORBA::Boolean TAO_Trader_Factory::supports_dynamic_properties_ [private]
 

Definition at line 103 of file Trader.h.

Referenced by parse_args().

CORBA::Boolean TAO_Trader_Factory::supports_modifiable_properties_ [private]
 

Definition at line 104 of file Trader.h.

Referenced by parse_args().

CORBA::Boolean TAO_Trader_Factory::threadsafe_ [private]
 

Definition at line 102 of file Trader.h.

Referenced by manufacture_trader(), and parse_args().


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 14:01:21 2006 for TAO_CosTrader by doxygen 1.3.6