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

# /Users/fpy/titan-1-5-MBARI/Mers/Utils/Io/Xml/Sax/CallbackStore.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_CALLBACKSTORE_HEADER_FILE
    00012 #define MERS_UTILS_IO_XML_SAX_CALLBACKSTORE_HEADER_FILE
    00013
    00014 #include "ContentCallback.h"
    00015 #include <cstdlib>
    00016
    00017 namespace Mers {
    00018         namespace Utils {
    00019                 namespace Io {
    00020                         namespace Xml {
    00021                                 namespace Sax {
    00025                                         template<typename Type>
    00026                                         class CallbackStore : public ContentCallback<Type>
    00027                                         {
    00028                                         public:
    00032                                                 CallbackStore()
    00033                                                         : ContentCallback<Type>(), m_Data()
    00034                                                 {
    00035                                                 }
    00036
    00046                                                 virtual void handleContent( Type data, const XMLCh * element )
    00047                                                 {
    00048                                                         m_Data = data;
    00049                                                 }
    00050
    00055                                                 Type get()
    00056                                                 {
    00057                                                         Type ret = m_Data;
    00058                                                         m_Data = Type();
    00059                                                         return ret;
    00060                                                 }
    00061
    00062                                         protected:
    00063                                                 Type m_Data;
    00064                                         };
    00065
    00070                                         template<typename Type>
    00071                                         class CallbackStore<Type *> : public ContentCallback<Type *>
    00072                                         {
    00073                                         public:
    00077                                                 CallbackStore()
    00078                                                         : ContentCallback<Type *>(), m_Data(NULL)
    00079                                                 {
    00080                                                 }
    00081
    00091                                                 virtual void handleContent( Type * data, const XMLCh * element )
    00092                                                 {
    00093                                                         (void) element;
    00094                                                         if( m_Data != NULL )
    00095                                                                 delete m_Data;
    00096                                                         m_Data = data;
    00097                                                 }
    00098
    00103                                                 Type * get()
    00104                                                 {
    00105                                                         Type * ret = m_Data;
    00106                                                         m_Data = NULL;
    00107                                                         return ret;
    00108                                                 }
    00109
    00110                                         protected:
    00111                                                 Type * m_Data;
    00112                                         };
    00113                                 }
    00114                         }
    00115                 }
    00116         }
    00117 }
    00118
    00119 #endif
    00120