Parse_Node.cpp

Go to the documentation of this file.
00001 #include "ace/Parse_Node.h"
00002 
00003 #if (ACE_USES_CLASSIC_SVC_CONF == 1)
00004 
00005 #include "ace/Service_Config.h"
00006 #include "ace/Service_Repository.h"
00007 #include "ace/Service_Types.h"
00008 #include "ace/Task.h"
00009 #include "ace/DLL.h"
00010 #include "ace/ACE.h"
00011 #include "ace/OS_NS_string.h"
00012 
00013 ACE_RCSID (ace,
00014            Parse_Node,
00015            "$Id: Parse_Node.cpp 79134 2007-07-31 18:23:50Z johnnyw $")
00016 
00017 
00018   ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00019 
00020 ACE_ALLOC_HOOK_DEFINE (ACE_Stream_Node)
00021 
00022 // Provide the class hierarchy that defines the parse tree of Service
00023 // Nodes.
00024 
00025   void
00026 ACE_Stream_Node::dump (void) const
00027 {
00028 #if defined (ACE_HAS_DUMP)
00029   ACE_TRACE ("ACE_Stream_Node::dump");
00030 #endif /* ACE_HAS_DUMP */
00031 }
00032 
00033 void
00034 ACE_Stream_Node::apply (ACE_Service_Gestalt *config, int &yyerrno)
00035 {
00036   ACE_TRACE ("ACE_Stream_Node::apply");
00037 
00038   if (config->initialize (this->node_->record (config),
00039                           this->node_->parameters ()) == -1)
00040     ++yyerrno;
00041 
00042 #ifndef ACE_NLOGGING
00043   if (ACE::debug ())
00044     ACE_DEBUG ((LM_DEBUG,
00045                 ACE_TEXT ("(%P|%t) Did stream on %s, error = %d\n"),
00046                 this->node_->name (),
00047                 yyerrno));
00048 #endif /* ACE_NLOGGING */
00049 }
00050 
00051 ACE_ALLOC_HOOK_DEFINE (ACE_Parse_Node)
00052 
00053   void
00054 ACE_Parse_Node::dump (void) const
00055 {
00056 #if defined (ACE_HAS_DUMP)
00057   ACE_TRACE ("ACE_Parse_Node::dump");
00058 #endif /* ACE_HAS_DUMP */
00059 }
00060 
00061 const ACE_TCHAR *
00062 ACE_Parse_Node::name (void) const
00063 {
00064   ACE_TRACE ("ACE_Parse_Node::name");
00065   return this->name_;
00066 }
00067 
00068 ACE_Parse_Node *
00069 ACE_Parse_Node::link (void) const
00070 {
00071   ACE_TRACE ("ACE_Parse_Node::link");
00072   return this->next_;
00073 }
00074 
00075 void
00076 ACE_Parse_Node::link (ACE_Parse_Node *n)
00077 {
00078   ACE_TRACE ("ACE_Parse_Node::link");
00079   this->next_ = n;
00080 }
00081 
00082 ACE_Stream_Node::ACE_Stream_Node (const ACE_Static_Node *str_ops,
00083                                   const ACE_Parse_Node *str_mods)
00084     : ACE_Parse_Node ((str_ops == 0 ? ACE_TEXT ("<unknown>") : str_ops->name ())),
00085       node_ (str_ops),
00086       mods_ (str_mods)
00087 {
00088   ACE_TRACE ("ACE_Stream_Node::ACE_Stream_Node");
00089 }
00090 
00091 
00092 ACE_Stream_Node::~ACE_Stream_Node (void)
00093 {
00094   ACE_TRACE ("ACE_Stream_Node::~ACE_Stream_Node");
00095   ACE_Static_Node *n = const_cast<ACE_Static_Node *> (this->node_);
00096   delete n;
00097   ACE_Parse_Node *m = const_cast<ACE_Parse_Node *> (this->mods_);
00098   delete m;
00099 }
00100 
00101 ACE_Parse_Node::ACE_Parse_Node (void)
00102   : name_ (0),
00103     next_ (0)
00104 {
00105   ACE_TRACE ("ACE_Parse_Node::ACE_Parse_Node");
00106 }
00107 
00108 
00109 ACE_Parse_Node::ACE_Parse_Node (const ACE_TCHAR *nm)
00110   : name_ (ACE::strnew (nm)),
00111     next_ (0)
00112 {
00113   ACE_TRACE ("ACE_Parse_Node::ACE_Parse_Node");
00114 }
00115 
00116 void
00117 ACE_Parse_Node::print (void) const
00118 {
00119   ACE_TRACE ("ACE_Parse_Node::print");
00120 
00121   ACE_DEBUG ((LM_DEBUG,
00122               ACE_TEXT ("svc = %s\n"),
00123               this->name ()));
00124 
00125   if (this->next_)
00126     this->next_->print ();
00127 }
00128 
00129 
00130 ACE_Parse_Node::~ACE_Parse_Node (void)
00131 {
00132   ACE_TRACE ("ACE_Parse_Node::~ACE_Parse_Node");
00133   delete[] const_cast<ACE_TCHAR*> (this->name_);
00134   delete this->next_;
00135 }
00136 
00137 ACE_ALLOC_HOOK_DEFINE (ACE_Suspend_Node)
00138 
00139   void
00140 ACE_Suspend_Node::dump (void) const
00141 {
00142 #if defined (ACE_HAS_DUMP)
00143   ACE_TRACE ("ACE_Suspend_Node::dump");
00144 #endif /* ACE_HAS_DUMP */
00145 }
00146 
00147 ACE_Suspend_Node::ACE_Suspend_Node (const ACE_TCHAR *name)
00148   : ACE_Parse_Node (name)
00149 {
00150   ACE_TRACE ("ACE_Suspend_Node::ACE_Suspend_Node");
00151 }
00152 
00153 ACE_Suspend_Node::~ACE_Suspend_Node (void)
00154 {
00155 }
00156 
00157 ACE_ALLOC_HOOK_DEFINE (ACE_Resume_Node)
00158 
00159   void
00160 ACE_Resume_Node::dump (void) const
00161 {
00162 #if defined (ACE_HAS_DUMP)
00163   ACE_TRACE ("ACE_Resume_Node::dump");
00164 #endif /* ACE_HAS_DUMP */
00165 }
00166 
00167 ACE_Resume_Node::ACE_Resume_Node (const ACE_TCHAR *name)
00168   : ACE_Parse_Node (name)
00169 {
00170   ACE_TRACE ("ACE_Resume_Node::ACE_Resume_Node");
00171 }
00172 
00173 ACE_Resume_Node::~ACE_Resume_Node (void)
00174 {
00175 }
00176 
00177 void
00178 ACE_Suspend_Node::apply (ACE_Service_Gestalt *config, int &yyerrno)
00179 {
00180   ACE_TRACE ("ACE_Suspend_Node::apply");
00181 
00182   if (config->suspend (this->name ()) == -1)
00183     ++yyerrno;
00184 
00185 #ifndef ACE_NLOGGING
00186   if (ACE::debug ())
00187     ACE_DEBUG ((LM_DEBUG,
00188                 ACE_TEXT ("did suspend on %s, error = %d\n"),
00189                 this->name (),
00190                 yyerrno));
00191 #endif /* ACE_NLOGGING */
00192 }
00193 
00194 void
00195 ACE_Resume_Node::apply (ACE_Service_Gestalt *config, int &yyerrno)
00196 {
00197   ACE_TRACE ("ACE_Resume_Node::apply");
00198 
00199   if (config->resume (this->name ()) == -1)
00200     ++yyerrno;
00201 
00202 #ifndef ACE_NLOGGING
00203   if (ACE::debug ())
00204     ACE_DEBUG ((LM_DEBUG,
00205                 ACE_TEXT ("did resume on %s, error = %d\n"),
00206                 this->name (),
00207                 yyerrno));
00208 #endif /* ACE_NLOGGING */
00209 }
00210 
00211 ACE_ALLOC_HOOK_DEFINE (ACE_Remove_Node)
00212 
00213   void
00214 ACE_Remove_Node::dump (void) const
00215 {
00216 #if defined (ACE_HAS_DUMP)
00217   ACE_TRACE ("ACE_Remove_Node::dump");
00218 #endif /* ACE_HAS_DUMP */
00219 }
00220 
00221 ACE_Remove_Node::ACE_Remove_Node (const ACE_TCHAR *name)
00222   : ACE_Parse_Node (name)
00223 {
00224   ACE_TRACE ("ACE_Remove_Node::ACE_Remove_Node");
00225 }
00226 
00227 ACE_Remove_Node::~ACE_Remove_Node (void)
00228 {
00229 }
00230 
00231 void
00232 ACE_Remove_Node::apply (ACE_Service_Gestalt *config, int &yyerrno)
00233 {
00234   ACE_TRACE ("ACE_Remove_Node::apply");
00235 
00236   if (config->remove (this->name ()) == -1)
00237     ++yyerrno;
00238 
00239 #ifndef ACE_NLOGGING
00240   if (ACE::debug ())
00241     ACE_DEBUG ((LM_DEBUG,
00242                 ACE_TEXT ("ACE (%P|%t) Remove_Node::apply")
00243                 ACE_TEXT (" - did remove on %s, error = %d\n"),
00244                 this->name (),
00245                 yyerrno));
00246 #endif /* ACE_NLOGGING */
00247 }
00248 
00249 
00250 ACE_Dynamic_Node::ACE_Dynamic_Node (ACE_Service_Type_Factory const *stf,
00251                                     ACE_TCHAR *parms)
00252   : ACE_Static_Node (stf->name (), parms)
00253   , factory_ (stf)
00254 {
00255   ACE_TRACE ("ACE_Dynamic_Node::ACE_Dynamic_Node");
00256 }
00257 
00258 void
00259 ACE_Dynamic_Node::apply (ACE_Service_Gestalt *config, int &yyerrno)
00260 {
00261   ACE_TRACE ("ACE_Dynamic_Node::apply");
00262 
00263   if (config->initialize (this->factory_.get (),
00264                           this->parameters ()) == -1)
00265     ++yyerrno;
00266 
00267 #ifndef ACE_NLOGGING
00268   if (ACE::debug ())
00269     ACE_DEBUG ((LM_DEBUG,
00270                 ACE_TEXT ("ACE (%P|%t) Dynamic_Node::apply")
00271                 ACE_TEXT (" - Did dynamic on %s (yyerrno=%d)\n"),
00272                 this->name (),
00273                 yyerrno));
00274 #endif /* ACE_NLOGGING */
00275 }
00276 
00277 ACE_ALLOC_HOOK_DEFINE (ACE_Dynamic_Node)
00278 
00279   void
00280 ACE_Dynamic_Node::dump (void) const
00281 {
00282 #if defined (ACE_HAS_DUMP)
00283   ACE_TRACE ("ACE_Dynamic_Node::dump");
00284 #endif /* ACE_HAS_DUMP */
00285 }
00286 
00287 ACE_Dynamic_Node::~ACE_Dynamic_Node (void)
00288 {
00289   ACE_TRACE ("ACE_Dynamic_Node::~ACE_Dynamic_Node");
00290 }
00291 
00292 ACE_ALLOC_HOOK_DEFINE (ACE_Static_Node)
00293 
00294   void
00295 ACE_Static_Node::dump (void) const
00296 {
00297 #if defined (ACE_HAS_DUMP)
00298   ACE_TRACE ("ACE_Static_Node::dump");
00299 #endif /* ACE_HAS_DUMP */
00300 }
00301 
00302 ACE_Static_Node::ACE_Static_Node (const ACE_TCHAR *nm,
00303                                   ACE_TCHAR *params)
00304   : ACE_Parse_Node (nm),
00305     parameters_ (ACE::strnew (params))
00306 {
00307   ACE_TRACE ("ACE_Static_Node::ACE_Static_Node");
00308 }
00309 
00310 const ACE_Service_Type *
00311 ACE_Static_Node::record (const ACE_Service_Gestalt *config) const
00312 {
00313   ACE_TRACE ("ACE_Static_Node::record");
00314   ACE_Service_Type *sr = 0;
00315 
00316   if (config->find (this->name (), (const ACE_Service_Type **) &sr) == -1)
00317     return 0;
00318 
00319   return sr;
00320 }
00321 
00322 ACE_TCHAR *
00323 ACE_Static_Node::parameters (void) const
00324 {
00325   ACE_TRACE ("ACE_Static_Node::parameters");
00326   return this->parameters_;
00327 }
00328 
00329 void
00330 ACE_Static_Node::apply (ACE_Service_Gestalt *config, int &yyerrno)
00331 {
00332   ACE_TRACE ("ACE_Static_Node::apply");
00333   if (config->initialize (this->name (),
00334         this->parameters ()) == -1)
00335     ++yyerrno;
00336 
00337 #ifndef ACE_NLOGGING
00338   if (ACE::debug ())
00339     ACE_DEBUG ((LM_DEBUG,
00340                 ACE_TEXT ("ACE (%P|%t) Static_Node::apply -")
00341                 ACE_TEXT (" Did static on %s (yyerrno=%d)\n"),
00342                 this->name (),
00343                 yyerrno));
00344 #endif /* ACE_NLOGGING */
00345 }
00346 
00347 ACE_Static_Node::~ACE_Static_Node (void)
00348 {
00349   ACE_TRACE ("ACE_Static_Node::~ACE_Static_Node");
00350   delete[] this->parameters_;
00351 }
00352 
00353 
00354 ACE_ALLOC_HOOK_DEFINE (ACE_Location_Node)
00355 
00356   void
00357 ACE_Location_Node::dump (void) const
00358 {
00359 #if defined (ACE_HAS_DUMP)
00360   ACE_TRACE ("ACE_Location_Node::dump");
00361 #endif /* ACE_HAS_DUMP */
00362 }
00363 
00364 ACE_Location_Node::ACE_Location_Node (void)
00365   : pathname_ (0),
00366     dll_ (),
00367     symbol_ (0)
00368 {
00369   ACE_TRACE ("ACE_Location_Node::ACE_Location_Node");
00370 }
00371 
00372 ACE_Location_Node::~ACE_Location_Node (void)
00373 {
00374   ACE_TRACE ("ACE_Location_Node::~ACE_Location_Node");
00375 }
00376 
00377 const ACE_DLL &
00378 ACE_Location_Node::dll (void)
00379 {
00380   return this->dll_;
00381 }
00382 
00383 const ACE_TCHAR *
00384 ACE_Location_Node::pathname (void) const
00385 {
00386   ACE_TRACE ("ACE_Location_Node::pathname");
00387   return this->pathname_;
00388 }
00389 
00390 void
00391 ACE_Location_Node::pathname (const ACE_TCHAR *p)
00392 {
00393   ACE_TRACE ("ACE_Location_Node::pathname");
00394   this->pathname_ = p;
00395 }
00396 
00397 int
00398 ACE_Location_Node::dispose (void) const
00399 {
00400   ACE_TRACE ("ACE_Location_Node::dispose");
00401   return this->must_delete_;
00402 }
00403 
00404 int
00405 ACE_Location_Node::open_dll (int & yyerrno)
00406 {
00407   ACE_TRACE ("ACE_Location_Node::open_dll");
00408 
00409 #ifndef ACE_NLOGGING
00410   if (ACE::debug ())
00411     ACE_DEBUG ((LM_DEBUG,
00412                 ACE_TEXT ("ACE (%P|%t) LN::open_dll - path=%s\n"),
00413                 this->pathname ()));
00414 #endif /* ACE_NLOGGING */
00415 
00416   if (-1 == this->dll_.open (this->pathname ()))
00417     {
00418       ++yyerrno;
00419 
00420 #ifndef ACE_NLOGGING
00421       ACE_TCHAR *errmsg = this->dll_.error ();
00422       ACE_ERROR ((LM_ERROR,
00423                   ACE_TEXT ("ACE (%P|%t) LN::open_dll - Failed to open %s: %s\n"),
00424                   this->pathname (),
00425                   errmsg ? errmsg : ACE_TEXT ("no error reported")));
00426 #endif /* ACE_NLOGGING */
00427 
00428       return -1;
00429     }
00430 
00431   return 0;
00432 
00433 }
00434 
00435 void
00436 ACE_Location_Node::set_symbol (void *s)
00437 {
00438   ACE_TRACE ("ACE_Location_Node::set_symbol");
00439   this->symbol_ = s;
00440 }
00441 
00442 ACE_ALLOC_HOOK_DEFINE (ACE_Object_Node)
00443 
00444   void
00445 ACE_Object_Node::dump (void) const
00446 {
00447 #if defined (ACE_HAS_DUMP)
00448   ACE_TRACE ("ACE_Object_Node::dump");
00449 #endif /* ACE_HAS_DUMP */
00450 }
00451 
00452 ACE_Object_Node::ACE_Object_Node (const ACE_TCHAR *path,
00453                                   const ACE_TCHAR *obj_name)
00454   : object_name_ (ACE::strnew (obj_name))
00455 {
00456   ACE_TRACE ("ACE_Object_Node::ACE_Object_Node");
00457   this->pathname (ACE::strnew (path));
00458   this->must_delete_ = 0;
00459 }
00460 
00461 void *
00462 ACE_Object_Node::symbol (ACE_Service_Gestalt *,
00463                          int &yyerrno,
00464                          ACE_Service_Object_Exterminator *)
00465 {
00466   ACE_TRACE ("ACE_Object_Node::symbol");
00467   if (this->open_dll (yyerrno) == 0)
00468     {
00469       ACE_TCHAR *object_name = const_cast<ACE_TCHAR *> (this->object_name_);
00470 
00471       this->symbol_ = this->dll_.symbol (object_name);
00472       if (this->symbol_ == 0)
00473         {
00474           ++yyerrno;
00475 
00476 #ifndef ACE_NLOGGING
00477           ACE_TCHAR *errmsg = this->dll_.error ();
00478           ACE_ERROR ((LM_ERROR,
00479                       ACE_TEXT ("ACE (%P|%t) DLL::symbol -")
00480                       ACE_TEXT (" Failed for object %s: %s\n"),
00481                       object_name,
00482                       errmsg ? errmsg : ACE_TEXT ("no error reported")));
00483 #endif /* ACE_NLOGGING */
00484 
00485           return 0;
00486         }
00487 
00488       return this->symbol_;
00489     }
00490 
00491   return 0;
00492 }
00493 
00494 ACE_Object_Node::~ACE_Object_Node (void)
00495 {
00496   ACE_TRACE ("ACE_Object_Node::~ACE_Object_Node");
00497   delete[] const_cast<ACE_TCHAR *> (this->object_name_);
00498 }
00499 
00500 ACE_ALLOC_HOOK_DEFINE (ACE_Function_Node)
00501 
00502   void
00503 ACE_Function_Node::dump (void) const
00504 {
00505 #if defined (ACE_HAS_DUMP)
00506   ACE_TRACE ("ACE_Function_Node::dump");
00507 #endif /* ACE_HAS_DUMP */
00508 }
00509 
00510 ACE_Function_Node::ACE_Function_Node (const ACE_TCHAR *path,
00511                                       const ACE_TCHAR *func_name)
00512   : function_name_ (make_func_name (func_name))
00513 {
00514   ACE_TRACE ("ACE_Function_Node::ACE_Function_Node");
00515   this->pathname (ACE::strnew (path));
00516   this->must_delete_ = 1;
00517 }
00518 
00519 ACE_TCHAR *
00520 ACE_Function_Node::make_func_name (ACE_TCHAR const * func_name)
00521 {
00522   // Preprocessor symbols will not be expanded if they are
00523   // stringified.  Force the preprocessor to expand them during the
00524   // argument prescan by calling a macro that itself calls another
00525   // that performs the actual stringification.
00526 #if defined (ACE_HAS_VERSIONED_NAMESPACE) && ACE_HAS_VERSIONED_NAMESPACE == 1
00527 # define ACE_MAKE_VERSIONED_NAMESPACE_NAME_STRING_IMPL(NAME) #NAME
00528 # define ACE_MAKE_VERSIONED_NAMESPACE_NAME_STRING(NAME) ACE_MAKE_VERSIONED_NAMESPACE_NAME_STRING_IMPL(NAME)
00529 # define ACE_VERSIONED_NAMESPACE_NAME_STRING ACE_MAKE_VERSIONED_NAMESPACE_NAME_STRING(ACE_VERSIONED_NAMESPACE_NAME)
00530 
00531   // Check if function is using the ACE naming convention.  If so,
00532   // it is likely that the ACE factory function macros
00533   // (e.g. ACE_FACTORY_DECLARE) were used to declare and define it, so
00534   // mangle the function name to include the ACE versioned namespace
00535   // name as is done in the ACE macros.  Otherwise, leave the function
00536   // name as is.
00537 
00538   static ACE_TCHAR const make_prefix[] = ACE_TEXT ("_make_");
00539   static size_t const make_prefix_len =
00540     sizeof (make_prefix) / sizeof (make_prefix[0]) - 1;
00541 
00542   if (ACE_OS::strncmp (make_prefix, func_name, make_prefix_len) == 0)
00543     {
00544       static ACE_TCHAR const versioned_namespace_name[] =
00545         ACE_TEXT (ACE_VERSIONED_NAMESPACE_NAME_STRING) ACE_TEXT("_") ;
00546 
00547       // Null terminator included in versioned_namespace_name_len since
00548       // it is static constant.
00549       static size_t const versioned_namespace_name_len =
00550         sizeof (versioned_namespace_name)
00551         / sizeof (versioned_namespace_name[0]); // - 1;
00552 
00553       size_t const len =
00554         ACE_OS::strlen (func_name)
00555         + versioned_namespace_name_len;
00556       // + 1;  // Null terminator.
00557 
00558       ACE_TCHAR * mangled_func_name;
00559       ACE_NEW_RETURN (mangled_func_name,
00560                       ACE_TCHAR[len],
00561                       0);
00562 
00563       ACE_Auto_Basic_Array_Ptr<ACE_TCHAR> safe (mangled_func_name);
00564 
00565       ACE_OS::snprintf (mangled_func_name,
00566                         len,
00567                         ACE_TEXT ("%s%s%s"),
00568                         make_prefix,
00569                         versioned_namespace_name,
00570                         func_name + make_prefix_len);
00571 
00572       return safe.release ();
00573     }
00574 #endif  /* ACE_HAS_VERSIONED_NAMESPACE == 1 */
00575 
00576   return ACE::strnew (func_name);
00577 }
00578 
00579 void *
00580 ACE_Function_Node::symbol (ACE_Service_Gestalt *,
00581                            int &yyerrno,
00582                            ACE_Service_Object_Exterminator *gobbler)
00583 {
00584   typedef ACE_Service_Object *(*ACE_Service_Factory_Ptr)
00585     (ACE_Service_Object_Exterminator *);
00586 
00587   ACE_TRACE ("ACE_Function_Node::symbol");
00588   if (this->open_dll (yyerrno) == 0)
00589     {
00590       this->symbol_ = 0;
00591 
00592       // Locate the factory function <function_name> in the shared
00593       // object.
00594       ACE_TCHAR * const function_name =
00595         const_cast<ACE_TCHAR *> (this->function_name_);
00596 
00597       void * const func_p = this->dll_.symbol (function_name);
00598       if (func_p == 0)
00599         {
00600           ++yyerrno;
00601 
00602 #ifndef ACE_NLOGGING
00603           ACE_TCHAR * const errmsg = this->dll_.error ();
00604           ACE_ERROR ((LM_ERROR,
00605                       ACE_TEXT ("DLL::symbol failed for function %s: ")
00606                       ACE_TEXT ("%s\n"),
00607                       function_name,
00608                       errmsg ? errmsg : ACE_TEXT ("no error reported")));
00609 #endif /* ACE_NLOGGING */
00610 
00611           return 0;
00612         }
00613 
00614 #if defined (ACE_OPENVMS) && (!defined (__INITIAL_POINTER_SIZE) || (__INITIAL_POINTER_SIZE < 64))
00615       int const temp_p = reinterpret_cast<int> (func_p);
00616 #else
00617       intptr_t const temp_p = reinterpret_cast<intptr_t> (func_p);
00618 #endif
00619 
00620       ACE_Service_Factory_Ptr func =
00621         reinterpret_cast<ACE_Service_Factory_Ptr> (temp_p);
00622 
00623       // Invoke the factory function and record it's return value.
00624       this->symbol_ = (*func) (gobbler);
00625 
00626       if (this->symbol_ == 0)
00627         {
00628           ++yyerrno;
00629           ACE_ERROR_RETURN ((LM_ERROR,
00630                              ACE_TEXT ("%p\n"),
00631                              this->function_name_),
00632                             0);
00633         }
00634     }
00635   return this->symbol_;
00636 }
00637 
00638 ACE_Function_Node::~ACE_Function_Node (void)
00639 {
00640   ACE_TRACE ("ACE_Function_Node::~ACE_Function_Node");
00641   delete[] const_cast<ACE_TCHAR *> (function_name_);
00642   delete[] const_cast<ACE_TCHAR *> (pathname_);
00643 }
00644 
00645 ACE_ALLOC_HOOK_DEFINE (ACE_Dummy_Node)
00646 
00647   void
00648 ACE_Dummy_Node::dump (void) const
00649 {
00650 #if defined (ACE_HAS_DUMP)
00651   ACE_TRACE ("ACE_Dummy_Node::dump");
00652 #endif /* ACE_HAS_DUMP */
00653 }
00654 
00655 ACE_Dummy_Node::ACE_Dummy_Node (const ACE_Static_Node *static_node,
00656                                 const ACE_Parse_Node *str_mods)
00657   : ACE_Parse_Node (static_node->name ()),
00658     node_ (static_node),
00659     mods_ (str_mods)
00660 {
00661   ACE_TRACE ("ACE_Dummy_Node::ACE_Dummy_Node");
00662 }
00663 
00664 void
00665 ACE_Dummy_Node::apply (ACE_Service_Gestalt *, int &yyerrno)
00666 {
00667   ACE_TRACE ("ACE_Dummy_Node::apply");
00668 
00669 #ifndef ACE_NLOGGING
00670   if (ACE::debug ())
00671     ACE_DEBUG ((LM_DEBUG,
00672                 ACE_TEXT ("did operations on stream %s, error = %d\n"),
00673                 this->name (),
00674                 yyerrno));
00675 #else
00676   ACE_UNUSED_ARG (yyerrno);
00677 #endif /* ACE_NLOGGING */
00678 }
00679 
00680 ACE_Dummy_Node::~ACE_Dummy_Node (void)
00681 {
00682   ACE_TRACE ("ACE_Dummy_Node::~ACE_Dummy_Node");
00683   ACE_Static_Node *n = const_cast<ACE_Static_Node *> (this->node_);
00684   delete n;
00685   ACE_Parse_Node *m = const_cast<ACE_Parse_Node *> (this->mods_);
00686   delete m;
00687 }
00688 
00689 ACE_ALLOC_HOOK_DEFINE (ACE_Static_Function_Node)
00690 
00691   void
00692 ACE_Static_Function_Node::dump (void) const
00693 {
00694 #if defined (ACE_HAS_DUMP)
00695   ACE_TRACE ("ACE_Static_Function_Node::dump");
00696 #endif /* ACE_HAS_DUMP */
00697 }
00698 
00699 ACE_Static_Function_Node::ACE_Static_Function_Node (const ACE_TCHAR *func_name)
00700   : function_name_ (ACE::strnew (func_name))
00701 {
00702   ACE_TRACE ("ACE_Static_Function_Node::ACE_Static_Function_Node");
00703   this->must_delete_ = 1;
00704 }
00705 
00706 void *
00707 ACE_Static_Function_Node::symbol (ACE_Service_Gestalt *config,
00708                                   int &yyerrno,
00709                                   ACE_Service_Object_Exterminator *gobbler)
00710 {
00711   ACE_TRACE ("ACE_Static_Function_Node::symbol");
00712 
00713   this->symbol_ = 0;
00714 
00715   // Locate the factory function <function_name> in the statically
00716   // linked svcs.
00717 
00718   ACE_Static_Svc_Descriptor *ssd = 0;
00719   if (config->find_static_svc_descriptor (this->function_name_, &ssd) == -1)
00720     {
00721       yyerrno++;
00722       ACE_ERROR_RETURN ((LM_ERROR,
00723        ACE_TEXT ("(%P|%t) No static service ")
00724        ACE_TEXT ("registered for function %s\n"),
00725        this->function_name_),
00726       0);
00727     }
00728 
00729   if (ssd->alloc_ == 0)
00730     {
00731       yyerrno++;
00732 
00733       if (this->symbol_ == 0)
00734         {
00735           ++yyerrno;
00736 
00737           ACE_ERROR_RETURN ((LM_ERROR,
00738                              ACE_TEXT ("(%P|%t) No static service factory ")
00739                              ACE_TEXT ("function registered for function %s\n"),
00740                              this->function_name_),
00741           0);
00742         }
00743     }
00744 
00745   // Invoke the factory function and record it's return value.
00746   this->symbol_ = (*ssd->alloc_) (gobbler);
00747 
00748   if (this->symbol_ == 0)
00749     {
00750       ++yyerrno;
00751       ACE_ERROR_RETURN ((LM_ERROR,
00752                          ACE_TEXT ("%p\n"),
00753                          this->function_name_),
00754                         0);
00755     }
00756 
00757   return this->symbol_;
00758 }
00759 
00760 ACE_Static_Function_Node::~ACE_Static_Function_Node (void)
00761 {
00762   ACE_TRACE ("ACE_Static_Function_Node::~ACE_Static_Function_Node");
00763   delete[] const_cast<ACE_TCHAR *> (this->function_name_);
00764 }
00765 
00766 ACE_ALLOC_HOOK_DEFINE (ACE_Service_Type_Factory)
00767 
00768 ACE_Service_Type_Factory::ACE_Service_Type_Factory (ACE_TCHAR const *name,
00769                                                     int type,
00770                                                     ACE_Location_Node *location,
00771                                                     int active)
00772   : name_ (name)
00773   , type_ (type)
00774   , location_ (location)
00775   , is_active_ (active)
00776 {
00777 }
00778 
00779 
00780 ACE_Service_Type_Factory::~ACE_Service_Type_Factory (void)
00781 {
00782 }
00783 
00784 
00785 ACE_Service_Type *
00786 ACE_Service_Type_Factory::make_service_type (ACE_Service_Gestalt *cfg) const
00787 {
00788   ACE_TRACE ("ACE_Service_Type_Factory::make_service_type");
00789 
00790   u_int flags = ACE_Service_Type::DELETE_THIS
00791     | (this->location_->dispose () == 0 ? 0 : ACE_Service_Type::DELETE_OBJ);
00792 
00793   int yyerrno = 0;
00794   ACE_Service_Object_Exterminator gobbler = 0;
00795 
00796   void *sym = this->location_->symbol (cfg, yyerrno, &gobbler);
00797 
00798   if (sym != 0)
00799     {
00800       ACE_Service_Type_Impl *stp =
00801         ACE_Service_Config::create_service_type_impl (this->name (),
00802                                                       this->type_,
00803                                                       sym,
00804                                                       flags,
00805                                                       gobbler);
00806       if (stp == 0)
00807         ++yyerrno;
00808 
00809       ACE_Service_Type *tmp = 0;
00810       ACE_NEW_RETURN (tmp,
00811                       ACE_Service_Type (this->name (),
00812                                         stp,
00813                                         this->location_->dll (),
00814                                         this->is_active_),
00815                       0);
00816       return tmp;
00817     }
00818 
00819 #ifndef ACE_NLOGGING
00820   ACE_ERROR ((LM_ERROR,
00821               ACE_TEXT ("ACE (%P|%t) Unable to create ")
00822               ACE_TEXT ("service object for %s\n"),
00823               this->name ()));
00824 #endif
00825   ++yyerrno;
00826   return 0;
00827 }
00828 
00829 ACE_TCHAR const*
00830 ACE_Service_Type_Factory::name (void) const
00831 {
00832   return name_.c_str ();
00833 }
00834 
00835 
00836 ACE_END_VERSIONED_NAMESPACE_DECL
00837 
00838 #endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */

Generated on Sun Jan 27 12:05:34 2008 for ACE by doxygen 1.3.6