[7297] Fixed profession spells sorting in trainer spell list at client.
[getmangos.git] / dep / ACE_wrappers / ace / Parse_Node.cpp
blob80e980fca0fa35fb3664fb3e826df5730d83d3ea
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 ACE_RCSID (ace,
15 Parse_Node,
16 "$Id: Parse_Node.cpp 81245 2008-04-05 13:37:47Z johnnyw $")
19 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
21 ACE_ALLOC_HOOK_DEFINE (ACE_Stream_Node)
23 // Provide the class hierarchy that defines the parse tree of Service
24 // Nodes.
26 void
27 ACE_Stream_Node::dump (void) const
29 #if defined (ACE_HAS_DUMP)
30 ACE_TRACE ("ACE_Stream_Node::dump");
31 #endif /* ACE_HAS_DUMP */
34 void
35 ACE_Stream_Node::apply (ACE_Service_Gestalt *config, int &yyerrno)
37 ACE_TRACE ("ACE_Stream_Node::apply");
39 const ACE_Service_Type *sst = this->node_->record (config);
40 if (sst == 0)
41 const_cast<ACE_Static_Node *> (this->node_)->apply (config, yyerrno);
43 if (yyerrno != 0) return;
45 sst = this->node_->record (config);
46 ACE_Stream_Type *st =
47 dynamic_cast<ACE_Stream_Type *> (const_cast<ACE_Service_Type_Impl *> (sst->type ()));
49 for (const ACE_Static_Node *module = dynamic_cast<const ACE_Static_Node*> (this->mods_);
50 module != 0;
51 module = dynamic_cast<ACE_Static_Node*> (module->link()))
53 ACE_ARGV args (module->parameters ());
55 const ACE_Service_Type *mst = module->record (config);
56 if (mst == 0)
57 const_cast<ACE_Static_Node *> (module)->apply (config, yyerrno);
59 if (yyerrno != 0)
61 ACE_ERROR ((LM_ERROR,
62 ACE_TEXT ("dynamic initialization failed for Module %s\n"),
63 module->name ()));
64 ++yyerrno;
67 ACE_Module_Type const * const mt1 =
68 static_cast <ACE_Module_Type const *> (module->record (config)->type());
70 ACE_Module_Type *mt = const_cast<ACE_Module_Type *>(mt1);
72 if (st->push (mt) == -1)
74 ACE_ERROR ((LM_ERROR,
75 ACE_TEXT ("dynamic initialization failed for Stream %s\n"),
76 this->node_->name ()));
77 ++yyerrno;
82 #ifndef ACE_NLOGGING
83 if (ACE::debug ())
84 ACE_DEBUG ((LM_DEBUG,
85 ACE_TEXT ("(%P|%t) Did stream on %s, error = %d\n"),
86 this->node_->name (),
87 yyerrno));
88 #endif /* ACE_NLOGGING */
91 ACE_ALLOC_HOOK_DEFINE (ACE_Parse_Node)
93 void
94 ACE_Parse_Node::dump (void) const
96 #if defined (ACE_HAS_DUMP)
97 ACE_TRACE ("ACE_Parse_Node::dump");
98 #endif /* ACE_HAS_DUMP */
101 const ACE_TCHAR *
102 ACE_Parse_Node::name (void) const
104 ACE_TRACE ("ACE_Parse_Node::name");
105 return this->name_;
108 ACE_Parse_Node *
109 ACE_Parse_Node::link (void) const
111 ACE_TRACE ("ACE_Parse_Node::link");
112 return this->next_;
115 void
116 ACE_Parse_Node::link (ACE_Parse_Node *n)
118 ACE_TRACE ("ACE_Parse_Node::link");
120 // Find the last list entry (if any) ...
121 ACE_Parse_Node *t = this;
122 while (t->next_ != 0)
123 t = t->next_;
125 // ... and insert n there.
126 t->next_ = n;
129 ACE_Stream_Node::ACE_Stream_Node (const ACE_Static_Node *str_ops,
130 const ACE_Parse_Node *str_mods)
131 : ACE_Parse_Node ((str_ops == 0 ? ACE_TEXT ("<unknown>") : str_ops->name ())),
132 node_ (str_ops),
133 mods_ (str_mods)
135 ACE_TRACE ("ACE_Stream_Node::ACE_Stream_Node");
139 ACE_Stream_Node::~ACE_Stream_Node (void)
141 ACE_TRACE ("ACE_Stream_Node::~ACE_Stream_Node");
142 ACE_Static_Node *n = const_cast<ACE_Static_Node *> (this->node_);
143 delete n;
144 ACE_Parse_Node *m = const_cast<ACE_Parse_Node *> (this->mods_);
145 delete m;
148 ACE_Parse_Node::ACE_Parse_Node (void)
149 : name_ (0),
150 next_ (0)
152 ACE_TRACE ("ACE_Parse_Node::ACE_Parse_Node");
156 ACE_Parse_Node::ACE_Parse_Node (const ACE_TCHAR *nm)
157 : name_ (ACE::strnew (nm)),
158 next_ (0)
160 ACE_TRACE ("ACE_Parse_Node::ACE_Parse_Node");
163 void
164 ACE_Parse_Node::print (void) const
166 ACE_TRACE ("ACE_Parse_Node::print");
168 ACE_DEBUG ((LM_DEBUG,
169 ACE_TEXT ("svc = %s\n"),
170 this->name ()));
172 if (this->next_)
173 this->next_->print ();
177 ACE_Parse_Node::~ACE_Parse_Node (void)
179 ACE_TRACE ("ACE_Parse_Node::~ACE_Parse_Node");
180 delete[] const_cast<ACE_TCHAR*> (this->name_);
181 delete this->next_;
184 ACE_ALLOC_HOOK_DEFINE (ACE_Suspend_Node)
186 void
187 ACE_Suspend_Node::dump (void) const
189 #if defined (ACE_HAS_DUMP)
190 ACE_TRACE ("ACE_Suspend_Node::dump");
191 #endif /* ACE_HAS_DUMP */
194 ACE_Suspend_Node::ACE_Suspend_Node (const ACE_TCHAR *name)
195 : ACE_Parse_Node (name)
197 ACE_TRACE ("ACE_Suspend_Node::ACE_Suspend_Node");
200 ACE_Suspend_Node::~ACE_Suspend_Node (void)
204 ACE_ALLOC_HOOK_DEFINE (ACE_Resume_Node)
206 void
207 ACE_Resume_Node::dump (void) const
209 #if defined (ACE_HAS_DUMP)
210 ACE_TRACE ("ACE_Resume_Node::dump");
211 #endif /* ACE_HAS_DUMP */
214 ACE_Resume_Node::ACE_Resume_Node (const ACE_TCHAR *name)
215 : ACE_Parse_Node (name)
217 ACE_TRACE ("ACE_Resume_Node::ACE_Resume_Node");
220 ACE_Resume_Node::~ACE_Resume_Node (void)
224 void
225 ACE_Suspend_Node::apply (ACE_Service_Gestalt *config, int &yyerrno)
227 ACE_TRACE ("ACE_Suspend_Node::apply");
229 if (config->suspend (this->name ()) == -1)
230 ++yyerrno;
232 #ifndef ACE_NLOGGING
233 if (ACE::debug ())
234 ACE_DEBUG ((LM_DEBUG,
235 ACE_TEXT ("did suspend on %s, error = %d\n"),
236 this->name (),
237 yyerrno));
238 #endif /* ACE_NLOGGING */
241 void
242 ACE_Resume_Node::apply (ACE_Service_Gestalt *config, int &yyerrno)
244 ACE_TRACE ("ACE_Resume_Node::apply");
246 if (config->resume (this->name ()) == -1)
247 ++yyerrno;
249 #ifndef ACE_NLOGGING
250 if (ACE::debug ())
251 ACE_DEBUG ((LM_DEBUG,
252 ACE_TEXT ("did resume on %s, error = %d\n"),
253 this->name (),
254 yyerrno));
255 #endif /* ACE_NLOGGING */
258 ACE_ALLOC_HOOK_DEFINE (ACE_Remove_Node)
260 void
261 ACE_Remove_Node::dump (void) const
263 #if defined (ACE_HAS_DUMP)
264 ACE_TRACE ("ACE_Remove_Node::dump");
265 #endif /* ACE_HAS_DUMP */
268 ACE_Remove_Node::ACE_Remove_Node (const ACE_TCHAR *name)
269 : ACE_Parse_Node (name)
271 ACE_TRACE ("ACE_Remove_Node::ACE_Remove_Node");
274 ACE_Remove_Node::~ACE_Remove_Node (void)
278 void
279 ACE_Remove_Node::apply (ACE_Service_Gestalt *config, int &yyerrno)
281 ACE_TRACE ("ACE_Remove_Node::apply");
283 if (config->remove (this->name ()) == -1)
284 ++yyerrno;
286 #ifndef ACE_NLOGGING
287 if (ACE::debug ())
288 ACE_DEBUG ((LM_DEBUG,
289 ACE_TEXT ("ACE (%P|%t) Remove_Node::apply")
290 ACE_TEXT (" - did remove on %s, error = %d\n"),
291 this->name (),
292 yyerrno));
293 #endif /* ACE_NLOGGING */
297 ACE_Dynamic_Node::ACE_Dynamic_Node (ACE_Service_Type_Factory const *stf,
298 ACE_TCHAR *parms)
299 : ACE_Static_Node (stf->name (), parms)
300 , factory_ (stf)
302 ACE_TRACE ("ACE_Dynamic_Node::ACE_Dynamic_Node");
305 void
306 ACE_Dynamic_Node::apply (ACE_Service_Gestalt *config, int &yyerrno)
308 ACE_TRACE ("ACE_Dynamic_Node::apply");
310 if (config->initialize (this->factory_.get (),
311 this->parameters ()) == -1)
312 ++yyerrno;
314 #ifndef ACE_NLOGGING
315 if (ACE::debug ())
316 ACE_DEBUG ((LM_DEBUG,
317 ACE_TEXT ("ACE (%P|%t) Dynamic_Node::apply")
318 ACE_TEXT (" - Did dynamic on %s (yyerrno=%d)\n"),
319 this->name (),
320 yyerrno));
321 #endif /* ACE_NLOGGING */
324 ACE_ALLOC_HOOK_DEFINE (ACE_Dynamic_Node)
326 void
327 ACE_Dynamic_Node::dump (void) const
329 #if defined (ACE_HAS_DUMP)
330 ACE_TRACE ("ACE_Dynamic_Node::dump");
331 #endif /* ACE_HAS_DUMP */
334 ACE_Dynamic_Node::~ACE_Dynamic_Node (void)
336 ACE_TRACE ("ACE_Dynamic_Node::~ACE_Dynamic_Node");
339 ACE_ALLOC_HOOK_DEFINE (ACE_Static_Node)
341 void
342 ACE_Static_Node::dump (void) const
344 #if defined (ACE_HAS_DUMP)
345 ACE_TRACE ("ACE_Static_Node::dump");
346 #endif /* ACE_HAS_DUMP */
349 ACE_Static_Node::ACE_Static_Node (const ACE_TCHAR *nm,
350 ACE_TCHAR *params)
351 : ACE_Parse_Node (nm),
352 parameters_ (ACE::strnew (params))
354 ACE_TRACE ("ACE_Static_Node::ACE_Static_Node");
357 const ACE_Service_Type *
358 ACE_Static_Node::record (const ACE_Service_Gestalt *config) const
360 ACE_TRACE ("ACE_Static_Node::record");
361 ACE_Service_Type *sr = 0;
363 if (config->find (this->name (), (const ACE_Service_Type **) &sr) == -1)
364 return 0;
366 return sr;
369 ACE_TCHAR *
370 ACE_Static_Node::parameters (void) const
372 ACE_TRACE ("ACE_Static_Node::parameters");
373 return this->parameters_;
376 void
377 ACE_Static_Node::apply (ACE_Service_Gestalt *config, int &yyerrno)
379 ACE_TRACE ("ACE_Static_Node::apply");
380 if (config->initialize (this->name (),
381 this->parameters ()) == -1)
382 ++yyerrno;
384 #ifndef ACE_NLOGGING
385 if (ACE::debug ())
386 ACE_DEBUG ((LM_DEBUG,
387 ACE_TEXT ("ACE (%P|%t) Static_Node::apply -")
388 ACE_TEXT (" Did static on %s (yyerrno=%d)\n"),
389 this->name (),
390 yyerrno));
391 #endif /* ACE_NLOGGING */
394 ACE_Static_Node::~ACE_Static_Node (void)
396 ACE_TRACE ("ACE_Static_Node::~ACE_Static_Node");
397 delete[] this->parameters_;
401 ACE_ALLOC_HOOK_DEFINE (ACE_Location_Node)
403 void
404 ACE_Location_Node::dump (void) const
406 #if defined (ACE_HAS_DUMP)
407 ACE_TRACE ("ACE_Location_Node::dump");
408 #endif /* ACE_HAS_DUMP */
411 ACE_Location_Node::ACE_Location_Node (void)
412 : pathname_ (0),
413 dll_ (),
414 symbol_ (0)
416 ACE_TRACE ("ACE_Location_Node::ACE_Location_Node");
419 ACE_Location_Node::~ACE_Location_Node (void)
421 ACE_TRACE ("ACE_Location_Node::~ACE_Location_Node");
424 const ACE_DLL &
425 ACE_Location_Node::dll (void)
427 return this->dll_;
430 const ACE_TCHAR *
431 ACE_Location_Node::pathname (void) const
433 ACE_TRACE ("ACE_Location_Node::pathname");
434 return this->pathname_;
437 void
438 ACE_Location_Node::pathname (const ACE_TCHAR *p)
440 ACE_TRACE ("ACE_Location_Node::pathname");
441 this->pathname_ = p;
445 ACE_Location_Node::dispose (void) const
447 ACE_TRACE ("ACE_Location_Node::dispose");
448 return this->must_delete_;
452 ACE_Location_Node::open_dll (int & yyerrno)
454 ACE_TRACE ("ACE_Location_Node::open_dll");
456 #ifndef ACE_NLOGGING
457 if (ACE::debug ())
458 ACE_DEBUG ((LM_DEBUG,
459 ACE_TEXT ("ACE (%P|%t) LN::open_dll - path=%s\n"),
460 this->pathname ()));
461 #endif /* ACE_NLOGGING */
463 if (-1 == this->dll_.open (this->pathname ()))
465 ++yyerrno;
467 #ifndef ACE_NLOGGING
468 ACE_TCHAR *errmsg = this->dll_.error ();
469 ACE_ERROR ((LM_ERROR,
470 ACE_TEXT ("ACE (%P|%t) LN::open_dll - Failed to open %s: %s\n"),
471 this->pathname (),
472 errmsg ? errmsg : ACE_TEXT ("no error reported")));
473 #endif /* ACE_NLOGGING */
475 return -1;
478 return 0;
482 void
483 ACE_Location_Node::set_symbol (void *s)
485 ACE_TRACE ("ACE_Location_Node::set_symbol");
486 this->symbol_ = s;
489 ACE_ALLOC_HOOK_DEFINE (ACE_Object_Node)
491 void
492 ACE_Object_Node::dump (void) const
494 #if defined (ACE_HAS_DUMP)
495 ACE_TRACE ("ACE_Object_Node::dump");
496 #endif /* ACE_HAS_DUMP */
499 ACE_Object_Node::ACE_Object_Node (const ACE_TCHAR *path,
500 const ACE_TCHAR *obj_name)
501 : object_name_ (ACE::strnew (obj_name))
503 ACE_TRACE ("ACE_Object_Node::ACE_Object_Node");
504 this->pathname (ACE::strnew (path));
505 this->must_delete_ = 0;
508 void *
509 ACE_Object_Node::symbol (ACE_Service_Gestalt *,
510 int &yyerrno,
511 ACE_Service_Object_Exterminator *)
513 ACE_TRACE ("ACE_Object_Node::symbol");
514 if (this->open_dll (yyerrno) == 0)
516 ACE_TCHAR *object_name = const_cast<ACE_TCHAR *> (this->object_name_);
518 this->symbol_ = this->dll_.symbol (object_name);
519 if (this->symbol_ == 0)
521 ++yyerrno;
523 #ifndef ACE_NLOGGING
524 ACE_TCHAR *errmsg = this->dll_.error ();
525 ACE_ERROR ((LM_ERROR,
526 ACE_TEXT ("ACE (%P|%t) DLL::symbol -")
527 ACE_TEXT (" Failed for object %s: %s\n"),
528 object_name,
529 errmsg ? errmsg : ACE_TEXT ("no error reported")));
530 #endif /* ACE_NLOGGING */
532 return 0;
535 return this->symbol_;
538 return 0;
541 ACE_Object_Node::~ACE_Object_Node (void)
543 ACE_TRACE ("ACE_Object_Node::~ACE_Object_Node");
544 delete[] const_cast<ACE_TCHAR *> (this->object_name_);
547 ACE_ALLOC_HOOK_DEFINE (ACE_Function_Node)
549 void
550 ACE_Function_Node::dump (void) const
552 #if defined (ACE_HAS_DUMP)
553 ACE_TRACE ("ACE_Function_Node::dump");
554 #endif /* ACE_HAS_DUMP */
557 ACE_Function_Node::ACE_Function_Node (const ACE_TCHAR *path,
558 const ACE_TCHAR *func_name)
559 : function_name_ (make_func_name (func_name))
561 ACE_TRACE ("ACE_Function_Node::ACE_Function_Node");
562 this->pathname (ACE::strnew (path));
563 this->must_delete_ = 1;
566 ACE_TCHAR *
567 ACE_Function_Node::make_func_name (ACE_TCHAR const * func_name)
569 // Preprocessor symbols will not be expanded if they are
570 // stringified. Force the preprocessor to expand them during the
571 // argument prescan by calling a macro that itself calls another
572 // that performs the actual stringification.
573 #if defined (ACE_HAS_VERSIONED_NAMESPACE) && ACE_HAS_VERSIONED_NAMESPACE == 1
574 # define ACE_MAKE_VERSIONED_NAMESPACE_NAME_STRING_IMPL(NAME) #NAME
575 # define ACE_MAKE_VERSIONED_NAMESPACE_NAME_STRING(NAME) ACE_MAKE_VERSIONED_NAMESPACE_NAME_STRING_IMPL(NAME)
576 # define ACE_VERSIONED_NAMESPACE_NAME_STRING ACE_MAKE_VERSIONED_NAMESPACE_NAME_STRING(ACE_VERSIONED_NAMESPACE_NAME)
578 // Check if function is using the ACE naming convention. If so,
579 // it is likely that the ACE factory function macros
580 // (e.g. ACE_FACTORY_DECLARE) were used to declare and define it, so
581 // mangle the function name to include the ACE versioned namespace
582 // name as is done in the ACE macros. Otherwise, leave the function
583 // name as is.
585 static ACE_TCHAR const make_prefix[] = ACE_TEXT ("_make_");
586 static size_t const make_prefix_len =
587 sizeof (make_prefix) / sizeof (make_prefix[0]) - 1;
589 if (ACE_OS::strncmp (make_prefix, func_name, make_prefix_len) == 0)
591 static ACE_TCHAR const versioned_namespace_name[] =
592 ACE_TEXT (ACE_VERSIONED_NAMESPACE_NAME_STRING) ACE_TEXT("_") ;
594 // Null terminator included in versioned_namespace_name_len since
595 // it is static constant.
596 static size_t const versioned_namespace_name_len =
597 sizeof (versioned_namespace_name)
598 / sizeof (versioned_namespace_name[0]); // - 1;
600 size_t const len =
601 ACE_OS::strlen (func_name)
602 + versioned_namespace_name_len;
603 // + 1; // Null terminator.
605 ACE_TCHAR * mangled_func_name;
606 ACE_NEW_RETURN (mangled_func_name,
607 ACE_TCHAR[len],
610 ACE_Auto_Basic_Array_Ptr<ACE_TCHAR> safe (mangled_func_name);
612 ACE_OS::snprintf (mangled_func_name,
613 len,
614 ACE_TEXT ("%s%s%s"),
615 make_prefix,
616 versioned_namespace_name,
617 func_name + make_prefix_len);
619 return safe.release ();
621 #endif /* ACE_HAS_VERSIONED_NAMESPACE == 1 */
623 return ACE::strnew (func_name);
626 void *
627 ACE_Function_Node::symbol (ACE_Service_Gestalt *,
628 int &yyerrno,
629 ACE_Service_Object_Exterminator *gobbler)
631 typedef ACE_Service_Object *(*ACE_Service_Factory_Ptr)
632 (ACE_Service_Object_Exterminator *);
634 ACE_TRACE ("ACE_Function_Node::symbol");
635 if (this->open_dll (yyerrno) == 0)
637 this->symbol_ = 0;
639 // Locate the factory function <function_name> in the shared
640 // object.
641 ACE_TCHAR * const function_name =
642 const_cast<ACE_TCHAR *> (this->function_name_);
644 void * const func_p = this->dll_.symbol (function_name);
645 if (func_p == 0)
647 ++yyerrno;
649 #ifndef ACE_NLOGGING
650 ACE_TCHAR * const errmsg = this->dll_.error ();
651 ACE_ERROR ((LM_ERROR,
652 ACE_TEXT ("DLL::symbol failed for function %s: ")
653 ACE_TEXT ("%s\n"),
654 function_name,
655 errmsg ? errmsg : ACE_TEXT ("no error reported")));
656 #endif /* ACE_NLOGGING */
658 return 0;
661 #if defined (ACE_OPENVMS) && (!defined (__INITIAL_POINTER_SIZE) || (__INITIAL_POINTER_SIZE < 64))
662 int const temp_p = reinterpret_cast<int> (func_p);
663 #else
664 intptr_t const temp_p = reinterpret_cast<intptr_t> (func_p);
665 #endif
667 ACE_Service_Factory_Ptr func =
668 reinterpret_cast<ACE_Service_Factory_Ptr> (temp_p);
670 // Invoke the factory function and record it's return value.
671 this->symbol_ = (*func) (gobbler);
673 if (this->symbol_ == 0)
675 ++yyerrno;
676 ACE_ERROR_RETURN ((LM_ERROR,
677 ACE_TEXT ("%p\n"),
678 this->function_name_),
682 return this->symbol_;
685 ACE_Function_Node::~ACE_Function_Node (void)
687 ACE_TRACE ("ACE_Function_Node::~ACE_Function_Node");
688 delete[] const_cast<ACE_TCHAR *> (function_name_);
689 delete[] const_cast<ACE_TCHAR *> (pathname_);
692 ACE_ALLOC_HOOK_DEFINE (ACE_Dummy_Node)
694 void
695 ACE_Dummy_Node::dump (void) const
697 #if defined (ACE_HAS_DUMP)
698 ACE_TRACE ("ACE_Dummy_Node::dump");
699 #endif /* ACE_HAS_DUMP */
702 ACE_Dummy_Node::ACE_Dummy_Node (const ACE_Static_Node *static_node,
703 const ACE_Parse_Node *str_mods)
704 : ACE_Parse_Node (static_node->name ()),
705 node_ (static_node),
706 mods_ (str_mods)
708 ACE_TRACE ("ACE_Dummy_Node::ACE_Dummy_Node");
711 void
712 ACE_Dummy_Node::apply (ACE_Service_Gestalt *, int &yyerrno)
714 ACE_TRACE ("ACE_Dummy_Node::apply");
716 #ifndef ACE_NLOGGING
717 if (ACE::debug ())
718 ACE_DEBUG ((LM_DEBUG,
719 ACE_TEXT ("did operations on stream %s, error = %d\n"),
720 this->name (),
721 yyerrno));
722 #else
723 ACE_UNUSED_ARG (yyerrno);
724 #endif /* ACE_NLOGGING */
727 ACE_Dummy_Node::~ACE_Dummy_Node (void)
729 ACE_TRACE ("ACE_Dummy_Node::~ACE_Dummy_Node");
730 ACE_Static_Node *n = const_cast<ACE_Static_Node *> (this->node_);
731 delete n;
732 ACE_Parse_Node *m = const_cast<ACE_Parse_Node *> (this->mods_);
733 delete m;
736 ACE_ALLOC_HOOK_DEFINE (ACE_Static_Function_Node)
738 void
739 ACE_Static_Function_Node::dump (void) const
741 #if defined (ACE_HAS_DUMP)
742 ACE_TRACE ("ACE_Static_Function_Node::dump");
743 #endif /* ACE_HAS_DUMP */
746 ACE_Static_Function_Node::ACE_Static_Function_Node (const ACE_TCHAR *func_name)
747 : function_name_ (ACE::strnew (func_name))
749 ACE_TRACE ("ACE_Static_Function_Node::ACE_Static_Function_Node");
750 this->must_delete_ = 1;
753 void *
754 ACE_Static_Function_Node::symbol (ACE_Service_Gestalt *config,
755 int &yyerrno,
756 ACE_Service_Object_Exterminator *gobbler)
758 ACE_TRACE ("ACE_Static_Function_Node::symbol");
760 this->symbol_ = 0;
762 // Locate the factory function <function_name> in the statically
763 // linked svcs.
765 ACE_Static_Svc_Descriptor *ssd = 0;
766 if (config->find_static_svc_descriptor (this->function_name_, &ssd) == -1)
768 ++yyerrno;
769 ACE_ERROR_RETURN ((LM_ERROR,
770 ACE_TEXT ("(%P|%t) No static service ")
771 ACE_TEXT ("registered for function %s\n"),
772 this->function_name_),
776 if (ssd->alloc_ == 0)
778 ++yyerrno;
780 if (this->symbol_ == 0)
782 ++yyerrno;
784 ACE_ERROR_RETURN ((LM_ERROR,
785 ACE_TEXT ("(%P|%t) No static service factory ")
786 ACE_TEXT ("function registered for function %s\n"),
787 this->function_name_),
792 // Invoke the factory function and record it's return value.
793 this->symbol_ = (*ssd->alloc_) (gobbler);
795 if (this->symbol_ == 0)
797 ++yyerrno;
798 ACE_ERROR_RETURN ((LM_ERROR,
799 ACE_TEXT ("%p\n"),
800 this->function_name_),
804 return this->symbol_;
807 ACE_Static_Function_Node::~ACE_Static_Function_Node (void)
809 ACE_TRACE ("ACE_Static_Function_Node::~ACE_Static_Function_Node");
810 delete[] const_cast<ACE_TCHAR *> (this->function_name_);
813 ACE_ALLOC_HOOK_DEFINE (ACE_Service_Type_Factory)
815 ACE_Service_Type_Factory::ACE_Service_Type_Factory (ACE_TCHAR const *name,
816 int type,
817 ACE_Location_Node *location,
818 int active)
819 : name_ (name)
820 , type_ (type)
821 , location_ (location)
822 , is_active_ (active)
827 ACE_Service_Type_Factory::~ACE_Service_Type_Factory (void)
832 ACE_Service_Type *
833 ACE_Service_Type_Factory::make_service_type (ACE_Service_Gestalt *cfg) const
835 ACE_TRACE ("ACE_Service_Type_Factory::make_service_type");
837 u_int flags = ACE_Service_Type::DELETE_THIS
838 | (this->location_->dispose () == 0 ? 0 : ACE_Service_Type::DELETE_OBJ);
840 int yyerrno = 0;
841 ACE_Service_Object_Exterminator gobbler = 0;
843 void *sym = this->location_->symbol (cfg, yyerrno, &gobbler);
845 if (sym != 0)
847 ACE_Service_Type_Impl *stp =
848 ACE_Service_Config::create_service_type_impl (this->name (),
849 this->type_,
850 sym,
851 flags,
852 gobbler);
853 if (stp == 0)
854 ++yyerrno;
856 ACE_Service_Type *tmp = 0;
857 ACE_NEW_RETURN (tmp,
858 ACE_Service_Type (this->name (),
859 stp,
860 this->location_->dll (),
861 this->is_active_),
863 return tmp;
866 #ifndef ACE_NLOGGING
867 ACE_ERROR ((LM_ERROR,
868 ACE_TEXT ("ACE (%P|%t) Unable to create ")
869 ACE_TEXT ("service object for %s\n"),
870 this->name ()));
871 #endif
872 ++yyerrno;
873 return 0;
876 ACE_TCHAR const*
877 ACE_Service_Type_Factory::name (void) const
879 return name_.c_str ();
883 ACE_END_VERSIONED_NAMESPACE_DECL
885 #endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */