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 FILEDESCRIPTOR_H 00011 #define FILEDESCRIPTOR_H 00012 00013 #include "Filename.h" 00014 #include "TypeAwareObject.h" 00015 #include "Serializable.h" 00016 #include "Subject.h" 00017 #include "TypesFile.h" 00018 00019 #include <string> 00020 00021 class Message; 00022 00023 /** 00024 * Describes how a data element is stored in a file on disk. 00025 * 00026 * A file descriptor contains data that describes how a data element is stored 00027 * on-disk, including the filename. There are two primary uses for a file 00028 * descriptor: 00029 * - On import, a file descriptor is used to indicate how the imported data is 00030 * stored in the file on disk. It is typically set into a data descriptor 00031 * by an importer. 00032 * - On export, a file descriptor is used to indicate how the exported data 00033 * should be saved to disk. This file descriptor is separate from a 00034 * potentially imported file descriptor and does not have a parent data 00035 * descriptor. It can be created by any object that will perform the 00036 * export. 00037 * 00038 * If a DataElement is created by an algorithm and was not imported from a 00039 * file, the element's data descriptor will have a \b NULL file descriptor. 00040 * 00041 * @see DataElement, DataDescriptor, 00042 * DataDescriptor::setFileDescriptor() 00043 * 00044 * This subclass of Subject will notify upon the following conditions: 00045 * - The following methods are called: setFilename(), setDatasetLocation(), 00046 * setEndian(), and clone(). 00047 * - Everything else documented in Subject. 00048 */ 00049 class FileDescriptor : public Subject, public Serializable 00050 { 00051 public: 00052 /** 00053 * Emitted when the filename changes with 00054 * boost::any<\link Filename\endlink*> containing a pointer to the new 00055 * filename. 00056 * 00057 * @see setFilename() 00058 */ 00059 SIGNAL_METHOD(FileDescriptor, FilenameChanged) 00060 00061 /** 00062 * Emitted when the data set location changes with boost::any<std::string> 00063 * containing the new data set location. 00064 * 00065 * @see setDatasetLocation() 00066 */ 00067 SIGNAL_METHOD(FileDescriptor, DatasetLocationChanged) 00068 00069 /** 00070 * Emitted when the endian changes with 00071 * boost::any<\link ::EndianType EndianType\endlink> containing the new 00072 * endian value. 00073 * 00074 * @see setEndian() 00075 */ 00076 SIGNAL_METHOD(FileDescriptor, EndianChanged) 00077 00078 /** 00079 * Sets the location on disk for the file data. 00080 * 00081 * @param filename 00082 * The location on disk of the file data. 00083 * 00084 * @notify This method notifies signalFilenameChanged() when the filename 00085 * is successfully changed. 00086 * 00087 * @see setFilename(const Filename&) 00088 */ 00089 virtual void setFilename(const std::string& filename) = 0; 00090 00091 /** 00092 * Sets the location on disk for the file data. 00093 * 00094 * @param filename 00095 * The Filename object containing the location on disk of the file 00096 * data. 00097 * 00098 * @notify This method notifies signalFilenameChanged() when the filename 00099 * is successfully changed. 00100 * 00101 * @see setFilename(const std::string&) 00102 */ 00103 virtual void setFilename(const Filename& filename) = 0; 00104 00105 /** 00106 * Returns the location on disk for the file data. 00107 * 00108 * @return The Filename object containing the location on disk of the file 00109 * data. 00110 */ 00111 virtual const Filename& getFilename() const = 0; 00112 00113 /** 00114 * Sets the location of the data set within the file. 00115 * 00116 * The data set location is a string representation of where the data set 00117 * resides within the file returned by getFilename(). This is useful when 00118 * a single file contains multiple data sets. The default value is an 00119 * empty string. 00120 * 00121 * @param datasetLocation 00122 * The string representation of where the data set resides within 00123 * the file on disk. 00124 * 00125 * @notify This method notifies signalDatasetLocationChanged() when the 00126 * data set location is successfully changed. 00127 * 00128 * @see setFilename(const std::string&) 00129 */ 00130 virtual void setDatasetLocation(const std::string& datasetLocation) = 0; 00131 00132 /** 00133 * Returns the location of the data set within the file. 00134 * 00135 * @return The string representation of where the data set resides within 00136 * the file on disk. An empty string is returned if a location 00137 * has not been set, which may indicate that the file only 00138 * contains one data set. 00139 */ 00140 virtual const std::string& getDatasetLocation() const = 0; 00141 00142 /** 00143 * Sets the endian format of the data on disk. 00144 * 00145 * This method sets the endian format of how the data is stored on disk. 00146 * An importer uses this value to determine whether to swap bytes when 00147 * importing the data. 00148 * 00149 * @param endian 00150 * The endian format of the data on disk. 00151 * 00152 * @notify This method notifies signalEndianChanged() when the endian value 00153 * is successfully changed. 00154 */ 00155 virtual void setEndian(EndianType endian) = 0; 00156 00157 /** 00158 * Returns the endian format of the data on disk. 00159 * 00160 * @return The endian format of the data on disk. 00161 */ 00162 virtual EndianType getEndian() const = 0; 00163 00164 /** 00165 * Creates a new file descriptor based on this file descriptor. 00166 * 00167 * This method creates a new file descriptor and sets the values of the 00168 * created descriptor to this object's values. 00169 * 00170 * @return The new file descriptor containing values identical to the 00171 * values in this file descriptor. 00172 * 00173 * @see clone() 00174 */ 00175 virtual FileDescriptor* copy() const = 0; 00176 00177 /** 00178 * Sets all values in this file descriptor to those of another file 00179 * descriptor. 00180 * 00181 * @param pFileDescriptor 00182 * The file descriptor from which to set all data values in this 00183 * file descriptor. No signal/slot attachments currently defined 00184 * in \em pFileDescriptor are set into this descriptor. This 00185 * method does nothing and returns \c false if \c NULL is passed 00186 * in. 00187 * 00188 * @return Returns \c true if all values in this file descriptor were 00189 * successfully set to the values in the given file descriptor; 00190 * otherwise returns \c false. 00191 * 00192 * @notify This method notifies one or more signals defined in this class 00193 * or its subclasses based on data values that are actually 00194 * changed. 00195 * 00196 * @see copy() 00197 */ 00198 virtual bool clone(const FileDescriptor* pFileDescriptor) = 0; 00199 00200 /** 00201 * Adds the current values in this file descriptor to a given message. 00202 * 00203 * This convenience method adds the values in this file descriptor as 00204 * properties to the given message in a message log. 00205 * 00206 * @param pMessage 00207 * The message in the message log for which to add this file 00208 * descriptor's values. 00209 */ 00210 virtual void addToMessageLog(Message* pMessage) const = 0; 00211 00212 protected: 00213 /** 00214 * This should be destroyed by calling ObjectFactory::destroyObject. 00215 */ 00216 virtual ~FileDescriptor() {} 00217 }; 00218 00219 #endif