Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / Parse_Node.cpp
blob76b763da3dfed6f3a6d7cb1d2178713978897f93
1 #include "ace/Parse_Node.h"
3 #if (ACE_USES_CLASSIC_SVC_CONF == 1)
5 #include "ace/Service_Config.h"
6 #include "ace/Service_Repository.h"
7 #include "ace/Service_Types.h"
8 #include "ace/Task.h"
9 #include "ace/DLL.h"
10 #include "ace/ACE.h"
11 #include "ace/OS_NS_string.h"
12 #include "ace/ARGV.h"
14 #include <list>
15 #include <memory>
17 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
19 ACE_ALLOC_HOOK_DEFINE (ACE_Stream_Node)
21 // Provide the class hierarchy that defines the parse tree of Service
22 // Nodes.
24 void
25 ACE_Stream_Node::dump () const
27 #if defined (ACE_HAS_DUMP)
28 ACE_TRACE ("ACE_Stream_Node::dump");
29 #endif /* ACE_HAS_DUMP */
32 void
33 ACE_Stream_Node::apply (ACE_Service_Gestalt *config, int &yyerrno)
35 ACE_TRACE ("ACE_Stream_Node::apply");
37 const ACE_Service_Type *sst = this->node_->record (config);
38 if (sst == 0)
39 const_cast<ACE_Static_Node *> (this->node_)->apply (config, yyerrno);
41 if (yyerrno != 0) return;
43 sst = this->node_->record (config);
44 ACE_Stream_Type *st =
45 dynamic_cast<ACE_Stream_Type *> (const_cast<ACE_Service_Type_Impl *> (sst->type ()));
47 // The modules were linked as popped off the yacc stack, so they're in
48 // reverse order from the way they should be pushed onto the stream.
49 // So traverse mods_ and and reverse the list, then iterate over it to push
50 // the modules in the stream in the correct order.
51 #if defined (ACE_HAS_ALLOC_HOOKS)
52 typedef std::list<const ACE_Static_Node *,
53 ACE_Allocator_Std_Adapter<const ACE_Static_Node *> > list_t;
54 #else
55 using list_t = std::list<const ACE_Static_Node *>;
56 #endif /* ACE_HAS_ALLOC_HOOKS */
57 list_t mod_list;
58 const ACE_Static_Node *module;
59 for (module = dynamic_cast<const ACE_Static_Node*> (this->mods_);
60 module != 0;
61 module = dynamic_cast<ACE_Static_Node*> (module->link()))
62 mod_list.push_front (module);
64 list_t::const_iterator iter;
65 for (iter = mod_list.begin (); iter != mod_list.end (); ++iter)
67 module = *iter;
68 ACE_ARGV args (module->parameters ());
70 const ACE_Service_Type *mst = module->record (config);
71 if (mst == 0)
72 const_cast<ACE_Static_Node *> (module)->apply (config, yyerrno);
74 if (yyerrno != 0)
76 if (ACE::debug ())
78 ACELIB_ERROR ((LM_ERROR,
79 ACE_TEXT ("dynamic initialization failed for Module %s\n"),
80 module->name ()));
82 ++yyerrno;
83 continue; // Don't try anything else with this one
86 ACE_Module_Type const * const mt1 =
87 static_cast <ACE_Module_Type const *> (module->record (config)->type());
89 ACE_Module_Type *mt = const_cast<ACE_Module_Type *>(mt1);
91 if (st->push (mt) == -1)
93 if (ACE::debug ())
95 ACELIB_ERROR ((LM_ERROR,
96 ACE_TEXT ("dynamic initialization failed for Stream %s\n"),
97 this->node_->name ()));
99 ++yyerrno;
104 #ifndef ACE_NLOGGING
105 if (ACE::debug ())
106 ACELIB_DEBUG ((LM_DEBUG,
107 ACE_TEXT ("(%P|%t) Did stream on %s, error = %d\n"),
108 this->node_->name (),
109 yyerrno));
110 #endif /* ACE_NLOGGING */
113 ACE_ALLOC_HOOK_DEFINE (ACE_Parse_Node)
115 void
116 ACE_Parse_Node::dump () const
118 #if defined (ACE_HAS_DUMP)
119 ACE_TRACE ("ACE_Parse_Node::dump");
120 #endif /* ACE_HAS_DUMP */
123 const ACE_TCHAR *
124 ACE_Parse_Node::name () const
126 ACE_TRACE ("ACE_Parse_Node::name");
127 return this->name_;
130 ACE_Parse_Node *
131 ACE_Parse_Node::link () const
133 ACE_TRACE ("ACE_Parse_Node::link");
134 return this->next_;
137 void
138 ACE_Parse_Node::link (ACE_Parse_Node *n)
140 ACE_TRACE ("ACE_Parse_Node::link");
142 // Find the last list entry (if any) ...
143 ACE_Parse_Node *t = this;
144 while (t->next_ != 0)
145 t = t->next_;
147 // ... and insert n there.
148 t->next_ = n;
151 ACE_Stream_Node::ACE_Stream_Node (const ACE_Static_Node *str_ops,
152 const ACE_Parse_Node *str_mods)
153 : ACE_Parse_Node ((str_ops == 0 ? ACE_TEXT ("<unknown>") : str_ops->name ())),
154 node_ (str_ops),
155 mods_ (str_mods)
157 ACE_TRACE ("ACE_Stream_Node::ACE_Stream_Node");
161 ACE_Stream_Node::~ACE_Stream_Node ()
163 ACE_TRACE ("ACE_Stream_Node::~ACE_Stream_Node");
164 ACE_Static_Node *n = const_cast<ACE_Static_Node *> (this->node_);
165 delete n;
166 ACE_Parse_Node *m = const_cast<ACE_Parse_Node *> (this->mods_);
167 delete m;
170 ACE_Parse_Node::ACE_Parse_Node ()
171 : name_ (0),
172 next_ (0)
174 ACE_TRACE ("ACE_Parse_Node::ACE_Parse_Node");
178 ACE_Parse_Node::ACE_Parse_Node (const ACE_TCHAR *nm)
179 : name_ (ACE::strnew (nm)),
180 next_ (0)
182 ACE_TRACE ("ACE_Parse_Node::ACE_Parse_Node");
185 void
186 ACE_Parse_Node::print () const
188 ACE_TRACE ("ACE_Parse_Node::print");
190 ACELIB_DEBUG ((LM_DEBUG,
191 ACE_TEXT ("svc = %s\n"),
192 this->name ()));
194 if (this->next_)
195 this->next_->print ();
199 ACE_Parse_Node::~ACE_Parse_Node ()
201 ACE_TRACE ("ACE_Parse_Node::~ACE_Parse_Node");
202 #if defined (ACE_HAS_ALLOC_HOOKS)
203 ACE_Allocator::instance()->free(const_cast<ACE_TCHAR*> (this->name_));
204 #else
205 delete[] const_cast<ACE_TCHAR*> (this->name_);
206 #endif /* ACE_HAS_ALLOC_HOOKS */
207 delete this->next_;
210 ACE_ALLOC_HOOK_DEFINE (ACE_Suspend_Node)
212 void
213 ACE_Suspend_Node::dump () const
215 #if defined (ACE_HAS_DUMP)
216 ACE_TRACE ("ACE_Suspend_Node::dump");
217 #endif /* ACE_HAS_DUMP */
220 ACE_Suspend_Node::ACE_Suspend_Node (const ACE_TCHAR *name)
221 : ACE_Parse_Node (name)
223 ACE_TRACE ("ACE_Suspend_Node::ACE_Suspend_Node");
226 ACE_Suspend_Node::~ACE_Suspend_Node ()
230 ACE_ALLOC_HOOK_DEFINE (ACE_Resume_Node)
232 void
233 ACE_Resume_Node::dump () const
235 #if defined (ACE_HAS_DUMP)
236 ACE_TRACE ("ACE_Resume_Node::dump");
237 #endif /* ACE_HAS_DUMP */
240 ACE_Resume_Node::ACE_Resume_Node (const ACE_TCHAR *name)
241 : ACE_Parse_Node (name)
243 ACE_TRACE ("ACE_Resume_Node::ACE_Resume_Node");
246 ACE_Resume_Node::~ACE_Resume_Node ()
250 void
251 ACE_Suspend_Node::apply (ACE_Service_Gestalt *config, int &yyerrno)
253 ACE_TRACE ("ACE_Suspend_Node::apply");
255 if (config->suspend (this->name ()) == -1)
256 ++yyerrno;
258 #ifndef ACE_NLOGGING
259 if (ACE::debug ())
260 ACELIB_DEBUG ((LM_DEBUG,
261 ACE_TEXT ("did suspend on %s, error = %d\n"),
262 this->name (),
263 yyerrno));
264 #endif /* ACE_NLOGGING */
267 void
268 ACE_Resume_Node::apply (ACE_Service_Gestalt *config, int &yyerrno)
270 ACE_TRACE ("ACE_Resume_Node::apply");
272 if (config->resume (this->name ()) == -1)
273 ++yyerrno;
275 #ifndef ACE_NLOGGING
276 if (ACE::debug ())
277 ACELIB_DEBUG ((LM_DEBUG,
278 ACE_TEXT ("did resume on %s, error = %d\n"),
279 this->name (),
280 yyerrno));
281 #endif /* ACE_NLOGGING */
284 ACE_ALLOC_HOOK_DEFINE (ACE_Remove_Node)
286 void
287 ACE_Remove_Node::dump () const
289 #if defined (ACE_HAS_DUMP)
290 ACE_TRACE ("ACE_Remove_Node::dump");
291 #endif /* ACE_HAS_DUMP */
294 ACE_Remove_Node::ACE_Remove_Node (const ACE_TCHAR *name)
295 : ACE_Parse_Node (name)
297 ACE_TRACE ("ACE_Remove_Node::ACE_Remove_Node");
300 ACE_Remove_Node::~ACE_Remove_Node ()
304 void
305 ACE_Remove_Node::apply (ACE_Service_Gestalt *config, int &yyerrno)
307 ACE_TRACE ("ACE_Remove_Node::apply");
309 if (config->remove (this->name ()) == -1)
310 ++yyerrno;
312 #ifndef ACE_NLOGGING
313 if (ACE::debug ())
314 ACELIB_DEBUG ((LM_DEBUG,
315 ACE_TEXT ("ACE (%P|%t) Remove_Node::apply")
316 ACE_TEXT (" - did remove on %s, error = %d\n"),
317 this->name (),
318 yyerrno));
319 #endif /* ACE_NLOGGING */
323 ACE_Dynamic_Node::ACE_Dynamic_Node (ACE_Service_Type_Factory const *stf,
324 ACE_TCHAR *parms)
325 : ACE_Static_Node (stf->name (), parms)
326 , factory_ (stf)
328 ACE_TRACE ("ACE_Dynamic_Node::ACE_Dynamic_Node");
331 void
332 ACE_Dynamic_Node::apply (ACE_Service_Gestalt *config, int &yyerrno)
334 ACE_TRACE ("ACE_Dynamic_Node::apply");
336 if (config->initialize (this->factory_.get (),
337 this->parameters ()) == -1)
338 ++yyerrno;
340 #ifndef ACE_NLOGGING
341 if (ACE::debug ())
342 ACELIB_DEBUG ((LM_DEBUG,
343 ACE_TEXT ("ACE (%P|%t) Dynamic_Node::apply")
344 ACE_TEXT (" - Did dynamic on %s (yyerrno=%d)\n"),
345 this->name (),
346 yyerrno));
347 #endif /* ACE_NLOGGING */
350 ACE_ALLOC_HOOK_DEFINE (ACE_Dynamic_Node)
352 void
353 ACE_Dynamic_Node::dump () const
355 #if defined (ACE_HAS_DUMP)
356 ACE_TRACE ("ACE_Dynamic_Node::dump");
357 #endif /* ACE_HAS_DUMP */
360 ACE_Dynamic_Node::~ACE_Dynamic_Node ()
362 ACE_TRACE ("ACE_Dynamic_Node::~ACE_Dynamic_Node");
365 ACE_ALLOC_HOOK_DEFINE (ACE_Static_Node)
367 void
368 ACE_Static_Node::dump () const
370 #if defined (ACE_HAS_DUMP)
371 ACE_TRACE ("ACE_Static_Node::dump");
372 #endif /* ACE_HAS_DUMP */
375 ACE_Static_Node::ACE_Static_Node (const ACE_TCHAR *nm,
376 ACE_TCHAR *params)
377 : ACE_Parse_Node (nm),
378 parameters_ (ACE::strnew (params))
380 ACE_TRACE ("ACE_Static_Node::ACE_Static_Node");
383 const ACE_Service_Type *
384 ACE_Static_Node::record (const ACE_Service_Gestalt *config) const
386 ACE_TRACE ("ACE_Static_Node::record");
387 ACE_Service_Type *sr = 0;
389 if (config->find (this->name (), (const ACE_Service_Type **) &sr) == -1)
390 return 0;
392 return sr;
395 ACE_TCHAR *
396 ACE_Static_Node::parameters () const
398 ACE_TRACE ("ACE_Static_Node::parameters");
399 return this->parameters_;
402 void
403 ACE_Static_Node::apply (ACE_Service_Gestalt *config, int &yyerrno)
405 ACE_TRACE ("ACE_Static_Node::apply");
406 if (config->initialize (this->name (),
407 this->parameters ()) == -1)
408 ++yyerrno;
410 #ifndef ACE_NLOGGING
411 if (ACE::debug ())
412 ACELIB_DEBUG ((LM_DEBUG,
413 ACE_TEXT ("ACE (%P|%t) Static_Node::apply -")
414 ACE_TEXT (" Did static on %s (yyerrno=%d)\n"),
415 this->name (),
416 yyerrno));
417 #endif /* ACE_NLOGGING */
420 ACE_Static_Node::~ACE_Static_Node ()
422 ACE_TRACE ("ACE_Static_Node::~ACE_Static_Node");
423 #if defined (ACE_HAS_ALLOC_HOOKS)
424 ACE_Allocator::instance()->free(this->parameters_);
425 #else
426 delete[] this->parameters_;
427 #endif /* ACE_HAS_ALLOC_HOOKS */
431 ACE_ALLOC_HOOK_DEFINE (ACE_Location_Node)
433 void
434 ACE_Location_Node::dump () const
436 #if defined (ACE_HAS_DUMP)
437 ACE_TRACE ("ACE_Location_Node::dump");
438 #endif /* ACE_HAS_DUMP */
441 ACE_Location_Node::ACE_Location_Node ()
442 : pathname_ (0),
443 must_delete_ (0),
444 dll_ (),
445 symbol_ (0)
447 ACE_TRACE ("ACE_Location_Node::ACE_Location_Node");
450 ACE_Location_Node::~ACE_Location_Node ()
452 ACE_TRACE ("ACE_Location_Node::~ACE_Location_Node");
455 const ACE_DLL &
456 ACE_Location_Node::dll ()
458 return this->dll_;
461 const ACE_TCHAR *
462 ACE_Location_Node::pathname () const
464 ACE_TRACE ("ACE_Location_Node::pathname");
465 return this->pathname_;
468 void
469 ACE_Location_Node::pathname (const ACE_TCHAR *p)
471 ACE_TRACE ("ACE_Location_Node::pathname");
472 this->pathname_ = p;
476 ACE_Location_Node::dispose () const
478 ACE_TRACE ("ACE_Location_Node::dispose");
479 return this->must_delete_;
483 ACE_Location_Node::open_dll (int & yyerrno)
485 ACE_TRACE ("ACE_Location_Node::open_dll");
487 #ifndef ACE_NLOGGING
488 if (ACE::debug ())
489 ACELIB_DEBUG ((LM_DEBUG,
490 ACE_TEXT ("ACE (%P|%t) LN::open_dll - path=%s\n"),
491 this->pathname ()));
492 #endif /* ACE_NLOGGING */
494 if (-1 == this->dll_.open (this->pathname ()))
496 ++yyerrno;
498 #ifndef ACE_NLOGGING
499 if (ACE::debug ())
501 ACE_TCHAR *errmsg = this->dll_.error ();
502 ACELIB_ERROR ((LM_ERROR,
503 ACE_TEXT ("ACE (%P|%t) LN::open_dll - Failed to open %s: %s\n"),
504 this->pathname (),
505 errmsg ? errmsg : ACE_TEXT ("no error reported")));
507 #endif /* ACE_NLOGGING */
509 return -1;
512 return 0;
515 void
516 ACE_Location_Node::set_symbol (void *s)
518 ACE_TRACE ("ACE_Location_Node::set_symbol");
519 this->symbol_ = s;
522 ACE_ALLOC_HOOK_DEFINE (ACE_Object_Node)
524 void
525 ACE_Object_Node::dump () const
527 #if defined (ACE_HAS_DUMP)
528 ACE_TRACE ("ACE_Object_Node::dump");
529 #endif /* ACE_HAS_DUMP */
532 ACE_Object_Node::ACE_Object_Node (const ACE_TCHAR *path,
533 const ACE_TCHAR *obj_name)
534 : object_name_ (ACE::strnew (obj_name))
536 ACE_TRACE ("ACE_Object_Node::ACE_Object_Node");
537 this->pathname (ACE::strnew (path));
538 this->must_delete_ = 0;
541 void *
542 ACE_Object_Node::symbol (ACE_Service_Gestalt *,
543 int &yyerrno,
544 ACE_Service_Object_Exterminator *)
546 ACE_TRACE ("ACE_Object_Node::symbol");
547 if (this->open_dll (yyerrno) == 0)
549 ACE_TCHAR *object_name = const_cast<ACE_TCHAR *> (this->object_name_);
551 this->symbol_ = this->dll_.symbol (object_name);
552 if (this->symbol_ == 0)
554 ++yyerrno;
556 #ifndef ACE_NLOGGING
557 if (ACE::debug ())
559 ACE_TCHAR *errmsg = this->dll_.error ();
560 ACELIB_ERROR ((LM_ERROR,
561 ACE_TEXT ("ACE (%P|%t) DLL::symbol -")
562 ACE_TEXT (" Failed for object %s: %s\n"),
563 object_name,
564 errmsg ? errmsg : ACE_TEXT ("no error reported")));
566 #endif /* ACE_NLOGGING */
568 return 0;
571 return this->symbol_;
574 return 0;
577 ACE_Object_Node::~ACE_Object_Node ()
579 ACE_TRACE ("ACE_Object_Node::~ACE_Object_Node");
580 #if defined (ACE_HAS_ALLOC_HOOKS)
581 ACE_Allocator::instance()->free(const_cast<ACE_TCHAR *> (this->object_name_));
582 #else
583 delete[] const_cast<ACE_TCHAR *> (this->object_name_);
584 #endif /* ACE_HAS_ALLOC_HOOKS */
587 ACE_ALLOC_HOOK_DEFINE (ACE_Function_Node)
589 void
590 ACE_Function_Node::dump () const
592 #if defined (ACE_HAS_DUMP)
593 ACE_TRACE ("ACE_Function_Node::dump");
594 #endif /* ACE_HAS_DUMP */
597 ACE_Function_Node::ACE_Function_Node (const ACE_TCHAR *path,
598 const ACE_TCHAR *func_name)
599 : function_name_ (make_func_name (func_name))
601 ACE_TRACE ("ACE_Function_Node::ACE_Function_Node");
602 this->pathname (ACE::strnew (path));
603 this->must_delete_ = 1;
606 ACE_TCHAR *
607 ACE_Function_Node::make_func_name (ACE_TCHAR const * func_name)
609 // Preprocessor symbols will not be expanded if they are
610 // stringified. Force the preprocessor to expand them during the
611 // argument prescan by calling a macro that itself calls another
612 // that performs the actual stringification.
613 #if defined (ACE_HAS_VERSIONED_NAMESPACE) && ACE_HAS_VERSIONED_NAMESPACE == 1
614 # define ACE_MAKE_VERSIONED_NAMESPACE_NAME_STRING_IMPL(NAME) #NAME
615 # define ACE_MAKE_VERSIONED_NAMESPACE_NAME_STRING(NAME) ACE_MAKE_VERSIONED_NAMESPACE_NAME_STRING_IMPL(NAME)
616 # define ACE_VERSIONED_NAMESPACE_NAME_STRING ACE_MAKE_VERSIONED_NAMESPACE_NAME_STRING(ACE_VERSIONED_NAMESPACE_NAME)
618 // Check if function is using the ACE naming convention. If so,
619 // it is likely that the ACE factory function macros
620 // (e.g. ACE_FACTORY_DECLARE) were used to declare and define it, so
621 // mangle the function name to include the ACE versioned namespace
622 // name as is done in the ACE macros. Otherwise, leave the function
623 // name as is.
625 static ACE_TCHAR const make_prefix[] = ACE_TEXT ("_make_");
626 static size_t const make_prefix_len =
627 sizeof (make_prefix) / sizeof (make_prefix[0]) - 1;
629 if (ACE_OS::strncmp (make_prefix, func_name, make_prefix_len) == 0)
631 static ACE_TCHAR const versioned_namespace_name[] =
632 ACE_TEXT (ACE_VERSIONED_NAMESPACE_NAME_STRING) ACE_TEXT("_") ;
634 // Null terminator included in versioned_namespace_name_len since
635 // it is static constant.
636 static size_t const versioned_namespace_name_len =
637 sizeof (versioned_namespace_name)
638 / sizeof (versioned_namespace_name[0]); // - 1;
640 size_t const len =
641 ACE_OS::strlen (func_name)
642 + versioned_namespace_name_len;
643 // + 1; // Null terminator.
645 ACE_TCHAR * mangled_func_name;
646 ACE_NEW_RETURN (mangled_func_name,
647 ACE_TCHAR[len],
650 std::unique_ptr<ACE_TCHAR[]> safe (mangled_func_name);
652 ACE_OS::snprintf (mangled_func_name,
653 len,
654 ACE_TEXT ("%s%s%s"),
655 make_prefix,
656 versioned_namespace_name,
657 func_name + make_prefix_len);
659 return safe.release ();
661 #endif /* ACE_HAS_VERSIONED_NAMESPACE == 1 */
663 return ACE::strnew (func_name);
666 void *
667 ACE_Function_Node::symbol (ACE_Service_Gestalt *,
668 int &yyerrno,
669 ACE_Service_Object_Exterminator *gobbler)
671 using ACE_Service_Factory_Ptr = ACE_Service_Object *(*)(ACE_Service_Object_Exterminator *);
673 ACE_TRACE ("ACE_Function_Node::symbol");
674 if (this->open_dll (yyerrno) == 0)
676 this->symbol_ = 0;
678 // Locate the factory function <function_name> in the shared
679 // object.
680 ACE_TCHAR * const function_name =
681 const_cast<ACE_TCHAR *> (this->function_name_);
683 void * const func_p = this->dll_.symbol (function_name);
684 if (func_p == 0)
686 ++yyerrno;
688 #ifndef ACE_NLOGGING
689 if (ACE::debug ())
691 ACE_TCHAR * const errmsg = this->dll_.error ();
692 ACELIB_ERROR ((LM_ERROR,
693 ACE_TEXT ("DLL::symbol failed for function %s: ")
694 ACE_TEXT ("%s\n"),
695 function_name,
696 errmsg ? errmsg : ACE_TEXT ("no error reported")));
698 #endif /* ACE_NLOGGING */
700 return 0;
703 intptr_t const temp_p = reinterpret_cast<intptr_t> (func_p);
705 ACE_Service_Factory_Ptr func = reinterpret_cast<ACE_Service_Factory_Ptr> (temp_p);
707 // Invoke the factory function and record it's return value.
708 this->symbol_ = (*func) (gobbler);
710 if (this->symbol_ == 0)
712 ++yyerrno;
713 if (ACE::debug ())
715 ACELIB_ERROR ((LM_ERROR,
716 ACE_TEXT ("%p\n"),
717 this->function_name_));
719 return 0;
722 return this->symbol_;
725 ACE_Function_Node::~ACE_Function_Node ()
727 ACE_TRACE ("ACE_Function_Node::~ACE_Function_Node");
728 #if defined (ACE_HAS_ALLOC_HOOKS)
729 ACE_Allocator::instance()->free(const_cast<ACE_TCHAR *> (function_name_));
730 ACE_Allocator::instance()->free(const_cast<ACE_TCHAR *> (pathname_));
731 #else
732 delete[] const_cast<ACE_TCHAR *> (function_name_);
733 delete[] const_cast<ACE_TCHAR *> (pathname_);
734 #endif /* ACE_HAS_ALLOC_HOOKS */
737 ACE_ALLOC_HOOK_DEFINE (ACE_Dummy_Node)
739 void
740 ACE_Dummy_Node::dump () const
742 #if defined (ACE_HAS_DUMP)
743 ACE_TRACE ("ACE_Dummy_Node::dump");
744 #endif /* ACE_HAS_DUMP */
747 ACE_Dummy_Node::ACE_Dummy_Node (const ACE_Static_Node *static_node,
748 const ACE_Parse_Node *str_mods)
749 : ACE_Parse_Node (static_node->name ()),
750 node_ (static_node),
751 mods_ (str_mods)
753 ACE_TRACE ("ACE_Dummy_Node::ACE_Dummy_Node");
756 void
757 ACE_Dummy_Node::apply (ACE_Service_Gestalt *, int &yyerrno)
759 ACE_TRACE ("ACE_Dummy_Node::apply");
761 #ifndef ACE_NLOGGING
762 if (ACE::debug ())
763 ACELIB_DEBUG ((LM_DEBUG,
764 ACE_TEXT ("did operations on stream %s, error = %d\n"),
765 this->name (),
766 yyerrno));
767 #else
768 ACE_UNUSED_ARG (yyerrno);
769 #endif /* ACE_NLOGGING */
772 ACE_Dummy_Node::~ACE_Dummy_Node ()
774 ACE_TRACE ("ACE_Dummy_Node::~ACE_Dummy_Node");
775 ACE_Static_Node *n = const_cast<ACE_Static_Node *> (this->node_);
776 delete n;
777 ACE_Parse_Node *m = const_cast<ACE_Parse_Node *> (this->mods_);
778 delete m;
781 ACE_ALLOC_HOOK_DEFINE (ACE_Static_Function_Node)
783 void
784 ACE_Static_Function_Node::dump () const
786 #if defined (ACE_HAS_DUMP)
787 ACE_TRACE ("ACE_Static_Function_Node::dump");
788 #endif /* ACE_HAS_DUMP */
791 ACE_Static_Function_Node::ACE_Static_Function_Node (const ACE_TCHAR *func_name)
792 : function_name_ (ACE::strnew (func_name))
794 ACE_TRACE ("ACE_Static_Function_Node::ACE_Static_Function_Node");
795 this->must_delete_ = 1;
798 void *
799 ACE_Static_Function_Node::symbol (ACE_Service_Gestalt *config,
800 int &yyerrno,
801 ACE_Service_Object_Exterminator *gobbler)
803 ACE_TRACE ("ACE_Static_Function_Node::symbol");
805 this->symbol_ = 0;
807 // Locate the factory function <function_name> in the statically
808 // linked svcs.
810 ACE_Static_Svc_Descriptor *ssd = 0;
811 if (config->find_static_svc_descriptor (this->function_name_, &ssd) == -1)
813 ++yyerrno;
814 if (ACE::debug ())
816 ACELIB_ERROR ((LM_ERROR,
817 ACE_TEXT ("(%P|%t) No static service ")
818 ACE_TEXT ("registered for function %s\n"),
819 this->function_name_));
821 return 0;
824 if (ssd->alloc_ == 0)
826 ++yyerrno;
828 if (this->symbol_ == 0)
830 ++yyerrno;
832 if (ACE::debug ())
834 ACELIB_ERROR ((LM_ERROR,
835 ACE_TEXT ("(%P|%t) No static service factory ")
836 ACE_TEXT ("function registered for function %s\n"),
837 this->function_name_));
839 return 0;
843 // Invoke the factory function and record it's return value.
844 this->symbol_ = (*ssd->alloc_) (gobbler);
846 if (this->symbol_ == 0)
848 ++yyerrno;
849 if (ACE::debug ())
851 ACELIB_ERROR ((LM_ERROR,
852 ACE_TEXT ("%p\n"),
853 this->function_name_));
855 return 0;
858 return this->symbol_;
861 ACE_Static_Function_Node::~ACE_Static_Function_Node ()
863 ACE_TRACE ("ACE_Static_Function_Node::~ACE_Static_Function_Node");
864 #if defined (ACE_HAS_ALLOC_HOOKS)
865 ACE_Allocator::instance()->free(const_cast<ACE_TCHAR *> (function_name_));
866 #else
867 delete[] const_cast<ACE_TCHAR *> (this->function_name_);
868 #endif /* ACE_HAS_ALLOC_HOOKS */
871 ACE_ALLOC_HOOK_DEFINE (ACE_Service_Type_Factory)
873 ACE_Service_Type_Factory::ACE_Service_Type_Factory (ACE_TCHAR const *name,
874 int type,
875 ACE_Location_Node *location,
876 bool active)
877 : name_ (name)
878 , type_ (type)
879 , location_ (location)
880 , is_active_ (active)
885 ACE_Service_Type_Factory::~ACE_Service_Type_Factory ()
890 ACE_Service_Type *
891 ACE_Service_Type_Factory::make_service_type (ACE_Service_Gestalt *cfg) const
893 ACE_TRACE ("ACE_Service_Type_Factory::make_service_type");
895 u_int const flags = ACE_Service_Type::DELETE_THIS
896 | (this->location_->dispose () == 0 ? 0 : ACE_Service_Type::DELETE_OBJ);
898 int yyerrno = 0;
899 ACE_Service_Object_Exterminator gobbler = 0;
901 void *sym = this->location_->symbol (cfg, yyerrno, &gobbler);
903 if (sym != 0)
905 ACE_Service_Type_Impl *stp =
906 ACE_Service_Config::create_service_type_impl (this->name (),
907 this->type_,
908 sym,
909 flags,
910 gobbler);
911 if (stp == 0)
912 ++yyerrno;
914 ACE_Service_Type *tmp = 0;
915 ACE_NEW_RETURN (tmp,
916 ACE_Service_Type (this->name (),
917 stp,
918 this->location_->dll (),
919 this->is_active_),
921 return tmp;
924 #ifndef ACE_NLOGGING
925 if (ACE::debug ())
927 ACELIB_ERROR ((LM_ERROR,
928 ACE_TEXT ("ACE (%P|%t) Unable to create ")
929 ACE_TEXT ("service object for %s\n"),
930 this->name ()));
932 #endif
933 ++yyerrno;
934 return 0;
937 ACE_TCHAR const*
938 ACE_Service_Type_Factory::name () const
940 return name_.c_str ();
944 ACE_END_VERSIONED_NAMESPACE_DECL
946 #endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */