EC_Sched_Factory.cpp

Go to the documentation of this file.
00001 // EC_Sched_Factory.cpp,v 1.14 2006/03/14 06:14:25 jtc Exp
00002 
00003 #include "orbsvcs/Event/EC_Sched_Factory.h"
00004 #include "orbsvcs/Event/EC_Priority_Dispatching.h"
00005 #include "orbsvcs/Event/EC_Priority_Scheduling.h"
00006 #include "orbsvcs/Event/EC_Sched_Filter_Builder.h"
00007 #include "orbsvcs/Event/EC_Event_Channel_Base.h"
00008 #include "orbsvcs/RtecSchedulerC.h"
00009 
00010 #include "ace/Arg_Shifter.h"
00011 #include "ace/Sched_Params.h"
00012 #include "ace/OS_NS_strings.h"
00013 
00014 #if ! defined (__ACE_INLINE__)
00015 #include "orbsvcs/Event/EC_Sched_Factory.i"
00016 #endif /* __ACE_INLINE__ */
00017 
00018 ACE_RCSID(Event, EC_Sched_Factory, "EC_Sched_Factory.cpp,v 1.14 2006/03/14 06:14:25 jtc Exp")
00019 
00020 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00021 
00022 TAO_EC_Sched_Factory::~TAO_EC_Sched_Factory (void)
00023 {
00024 }
00025 
00026 int
00027 TAO_EC_Sched_Factory::init (int argc, ACE_TCHAR* argv[])
00028 {
00029   ACE_Arg_Shifter arg_shifter (argc, argv);
00030 
00031   while (arg_shifter.is_anything_left ())
00032     {
00033       const ACE_TCHAR* arg = arg_shifter.get_current ();
00034 
00035       if (ACE_OS::strcasecmp (arg, ACE_TEXT("-ECDispatching")) == 0)
00036         {
00037           arg_shifter.consume_arg ();
00038 
00039           if (arg_shifter.is_parameter_next ())
00040             {
00041               const ACE_TCHAR* opt = arg_shifter.get_current ();
00042               if (ACE_OS::strcasecmp (opt, ACE_TEXT("reactive")) == 0)
00043                 {
00044                   this->dispatching_ = 0;
00045                 }
00046               else if (ACE_OS::strcasecmp (opt, ACE_TEXT("mt")) == 0)
00047                 {
00048                   this->dispatching_ = 1;
00049                 }
00050               else if (ACE_OS::strcasecmp (opt, ACE_TEXT("priority")) == 0)
00051                 {
00052                   this->dispatching_ = 2;
00053                 }
00054               else
00055                 {
00056                   ACE_ERROR ((LM_ERROR,
00057                               ACE_TEXT("EC_Sched_Factory - ")
00058                               ACE_TEXT("unsupported dispatching <%s>\n"),
00059                               opt));
00060                 }
00061               arg_shifter.consume_arg ();
00062             }
00063         }
00064 
00065       else if (ACE_OS::strcasecmp (arg, ACE_TEXT("-ECFiltering")) == 0)
00066         {
00067           arg_shifter.consume_arg ();
00068 
00069           if (arg_shifter.is_parameter_next ())
00070             {
00071               const ACE_TCHAR* opt = arg_shifter.get_current ();
00072               if (ACE_OS::strcasecmp (opt, ACE_TEXT("null")) == 0)
00073                 {
00074                   this->filtering_ = 0;
00075                 }
00076               else if (ACE_OS::strcasecmp (opt, ACE_TEXT("basic")) == 0)
00077                 {
00078                   this->filtering_ = 1;
00079                 }
00080               else if (ACE_OS::strcasecmp (opt, ACE_TEXT("prefix")) == 0)
00081                 {
00082                   this->filtering_ = 2;
00083                 }
00084               else if (ACE_OS::strcasecmp (opt, ACE_TEXT("priority")) == 0)
00085                 {
00086                   this->filtering_ = 3;
00087                 }
00088               else
00089                 {
00090                   ACE_ERROR ((LM_ERROR,
00091                               ACE_TEXT("EC_Sched_Factory - ")
00092                               ACE_TEXT("unsupported filtering <%s>\n"),
00093                               opt));
00094                 }
00095               arg_shifter.consume_arg ();
00096             }
00097         }
00098 
00099       else if (ACE_OS::strcasecmp (arg, ACE_TEXT("-ECTimeout")) == 0)
00100         {
00101           arg_shifter.consume_arg ();
00102 
00103           if (arg_shifter.is_parameter_next ())
00104             {
00105               const ACE_TCHAR* opt = arg_shifter.get_current ();
00106               if (ACE_OS::strcasecmp (opt, ACE_TEXT("reactive")) == 0)
00107                 {
00108                   this->timeout_ = 0;
00109                 }
00110 #if 0
00111               else if (ACE_OS::strcasecmp (opt, ACE_TEXT("priority")) == 0)
00112                 {
00113                   this->timeout_ = 1;
00114                 }
00115 #endif /* 0 */
00116               else
00117                 {
00118                   ACE_ERROR ((LM_ERROR,
00119                               ACE_TEXT("EC_Sched_Factory - ")
00120                               ACE_TEXT("unsupported timeout <%s>\n"),
00121                               opt));
00122                 }
00123               arg_shifter.consume_arg ();
00124             }
00125         }
00126 
00127       else if (ACE_OS::strcasecmp (arg, ACE_TEXT("-ECScheduling")) == 0)
00128         {
00129           arg_shifter.consume_arg ();
00130 
00131           if (arg_shifter.is_parameter_next ())
00132             {
00133               const ACE_TCHAR* opt = arg_shifter.get_current ();
00134               if (ACE_OS::strcasecmp (opt, ACE_TEXT("null")) == 0)
00135                 {
00136                   this->scheduling_ = 0;
00137                 }
00138               else if (ACE_OS::strcasecmp (opt, ACE_TEXT("group")) == 0)
00139                 {
00140                   this->scheduling_ = 1;
00141                 }
00142               else if (ACE_OS::strcasecmp (opt, ACE_TEXT("priority")) == 0)
00143                 {
00144                   this->scheduling_ = 2;
00145                 }
00146               else
00147                 {
00148                   ACE_ERROR ((LM_ERROR,
00149                               ACE_TEXT("EC_Sched_Factory - ")
00150                               ACE_TEXT("unsupported scheduling <%s>\n"),
00151                               opt));
00152                 }
00153               arg_shifter.consume_arg ();
00154             }
00155         }
00156 
00157       else
00158         {
00159           arg_shifter.ignore_arg ();
00160         }
00161     }
00162   return this->TAO_EC_Default_Factory::init (argc, argv);
00163 }
00164 
00165 int
00166 TAO_EC_Sched_Factory::fini (void)
00167 {
00168   return 0;
00169 }
00170 
00171 // ****************************************************************
00172 
00173 TAO_EC_Dispatching*
00174 TAO_EC_Sched_Factory::create_dispatching (TAO_EC_Event_Channel_Base *ec)
00175 {
00176   if (this->dispatching_ == 2)
00177     return new TAO_EC_Priority_Dispatching (ec);
00178   return this->TAO_EC_Default_Factory::create_dispatching (ec);
00179 }
00180 
00181 TAO_EC_Filter_Builder*
00182 TAO_EC_Sched_Factory::create_filter_builder (TAO_EC_Event_Channel_Base *ec)
00183 {
00184   if (this->filtering_ == 3)
00185     return new TAO_EC_Sched_Filter_Builder (ec);
00186 
00187   return this->TAO_EC_Default_Factory::create_filter_builder (ec);
00188 }
00189 
00190 
00191 TAO_EC_Timeout_Generator*
00192 TAO_EC_Sched_Factory::create_timeout_generator (TAO_EC_Event_Channel_Base *ec)
00193 {
00194 #if 0
00195   if (this->timeout_ == 1)
00196     {
00197     }
00198 #endif
00199   return this->TAO_EC_Default_Factory::create_timeout_generator (ec);
00200 }
00201 
00202 TAO_EC_Scheduling_Strategy*
00203 TAO_EC_Sched_Factory::create_scheduling_strategy (TAO_EC_Event_Channel_Base* ec)
00204 {
00205   if (this->scheduling_ == 2)
00206     {
00207       CORBA::Object_var tmp = ec->scheduler ();
00208       RtecScheduler::Scheduler_var scheduler =
00209         RtecScheduler::Scheduler::_narrow (tmp.in ());
00210       return new TAO_EC_Priority_Scheduling (scheduler.in ());
00211     }
00212   return this->TAO_EC_Sched_Factory::create_scheduling_strategy (ec);
00213 }
00214 
00215 TAO_END_VERSIONED_NAMESPACE_DECL
00216 
00217 // ****************************************************************
00218 
00219 ACE_STATIC_SVC_DEFINE (TAO_EC_Sched_Factory,
00220                        ACE_TEXT ("EC_Factory"),
00221                        ACE_SVC_OBJ_T,
00222                        &ACE_SVC_NAME (TAO_EC_Sched_Factory),
00223                        ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ,
00224                        0)
00225 ACE_FACTORY_DEFINE (TAO_RTSchedEvent, TAO_EC_Sched_Factory)

Generated on Thu Nov 9 13:11:09 2006 for TAO_RTEvent by doxygen 1.3.6