Parser_Registry.cpp

Go to the documentation of this file.
00001 // $Id: Parser_Registry.cpp 80572 2008-02-05 20:02:46Z 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 80572 2008-02-05 20:02:46Z 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 = 0;
00034   int number_of_names = 0;
00035 
00036   if (orb_core->resource_factory () == 0)
00037     {
00038       return -1;
00039     }
00040 
00041   orb_core->resource_factory ()->get_parser_names (names, number_of_names);
00042 
00043   if (number_of_names == 0)
00044     {
00045       return -1;
00046     }
00047 
00048   this->size_ = number_of_names;
00049   ACE_NEW_RETURN (this->parsers_,
00050                   TAO_IOR_Parser*[this->size_],
00051                   -1);
00052 
00053   for (size_t i = 0, index = 0; i != this->size_; ++i)
00054     {
00055       this->parsers_[index] =
00056         ACE_Dynamic_Service<TAO_IOR_Parser>::instance (orb_core->configuration (),
00057                                                        names [i]);
00058 
00059       if (this->parsers_[index] == 0)
00060         {
00061           --number_of_names;
00062           if (TAO_debug_level >= 1)
00063             {
00064               ACE_DEBUG ((LM_DEBUG, "TAO (%P|%t) Failed to find Service Object"
00065                           " for %s.\n", names[i]));
00066             }
00067         }
00068       else
00069         {
00070           ++index;
00071         }
00072     }
00073 
00074   this->size_ = number_of_names;
00075   return 0;
00076 }
00077 
00078 TAO_IOR_Parser *
00079 TAO_Parser_Registry::match_parser (const char *ior_string)
00080 {
00081   for (Parser_Iterator i = this->begin (); i != this->end (); ++i)
00082     {
00083       if ((*i)->match_prefix (ior_string))
00084         {
00085           return *i;
00086         }
00087     }
00088 
00089   return 0;
00090 }
00091 
00092 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Tue Feb 2 17:37:52 2010 for TAO by  doxygen 1.4.7