Any.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 ANY_H
00011 #define ANY_H
00012 
00013 #include "DataElement.h"
00014 
00015 #include <string>
00016 
00017 class AnyData;
00018 
00019 /**
00020  *  Provides custom data storage.
00021  *
00022  *  The %Any element provides storage for custom data types that are not
00023  *  inherently recognized by the data model.  The element provides the means to
00024  *  set and get the custom data stored in the element via the AnyData class
00025  *  which serves as a common base class for all custom data objects.
00026  *
00027  *  The application provides one concrete subclass, DataVariantAnyData, that stores a
00028  *  single DataVariant value.  If the plug-in module creating the
00029  *  DataVariantAnyData object will remain loaded for the lifetime of the %Any
00030  *  element, the plug-in can create the object directly on the heap.  If the
00031  *  plug-in module will be unloaded before the %Any element is destroyed, the
00032  *  plug-in must create the DataVariantAnyData object from the ObjectFactory,
00033  *  which ensures that the %Any element containing the object will be able to
00034  *  successfully delete it when the element is destroyed.
00035  *
00036  *  A plug-in can also create a subclass of AnyData to store custom data that
00037  *  cannot be set into a DataVariant, but the module containing that plug-in
00038  *  must remain loaded so that the %Any element will be able to successfully
00039  *  delete the custom data when the element is destroyed.
00040  *
00041  *  This subclass of Subject will notify upon the following conditions:
00042  *  - The setData() method is called.
00043  *  - Everything else documented in DataElement.
00044  *
00045  *  @see     DataElement
00046  */
00047 class Any : public DataElement
00048 {
00049 public:
00050    /**
00051     *  Sets the custom data managed by this element.
00052     *
00053     *  Ownership of the data is transferred to the element, so the calling
00054     *  object is not responsible for deleting the data.  The element will
00055     *  delete the data when the element is destroyed.
00056     *
00057     *  @param   pData
00058     *           A pointer to the custom data object.
00059     *
00060     *  @notify  This method will notify Subject::signalModified with any<AnyData*>.
00061     */
00062    virtual void setData(AnyData* pData) = 0;
00063 
00064    /**
00065     *  Returns a pointer to the custom data.
00066     *
00067     *  The calling object must cast the data to the proper pointer type to
00068     *  further manipulate it.
00069     *
00070     *  @return  A pointer to the stored data.  \b NULL is returned if no custom
00071     *           data has been set.
00072     */
00073    virtual AnyData* getData() = 0;
00074 
00075    /**
00076     *  Returns read-only access to the custom data.
00077     *
00078     *  The calling object must cast the data to the proper pointer type to
00079     *  further access it.
00080     *
00081     *  @return  A pointer to the stored data.  The custom data represented by
00082     *           the returned pointer should not be modified.  To modify the
00083     *           values, call the non-const version of getData().  \b NULL is
00084     *           returned if no custom data has been set.
00085     */
00086    virtual const AnyData* getData() const = 0;
00087 
00088 protected:
00089    /**
00090     * This should be destroyed by calling ModelServices::destroyElement().
00091     */
00092    virtual ~Any() {}
00093 };
00094 
00095 #endif

Software Development Kit - Opticks 4.9.0 Build 16218