- Main Page
- Namespaces
- Classes
- Files
- Related Pages

# /Users/fpy/titan-1-5-MBARI/Mers/Utils/Io/Xml/Sax/ContentLauncher.h

    00001
    00002 //
    00003 // Copyright (c) 2005           Model-based Embedded and Robotic Systems Group
    00004 // All Rights Reserved          Massachusetts Institute of Technology
    00005 //
    00006 // This software is provided as is. Model-based Embedded and Robotic Systems
    00007 // (MERS) group does not assume any responsibility.
    00008 //
    00010
    00011 #ifndef MERS_UTILS_IO_XML_SAX_CONTENTLAUNCHER_HEADER_FILE
    00012 #define MERS_UTILS_IO_XML_SAX_CONTENTLAUNCHER_HEADER_FILE
    00013
    00014 #include "TypedCH.h"
    00015 #include <Mers/Utils/Exceptions/RuntimeException.h>
    00016 #include <xercesc/sax2/SAX2XMLReader.hpp>
    00017
    00018 namespace Mers {
    00019         namespace Utils {
    00020                 namespace Io {
    00021                         namespace Xml {
    00022                                 namespace Sax {
    00028                                         template<class Content, class Callback, typename Data>
    00029                                         class ContentLauncher : public TypedCH< Data >
    00030                                         {
    00031                                         public:
    00041                                                 ContentLauncher( XERCES_CPP_NAMESPACE::SAX2XMLReader * reader,
    00042                                                         Data data, Callback * callback )
    00043                                                         : TypedCH< Data >( reader, data, NULL ), m_Callback( callback )
    00044                                                 {
    00045                                                 }
    00046
    00065                                                 virtual void endElement(
    00066                                                         const XMLCh * const uri,
    00067                                                         const XMLCh * const localname,
    00068                                                         const XMLCh * const qname)
    00069                                                 {
    00070                                                         (void) uri;
    00071                                                         (void) localname;
    00072                                                         (void) qname;
    00073                                                         LOG4CPLUS_ERROR( ContentHandler::m_Logger,
    00074                                                                 "ContentLauncher should never reach an end element" );
    00075                                                         throw ::Mers::Utils::Exceptions::RuntimeException(
    00076                                                                 "Unsupported end element in ContentLauncher",
    00077                                                                 __FILE__, __LINE__ );
    00078                                                 }
    00079
    00116                                                 virtual void startElement(
    00117                                                         const XMLCh * const uri,
    00118                                                         const XMLCh * const localname,
    00119                                                         const XMLCh * const qname,
    00120                                                         const XERCES_CPP_NAMESPACE::Attributes& attrs)
    00121                                                 {
    00122                                                         (void) uri;
    00123                                                         (void) localname;
    00124                                                         (void) qname;
    00125                                                         (void) attrs;
    00126
    00127                                                         LOG4CPLUS_TRACE( ContentHandler::m_Logger, "Launching Content " );
    00128
    00129                                                         // Handle launching a new content handler.
    00130                                                         Content * c = new Content( TypedCH<Data>::m_Reader,
    00131                                                                 TypedCH<Data>::m_Data, TypedCH<Data>::m_Parent,
    00132                                                                 m_Callback );
    00133                                                         c->setDocumentLocator( TypedCH<Data>::getDocumentLocator() );
    00134                                                         TypedCH<Data>::m_Reader->setContentHandler( c );
    00135
    00136                                                         // We're all done now, clean ourself up.
    00137                                                         delete this;
    00138                                                 }
    00139
    00140                                         protected:
    00141                                                 // The callback object used for launch.
    00142                                                 Callback * m_Callback;
    00143                                         };
    00144                                 }
    00145                         }
    00146                 }
    00147         }
    00148 }
    00149
    00150 #endif