Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Svcconf_Handler.cpp

Go to the documentation of this file.
00001 // -*- C++ -*-  $Id: Svcconf_Handler.cpp,v 1.1.1.1 2003/02/21 18:36:32 chad Exp $
00002 
00003 #include "Svcconf_Handler.h"
00004 #include "ace/ACE.h"
00005 #include "ace/Log_Msg.h"
00006 
00007 #if !defined (__ACEXML_INLINE__)
00008 # include "Svcconf_Handler.i"
00009 #endif /* __ACEXML_INLINE__ */
00010 
00011 ACEXML_Svcconf_Handler::ACEXML_Svcconf_Handler (void)
00012   : in_stream_def_ (0),
00013     in_module_ (0)
00014 {
00015   // no-op
00016 }
00017 
00018 ACEXML_Svcconf_Handler::~ACEXML_Svcconf_Handler (void)
00019 {
00020   // no-op
00021 }
00022 
00023 void
00024 ACEXML_Svcconf_Handler::characters (const ACEXML_Char *,
00025                                     int,
00026                                     int ACEXML_ENV_ARG_DECL_NOT_USED)
00027       ACE_THROW_SPEC ((ACEXML_SAXException))
00028 {
00029   // no-op
00030 }
00031 
00032 void
00033 ACEXML_Svcconf_Handler::endDocument (ACEXML_ENV_SINGLE_ARG_DECL_NOT_USED)
00034       ACE_THROW_SPEC ((ACEXML_SAXException))
00035 {
00036   // no-op
00037 }
00038 
00039 void
00040 ACEXML_Svcconf_Handler::endElement (const ACEXML_Char *,
00041                                     const ACEXML_Char *,
00042                                     const ACEXML_Char *qName ACEXML_ENV_ARG_DECL)
00043       ACE_THROW_SPEC ((ACEXML_SAXException))
00044 {
00045 
00046 
00047   if (ACE_OS_String::strcmp (qName, ACE_TEXT ("dynamic")) == 0)
00048     {
00049       if (this->in_stream_def_)
00050         {
00051           ACE_DEBUG ((LM_INFO, ACE_TEXT ("Create dynamic %s for stream\n"),
00052                       this->stream_info_.name ()));
00053         }
00054       else
00055         {
00056           if (this->in_module_)
00057             {
00058               ACE_DEBUG ((LM_INFO, ACE_TEXT ("Push dynamic %s into stream %s\n"),
00059                           this->parsed_info_.name (),
00060                           this->stream_info_.name ()));
00061             }
00062           else
00063             {
00064               ACE_DEBUG ((LM_INFO, ACE_TEXT ("Apply dynamic %s\n"),
00065                           this->parsed_info_.name ()));
00066             }
00067           this->parsed_info_.reset ();
00068         }
00069     }
00070   else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("static")) == 0)
00071     {
00072       if (this->in_stream_def_)
00073         {
00074           ACE_DEBUG ((LM_INFO, ACE_TEXT ("Create sttaic %s for stream\n"),
00075                       this->stream_info_.name ()));
00076         }
00077       else
00078         {
00079           if (this->in_module_)
00080             {
00081               ACE_DEBUG ((LM_INFO, ACE_TEXT ("Push static %s into stream %s\n"),
00082                           this->parsed_info_.name (),
00083                           this->stream_info_.name ()));
00084             }
00085           else
00086             {
00087               ACE_DEBUG ((LM_INFO, ACE_TEXT ("Apply static %s\n"),
00088                           this->parsed_info_.name ()));
00089             }
00090           this->parsed_info_.reset ();
00091         }
00092     }
00093   else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("module")) == 0)
00094     {
00095       this->in_module_ = 0;
00096     }
00097   else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("streamdef")) == 0 ||
00098            ACE_OS_String::strcmp (qName, ACE_TEXT ("stream")) == 0)
00099     {
00100       ACE_DEBUG ((LM_INFO, ACE_TEXT ("Apply stream %s of type %s\n"),
00101                   this->stream_info_.name (),
00102                   this->stream_info_.name ()));
00103       this->stream_info_.reset ();
00104     }
00105   else
00106     {
00107     }
00108 }
00109 
00110 void
00111 ACEXML_Svcconf_Handler::endPrefixMapping (const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
00112       ACE_THROW_SPEC ((ACEXML_SAXException))
00113 {
00114   // no-op
00115 }
00116 
00117 void
00118 ACEXML_Svcconf_Handler::ignorableWhitespace (const ACEXML_Char *,
00119                                              int,
00120                                              int ACEXML_ENV_ARG_DECL_NOT_USED)
00121       ACE_THROW_SPEC ((ACEXML_SAXException))
00122 {
00123   // no-op
00124 }
00125 
00126 void
00127 ACEXML_Svcconf_Handler::processingInstruction (const ACEXML_Char *,
00128                                                const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
00129       ACE_THROW_SPEC ((ACEXML_SAXException))
00130 {
00131   // no-op
00132 }
00133 
00134 void
00135 ACEXML_Svcconf_Handler::setDocumentLocator (ACEXML_Locator* )
00136 {
00137 }
00138 
00139 void
00140 ACEXML_Svcconf_Handler::skippedEntity (const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
00141       ACE_THROW_SPEC ((ACEXML_SAXException))
00142 {
00143   // no-op
00144 }
00145 
00146 void
00147 ACEXML_Svcconf_Handler::startDocument (ACEXML_ENV_SINGLE_ARG_DECL_NOT_USED)
00148       ACE_THROW_SPEC ((ACEXML_SAXException))
00149 {
00150   // no-op
00151 }
00152 
00153 void
00154 ACEXML_Svcconf_Handler::startElement (const ACEXML_Char *,
00155                                       const ACEXML_Char *,
00156                                       const ACEXML_Char *qName,
00157                                       ACEXML_Attributes *alist ACEXML_ENV_ARG_DECL)
00158       ACE_THROW_SPEC ((ACEXML_SAXException))
00159 {
00160   if (ACE_OS_String::strcmp (qName, ACE_TEXT ("dynamic")) == 0)
00161     {
00162       this->get_dynamic_attrs (alist ACEXML_ENV_ARG_PARAMETER);
00163     }
00164   else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("initializer")) == 0)
00165     {
00166       this->get_initializer_attrs (alist ACEXML_ENV_ARG_PARAMETER);
00167     }
00168   else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("static")) == 0)
00169     {
00170       this->get_static_attrs (alist ACEXML_ENV_ARG_PARAMETER);
00171     }
00172   else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("stream")) == 0)
00173     {
00174       this->get_stream_id (alist ACEXML_ENV_ARG_PARAMETER);
00175       ACE_DEBUG ((LM_INFO, ACE_TEXT ("Retrieve stream %s from repository\n"),
00176                   this->stream_info_.name ()));
00177     }
00178   else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("streamdef")) == 0)
00179     {
00180       this->in_stream_def_ = 1;
00181       // @@ Set up stream service object
00182     }
00183   else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("module")) == 0)
00184     {
00185       this->in_stream_def_ = 0;
00186       this->in_module_ = 1;
00187     }
00188   else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("resume")) == 0)
00189     {
00190       this->get_id (alist ACEXML_ENV_ARG_PARAMETER);
00191       if (this->in_module_)
00192         {
00193           ACE_DEBUG ((LM_INFO, ACE_TEXT ("Resume %s in stream %s\n"),
00194                       this->parsed_info_.name (),
00195                       this->stream_info_.name ()));
00196         }
00197       else
00198         {
00199           ACE_DEBUG ((LM_INFO, ACE_TEXT ("Resume %s\n"),
00200                       this->parsed_info_.name ()));
00201         }
00202       this->parsed_info_.reset ();
00203     }
00204   else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("suspend")) == 0)
00205     {
00206       this->get_id (alist ACEXML_ENV_ARG_PARAMETER);
00207       if (this->in_module_)
00208         {
00209           ACE_DEBUG ((LM_INFO, ACE_TEXT ("Suspend %s in stream %s\n"),
00210                       this->parsed_info_.name (),
00211                       this->stream_info_.name ()));
00212         }
00213       else
00214         {
00215           ACE_DEBUG ((LM_INFO, ACE_TEXT ("Suspend %s\n"),
00216                       this->parsed_info_.name ()));
00217         }
00218       this->parsed_info_.reset ();
00219     }
00220   else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("remove")) == 0)
00221     {
00222       this->get_id (alist ACEXML_ENV_ARG_PARAMETER);
00223       if (this->in_module_)
00224         {
00225           ACE_DEBUG ((LM_INFO, ACE_TEXT ("Remove %s in stream %s\n"),
00226                       this->parsed_info_.name (),
00227                       this->stream_info_.name ()));
00228         }
00229       else
00230         {
00231           ACE_DEBUG ((LM_INFO, ACE_TEXT ("Remove %s\n"),
00232                       this->parsed_info_.name ()));
00233         }
00234       this->parsed_info_.reset ();
00235     }
00236   else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("ACE_Svc_Conf")) == 0)
00237     {
00238       // Main document tag. no-op.
00239       ACE_DEBUG ((LM_INFO, ACE_TEXT ("ACE_Svc_Conf tag\n")));
00240     }
00241   else
00242     {
00243       // @@ Error.  Perhaps we should relay to user event handler here, if available.
00244     }
00245 
00246   return;
00247 
00248   if (alist != 0)
00249     for (size_t i = 0; i < alist->getLength (); ++i)
00250       {
00251         ACE_DEBUG ((LM_DEBUG,
00252                     ACE_TEXT (" %s = \"%s\""),
00253                     alist->getQName (i), alist->getValue (i)));
00254       }
00255   ACE_DEBUG ((LM_DEBUG, ACE_TEXT (">")));
00256 }
00257 
00258 void
00259 ACEXML_Svcconf_Handler::startPrefixMapping (const ACEXML_Char *,
00260                                             const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
00261       ACE_THROW_SPEC ((ACEXML_SAXException))
00262 {
00263   // No-op.
00264 }
00265 
00266 // *** Methods inherit from ACEXML_DTDHandler.
00267 
00268 void
00269 ACEXML_Svcconf_Handler::notationDecl (const ACEXML_Char *,
00270                                       const ACEXML_Char *,
00271                                       const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
00272       ACE_THROW_SPEC ((ACEXML_SAXException))
00273 {
00274   // No-op.
00275 }
00276 
00277 void
00278 ACEXML_Svcconf_Handler::unparsedEntityDecl (const ACEXML_Char *,
00279                                             const ACEXML_Char *,
00280                                             const ACEXML_Char *,
00281                                             const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
00282       ACE_THROW_SPEC ((ACEXML_SAXException))
00283 {
00284   // No-op.
00285 }
00286 
00287 // Methods inherit from ACEXML_EnitityResolver.
00288 
00289 ACEXML_InputSource *
00290 ACEXML_Svcconf_Handler::resolveEntity (const ACEXML_Char *,
00291                                        const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
00292       ACE_THROW_SPEC ((ACEXML_SAXException))
00293 {
00294   // No-op.
00295   return 0;
00296 }
00297 
00298 // Methods inherit from ACEXML_ErrorHandler.
00299 
00300   /*
00301    * Receive notification of a recoverable error.
00302    */
00303 void
00304 ACEXML_Svcconf_Handler::error (ACEXML_SAXParseException & ACEXML_ENV_ARG_DECL_NOT_USED)
00305       ACE_THROW_SPEC ((ACEXML_SAXException))
00306 {
00307   // No-op.
00308 }
00309 
00310 void
00311 ACEXML_Svcconf_Handler::fatalError (ACEXML_SAXParseException & ACEXML_ENV_ARG_DECL_NOT_USED)
00312       ACE_THROW_SPEC ((ACEXML_SAXException))
00313 {
00314   // No-op.
00315 }
00316 
00317 void
00318 ACEXML_Svcconf_Handler::warning (ACEXML_SAXParseException & ACEXML_ENV_ARG_DECL_NOT_USED)
00319       ACE_THROW_SPEC ((ACEXML_SAXException))
00320 {
00321   // No-op.
00322 }
00323 
00324 int
00325 ACEXML_Svcconf_Handler::get_stream_id (ACEXML_Attributes *alist ACEXML_ENV_ARG_DECL)
00326 {
00327 
00328 
00329   if (alist != 0)
00330     for (size_t i = 0; i < alist->getLength (); ++i)
00331       {
00332         if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0)
00333           {
00334             this->stream_info_.name (alist->getValue (i));
00335           }
00336         else
00337           {
00338             // @@ Exception...
00339             return -1;
00340           }
00341       }
00342   return 0;
00343 }
00344 
00345 int
00346 ACEXML_Svcconf_Handler::get_id (ACEXML_Attributes *alist ACEXML_ENV_ARG_DECL)
00347 {
00348 
00349 
00350   if (alist != 0)
00351     for (size_t i = 0; i < alist->getLength (); ++i)
00352       {
00353         if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0)
00354           {
00355             this->parsed_info_.name (alist->getValue (i));
00356           }
00357         else
00358           {
00359             // @@ Exception...
00360             return -1;
00361           }
00362       }
00363   return 0;
00364 }
00365 
00366 int
00367 ACEXML_Svcconf_Handler::get_dynamic_attrs (ACEXML_Attributes *alist ACEXML_ENV_ARG_DECL)
00368 {
00369 
00370 
00371   if (alist != 0)
00372     {
00373       ACE_Parsed_Info *info = (this->in_stream_def_ == 0 ?
00374                                &this->parsed_info_ :
00375                                &this->stream_info_);
00376       for (size_t i = 0; i < alist->getLength (); ++i)
00377         {
00378           if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0)
00379             {
00380               info->name (alist->getValue (i));
00381             }
00382           else if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("status")) == 0)
00383             {
00384               if (ACE_OS_String::strcmp (alist->getValue (i), ACE_TEXT ("inactive")) == 0)
00385                 {
00386                 }
00387               else if (ACE_OS_String::strcmp (alist->getValue (i), ACE_TEXT ("active")) == 0)
00388                 {
00389                 }
00390               else
00391                 {
00392                   // @@ error, invalid 'status' value.
00393                 }
00394             }
00395           else if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("type")) == 0)
00396             {
00397               if (ACE_OS_String::strcmp (alist->getValue (i), ACE_TEXT ("service_object")) == 0)
00398                 {
00399                   info->service_type (ACE_Parsed_Info::SERVICE_OBJECT_TYPE);
00400                 }
00401               else if (ACE_OS_String::strcmp (alist->getValue (i), ACE_TEXT ("stream")) == 0)
00402                 {
00403                   info->service_type (ACE_Parsed_Info::STREAM_TYPE);
00404                 }
00405               else if (ACE_OS_String::strcmp (alist->getValue (i), ACE_TEXT ("module")) == 0)
00406                 {
00407                   info->service_type (ACE_Parsed_Info::MODULE_TYPE);
00408                 }
00409               else
00410                 {
00411                   // @@ error, invalid 'type' value.
00412                 }
00413             }
00414           else
00415             {
00416               // @@ Exception...
00417               return -1;
00418             }
00419         }
00420     }
00421   return 0;
00422 }
00423 
00424 int
00425 ACEXML_Svcconf_Handler::get_initializer_attrs (ACEXML_Attributes *alist ACEXML_ENV_ARG_DECL)
00426 {
00427 
00428 
00429   if (alist != 0)
00430     {
00431       ACE_Parsed_Info *info = (this->in_stream_def_ == 0 ?
00432                                &this->parsed_info_ :
00433                                &this->stream_info_);
00434       for (size_t i = 0; i < alist->getLength (); ++i)
00435         {
00436           if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("init")) == 0)
00437             {
00438               info->init_func (alist->getValue (i));
00439             }
00440           else if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("path")) == 0)
00441             {
00442               info->path (alist->getValue (i));
00443             }
00444           else if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("params")) == 0)
00445             {
00446               info->init_params (alist->getValue (i));
00447             }
00448           else
00449             {
00450               // @@ Exception...
00451               return -1;
00452             }
00453         }
00454     }
00455   return 0;
00456 }
00457 
00458 int
00459 ACEXML_Svcconf_Handler::get_static_attrs (ACEXML_Attributes *alist ACEXML_ENV_ARG_DECL)
00460 {
00461 
00462 
00463   if (alist != 0)
00464     {
00465       ACE_Parsed_Info *info = (this->in_stream_def_ == 0 ?
00466                                &this->parsed_info_ :
00467                                &this->stream_info_);
00468       for (size_t i = 0; i < alist->getLength (); ++i)
00469         {
00470           if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0)
00471             {
00472               info->name (alist->getValue (i));
00473             }
00474           else if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("params")) == 0)
00475             {
00476               info->init_params (alist->getValue (i));
00477             }
00478           else
00479             {
00480               // @@ Exception...
00481               return -1;
00482             }
00483         }
00484     }
00485   return 0;
00486 }

Generated on Mon Jun 16 13:23:26 2003 for ACEXML by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002