Serializable.h

Go to the documentation of this file.
00001 /*
00002  * The information in this file is
00003  * Copyright(c) 2007 Ball Aerospace & Technologies Corporation
00004  * and is subject to the terms and conditions of the
00005  * GNU Lesser General Public License Version 2.1
00006  * The license text is available from   
00007  * http://www.gnu.org/licenses/lgpl.html
00008  */
00009 
00010 #ifndef SERIALIZABLE_H
00011 #define SERIALIZABLE_H
00012 
00013 #include "XercesIncludes.h"
00014 
00015 using XERCES_CPP_NAMESPACE_QUALIFIER DOMNode;
00016 class XMLWriter;
00017 
00018 /**
00019  *  Converts data into formats that can be read from and saved to disk.
00020  *
00021  *  Objects that can save/restore themselves from a file inherit this
00022  *  interface. Each class that ultimately derives from Serializable 
00023  *  must implement an override of these interfaces, even if an intermediate
00024  *  parent already has an implementation.
00025  *
00026  *  The structure of the serialized output generally has the form of a
00027  *  string with the class name, followed by the data comprising the
00028  *  object plus any data in the object's inherited parent(s).
00029  */
00030 class Serializable
00031 {
00032 public:
00033    /**
00034     *  Converts the contents of this object to XML data.
00035     *
00036     *  @param   pXml
00037     *           Pointer to an XMLWriter object in which the object's contents
00038     *           are written.
00039     *
00040     *  @throw   XmlBase::XmlException
00041     *           This exception (or a subclass) is thrown if there is a problem
00042     *           serializing the object.
00043     *
00044     *  @return  Returns true if the object was successfully converted to XML
00045     *           data.  Returns false if the object cannot be represented in
00046     *           XML format.
00047     */
00048    virtual bool toXml(XMLWriter* pXml) const = 0;
00049 
00050    /**
00051     *  Sets the contents of this object from given XML data.
00052     *
00053     *  @param   pDocument
00054     *           The Xerces DOM node.
00055     *
00056     *  @param   version
00057     *           This is the version of the XML which is being deserialized.
00058     *
00059     *  @throw   XmlBase::XmlException
00060     *           This exception (or a subclass) is thrown if there is a problem
00061     *           deserializing the object.
00062     *
00063     *  @return  Returns true if the object's data values were successfully
00064     *           set from the given XML data.  Returns false if the object
00065     *           cannot be represented in XML format.
00066     */
00067    virtual bool fromXml(DOMNode* pDocument, unsigned int version) = 0;
00068 
00069 protected:
00070    /**
00071     * This should not be deleted directly.  It should be deleted according to
00072     * the instructions provided for the relevant subclass.
00073     */
00074    virtual ~Serializable() {}
00075 };
00076 
00077 #endif

Software Development Kit - Opticks 4.9.0 Build 16218