AnyData.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 ANYDATA_H
00011 #define ANYDATA_H
00012 
00013 class SessionItemDeserializer;
00014 class SessionItemSerializer;
00015 
00016 /**
00017  *  Container for custom data stored in an Any element.
00018  *
00019  *  This class serves as a common base class for custom data classes to be set
00020  *  into an Any element.  The constructor is protected since this base class
00021  *  does not contain any actual data and should not be instantiated.
00022  */
00023 class AnyData
00024 {
00025 public:
00026    /**
00027     *  Destroys the custom data object.
00028     *
00029     *  The destructor is called by the Any element when the element is
00030     *  destroyed.  Subclasses should perform any necessary cleanup in their own
00031     *  destructor.
00032     */
00033    virtual ~AnyData()
00034    {
00035    }
00036 
00037    /**
00038     *  Creates a copy of the custom data.
00039     *
00040     *  This method is called when the Any::copy() method is called to copy the
00041     *  data element.  The default implementation of this method returns \b NULL
00042     *  so subclasses should override this method to create a new instance of
00043     *  the object and copy the actual data.  Each subclass can define whether
00044     *  it performs a deep copy or a shallow copy.
00045     *
00046     *  @return  A pointer to a new data object containing a copy of this data.
00047     *           The default implementation returns \b NULL.  If \b NULL is
00048     *           returned, the Any::copy() method will also return \b NULL.
00049     */
00050    virtual AnyData* copy() const
00051    {
00052       return 0;
00053    }
00054 
00055    /**
00056     *  Serializes the AnyData during save session.
00057     *
00058     *  This is equivalent to SessionItem::serialize() for AnyData objects.
00059     *
00060     *  @param   serializer
00061     *           The object to use to save the item as part of the current
00062     * `         session.
00063     *
00064     *  @return  The default implementation simply returns \c true.
00065     *
00066     *  @see     SessionItem::serialize()
00067     */
00068    virtual bool serialize(SessionItemSerializer& serializer) const
00069    {
00070       return true;
00071    }
00072 
00073    /**
00074     *  Deserializes the AnyData during restore session.
00075     *
00076     *  This is equivalent to SessionItem::deserialize() for AnyData objects.
00077     *
00078     *  @param   deserializer
00079     *           The object to use to restore the item from a saved session.
00080     *
00081     *  @return  The default implementation simply returns \c true.
00082     *
00083     *  @see     SessionItem::deserialize()
00084     */
00085    virtual bool deserialize(SessionItemDeserializer& deserializer)
00086    {
00087       return true;
00088    }
00089 
00090 protected:
00091    /**
00092     *  Creates the custom data object.
00093     *
00094     *  The constructor is protected since this base class does not contain any
00095     *  actual data and should not be instantiated.
00096     */
00097    AnyData()
00098    {
00099    }
00100 };
00101 
00102 #endif

Software Development Kit - Opticks 4.9.0 Build 16218