Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tao / Parser_Registry.cpp
blobeed0f04a2cd1383e5298cea44413545d2831ff67
1 // -*- C++ -*-
2 #include "tao/Parser_Registry.h"
3 #include "tao/IOR_Parser.h"
4 #include "tao/ORB_Core.h"
6 #include "ace/Dynamic_Service.h"
8 #if !defined(__ACE_INLINE__)
9 #include "tao/Parser_Registry.inl"
10 #endif /* __ACE_INLINE__ */
12 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
14 TAO_Parser_Registry::TAO_Parser_Registry ()
15 : parsers_ (nullptr),
16 size_ (0)
20 TAO_Parser_Registry::~TAO_Parser_Registry ()
22 delete [] this->parsers_;
25 int
26 TAO_Parser_Registry::open (TAO_ORB_Core *orb_core)
28 char **names = nullptr;
29 int number_of_names = 0;
31 if (orb_core->resource_factory () == nullptr)
33 return -1;
36 orb_core->resource_factory ()->get_parser_names (names, number_of_names);
38 if (number_of_names == 0)
40 return -1;
43 this->size_ = number_of_names;
44 ACE_NEW_RETURN (this->parsers_,
45 TAO_IOR_Parser*[this->size_],
46 -1);
48 for (size_t i = 0, index = 0; i != this->size_; ++i)
50 this->parsers_[index] =
51 ACE_Dynamic_Service<TAO_IOR_Parser>::instance (orb_core->configuration (),
52 names [i]);
54 if (this->parsers_[index] == nullptr)
56 --number_of_names;
57 if (TAO_debug_level >= 1)
59 TAOLIB_DEBUG ((LM_DEBUG, "TAO (%P|%t) Failed to find Service Object"
60 " for %C.\n", names[i]));
63 else
65 ++index;
69 this->size_ = number_of_names;
70 return 0;
73 TAO_IOR_Parser *
74 TAO_Parser_Registry::match_parser (const char *ior_string)
76 for (Parser_Iterator i = this->begin (); i != this->end (); ++i)
78 if ((*i)->match_prefix (ior_string))
80 return *i;
84 return nullptr;
87 TAO_END_VERSIONED_NAMESPACE_DECL