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 DATAELEMENT_H 00011 #define DATAELEMENT_H 00012 00013 #include "SessionItem.h" 00014 #include "Subject.h" 00015 #include "Serializable.h" 00016 00017 #include <string> 00018 00019 class Classification; 00020 class DataDescriptor; 00021 class DynamicObject; 00022 00023 /** 00024 * Base class for all data elements. 00025 * 00026 * The DataElement is a base class for all objects that are managed by 00027 * ModelServices within the application. This class only stores anscillary 00028 * data in a DataDescriptor object, where subclasses store or manage the 00029 * actual raw data. An instance of this class can be created to provide an 00030 * element container for custom data not provided by the subclasses. 00031 * 00032 * This subclass of Subject will notify upon the following conditions: 00033 * - The Subject::signalModified notification is sent when the following items 00034 * are modified in the data descriptor: classification, metadata, and file 00035 * descriptor. 00036 * - The data descriptor's name or parent element are changed through 00037 * ModelServices. 00038 * 00039 * @see Subject, Serializable, DataDescriptor 00040 */ 00041 class DataElement : public SessionItem, public Subject, public Serializable 00042 { 00043 public: 00044 /** 00045 * Returns all anscillary data for the element. 00046 * 00047 * @return A pointer to the DataDescriptor object containing the element anscillary 00048 * data. 00049 */ 00050 virtual DataDescriptor* getDataDescriptor() = 0; 00051 00052 /** 00053 * Returns read-only access to all anscillary data for the element. 00054 * 00055 * @return A const pointer to the DataDescriptor object containing the element 00056 * anscillary data. The data represented by the returned pointer should 00057 * not be modified. To modify the values, call the non-const version of 00058 * getDataDescriptor(). 00059 */ 00060 virtual const DataDescriptor* getDataDescriptor() const = 0; 00061 00062 /** 00063 * Returns the identifying type for the element. 00064 * 00065 * This is a convenience method that returns the element type that is stored in the 00066 * DataDescriptor object. 00067 * 00068 * The element type is one of the unique identifiers for a DataElement that is used 00069 * to query elements in the ModelServices interface. 00070 * 00071 * @return The element type. The returned type will be one of the valid element 00072 * type strings returned by ModelServices::getValidElementTypes(), which 00073 * may not be the same type returned by getObjectType(). 00074 * 00075 * @see DataDescriptor::getType(), ModelServices::getElement() 00076 */ 00077 virtual std::string getType() const = 0; 00078 00079 /** 00080 * Returns the filename where the element is saved on disk. 00081 * 00082 * This is a convenience method that returns the filename that is stored in the 00083 * FileDecriptor object contained in the element's DataDescriptor object. 00084 * 00085 * @return The element filename. An empty string is returned if the element was not 00086 * originally imported from a file on disk. 00087 * 00088 * @see FileDescriptor::getFilename() 00089 */ 00090 virtual std::string getFilename() const = 0; 00091 00092 /** 00093 * Returns the parent element. 00094 * 00095 * This is a convenience method that returns the parent element that is stored 00096 * in the DataDescriptor object. The element parent is typically the data set 00097 * to which the element is associated. 00098 * 00099 * The parent element is one of the unique identifiers for a DataElement that 00100 * is used to query elements in the ModelServices interface. 00101 * 00102 * @return The element's associated parent element. \b NULL is returned if the 00103 * element does not have a parent. 00104 * 00105 * @see DataDescriptor::getParentElement(), ModelServices::getElement() 00106 */ 00107 virtual DataElement* getParent() const = 0; 00108 00109 /** 00110 * Returns the parent element designator. 00111 * 00112 * The parent element designator is a vector of strings such that the first 00113 * string is the name of a top level element, the second is the name of a child 00114 * of that element, and so on. This designator identifies the parent element. 00115 * 00116 * @return A parent element designator 00117 * 00118 * @see getParent(), ModelServices::createDataDescriptor(const std::string&,const std::string&, const std::vector<std::string>&) const 00119 */ 00120 virtual std::vector<std::string> getParentDesignator() const = 0; 00121 00122 /** 00123 * Returns a pointer to the element's classification object. 00124 * 00125 * The classification object documents how the data in the element is to be 00126 * handled and/or restricted. 00127 * 00128 * This is a convenience method that returns the classification object that 00129 * is stored in the DataDescriptor object. 00130 * 00131 * @return A pointer to the element's classification object. 00132 * 00133 * @see DataDescriptor::getClassification(), Classification 00134 */ 00135 virtual Classification* getClassification() = 0; 00136 00137 /** 00138 * Returns read-only access to the element's classification object. 00139 * 00140 * The classification object documents how the data in the element is to be 00141 * handled and/or restricted. 00142 * 00143 * This is a convenience method that returns the classification object that 00144 * is stored in the DataDescriptor object. 00145 * 00146 * @return A const pointer to the element's classification object. 00147 * The classification represented by the returned pointer should 00148 * not be modified. To modify the values, call the non-const 00149 * version of getClassification() instead. 00150 * 00151 * @see DataDescriptor::getClassification(), Classification 00152 */ 00153 virtual const Classification* getClassification() const = 0; 00154 00155 /** 00156 * Sets the element's classification object. 00157 * 00158 * The classification object documents how the data in element is to be handled and/or 00159 * restricted. 00160 * 00161 * This is a convenience method that makes a deep copy of the given classification object 00162 * that is stored in its DataDescriptor object, so it is the responsibility of the calling object 00163 * to delete the classification object when necessary. 00164 * 00165 * @param pClassification 00166 * The classification for the element. A deep copy is performed 00167 * so it is the responsibility of the calling object to delete 00168 * the given classification object when necessary. This method 00169 * does nothing if \c NULL is passed in. 00170 * 00171 * @see DataDescriptor::setClassification(), Classification 00172 */ 00173 virtual void setClassification(const Classification* pClassification) = 0; 00174 00175 /** 00176 * Copies the classification settings from a DataElement. 00177 * 00178 * This is a convenience method that deep copies the Classification object that is stored 00179 * in the DataDescriptor object of another DataElement into the DataDescriptor object of 00180 * this DataElement. The existing classification settings for this DataElement are replaced 00181 * by the settings from the passed DataElement. No attempt is made to merge the settings. 00182 * 00183 * @param pElement 00184 * The DataElement from which the Classification object will be copied. 00185 * 00186 * @see DataDescriptor::getClassification(), DataDescriptor::setClassification(), Classification 00187 */ 00188 virtual void copyClassification(const DataElement* pElement) = 0; 00189 00190 /** 00191 * Returns a pointer to the element's metadata values. 00192 * 00193 * This is a convenience method that returns the metadata object that is stored in the 00194 * DataDescriptor object. 00195 * 00196 * Please see \ref specialmetadata for details on 00197 * special entries in the metadata that the application will 00198 * attempt to use. 00199 * 00200 * @return A pointer to the element's metadata as a DynamicObject. 00201 * 00202 * @see DataDescriptor::getMetadata(), DynamicObject 00203 */ 00204 virtual DynamicObject* getMetadata() = 0; 00205 00206 /** 00207 * Returns read-only access to the element's metadata values. 00208 * 00209 * This is a convenience method that returns the metadata object that is 00210 * stored in the DataDescriptor object. 00211 * 00212 * Please see \ref specialmetadata for details on 00213 * special entries in the metadata that the application will 00214 * attempt to use. 00215 * 00216 * @return A const pointer to the element's metadata as a DynamicObject. 00217 * The metadata represented by the returned pointer should not be 00218 * modified. To modify the values, call the non-const version of 00219 * getMetadata(). 00220 * 00221 * @see DataDescriptor::getMetadata(), DynamicObject 00222 */ 00223 virtual const DynamicObject* getMetadata() const = 0; 00224 00225 /** 00226 * Creates a new data element with the same values as this element. 00227 * 00228 * The method creates a new element based on the data contained in this 00229 * element, which includes a copy of all data in the data descriptor. 00230 * 00231 * @param name 00232 * The name for the created data element, which can be the same 00233 * as this object's name if the parent is different than this 00234 * object's parent. 00235 * @param pParent 00236 * The parent element for the created data element, which can be 00237 * the same as this object's parent if the name is different 00238 * than this object's name. 00239 * 00240 * @return A pointer to the new data element. \b NULL is returned if 00241 * the element cannot be copied or if the given parent is the 00242 * same as this object's parent. 00243 */ 00244 virtual DataElement* copy(const std::string& name, DataElement* pParent) const = 0; 00245 00246 protected: 00247 /** 00248 * This should be destroyed by calling ModelServices::destroyElement. 00249 */ 00250 virtual ~DataElement() {} 00251 }; 00252 00253 #endif