00001 // $Id: Parser_Registry.cpp 76687 2007-01-29 19:18:13Z johnnyw $ 00002 00003 #include "tao/Parser_Registry.h" 00004 #include "tao/IOR_Parser.h" 00005 #include "tao/ORB_Core.h" 00006 00007 #include "ace/Dynamic_Service.h" 00008 00009 #if !defined(__ACE_INLINE__) 00010 #include "tao/Parser_Registry.inl" 00011 #endif /* __ACE_INLINE__ */ 00012 00013 ACE_RCSID (tao, 00014 Parser_Registry, 00015 "$Id: Parser_Registry.cpp 76687 2007-01-29 19:18:13Z johnnyw $") 00016 00017 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00018 00019 TAO_Parser_Registry::TAO_Parser_Registry (void) 00020 : parsers_ (0), 00021 size_ (0) 00022 { 00023 } 00024 00025 TAO_Parser_Registry::~TAO_Parser_Registry (void) 00026 { 00027 delete [] this->parsers_; 00028 } 00029 00030 int 00031 TAO_Parser_Registry::open (TAO_ORB_Core *orb_core) 00032 { 00033 char **names; 00034 int number_of_names = 0; 00035 00036 orb_core->resource_factory ()->get_parser_names (names, number_of_names); 00037 00038 if (number_of_names == 0) 00039 { 00040 return -1; 00041 } 00042 00043 this->size_ = number_of_names; 00044 ACE_NEW_RETURN (this->parsers_, 00045 TAO_IOR_Parser*[this->size_], 00046 -1); 00047 00048 for (size_t i = 0; i != this->size_; ++i) 00049 { 00050 this->parsers_[i] = 00051 ACE_Dynamic_Service<TAO_IOR_Parser>::instance (orb_core->configuration (), 00052 names [i]); 00053 00054 if (this->parsers_[i] == 0) 00055 { 00056 return -1; 00057 } 00058 } 00059 00060 return 0; 00061 } 00062 00063 TAO_IOR_Parser * 00064 TAO_Parser_Registry::match_parser (const char *ior_string) 00065 { 00066 for (Parser_Iterator i = this->begin (); i != this->end (); ++i) 00067 { 00068 if ((*i)->match_prefix (ior_string)) 00069 { 00070 return *i; 00071 } 00072 } 00073 00074 return 0; 00075 } 00076 00077 TAO_END_VERSIONED_NAMESPACE_DECL