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