SignatureLibrary.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 SIGNATURE_LIBRARY_H
00011 #define SIGNATURE_LIBRARY_H
00012 
00013 #include "SignatureSet.h"
00014 
00015 #include <map>
00016 #include <set>
00017 #include <string>
00018 #include <vector>
00019 
00020 class Progress;
00021 class RasterElement;
00022 
00023 /**
00024  *  A container for multiple signatures.
00025  *
00026  *  This class provides encapsulation for multiple signatures into a single object.  The
00027  *  SignatureLibrary is also a SignatureSet, so it can contain metadata, a description,
00028  *  and acquisition values.  The Signature Library's set of Signatures is largely immutable, 
00029  *  in that, except for an empty library, new signatures cannot be added to it, and, 
00030  *  for the most part, signatures cannot be removed from it.
00031  *
00032  *  When a SignatureLibrary is deleted, Signatures contained in the set are automatically
00033  *  deleted. It owns its signatures.
00034  *
00035  *  The primary benefit of a SignatureLibrary over a standard SignatureSet is that the
00036  *  SignatureLibrary can store much larger collections of signatures and can more 
00037  *  efficiently and conveniently resample them. Additionally, a SignatureLibrary
00038  *  provides faster, more convenient access to its primary ordinate data.
00039  *
00040  *  This subclass of Subject will notify upon the following conditions:
00041  *  - The following methods are called: 
00042  *    resample(), desample(), import(), insertSignature(), insertSignatures(), clear().
00043  *  - Everything else documented in SignatureSet.
00044  *
00045  *  @see        SignatureSet
00046  */
00047 class SignatureLibrary : public SignatureSet
00048 {
00049 public:
00050    /**
00051     *  Returns the values that the signature ordinate data is currently sampled
00052     *  to.
00053     *
00054     *  Returns the values that the signature ordinate data is currently sampled
00055     *  to. If the library has not been resampled, this will return getOriginalAbscissa().
00056     *
00057     *  @return  The active abscissa of the library.
00058     *
00059     *  @see getOriginalAbscissa()
00060     */
00061    virtual const std::vector<double>& getAbscissa() const = 0;
00062 
00063    /**
00064     *  Returns the values that the raw signature library ordinate data is 
00065     *  sampled to.
00066     *
00067     *  @return  The original abscissa of the library.
00068     */
00069    virtual const std::vector<double>& getOriginalAbscissa() const = 0;
00070 
00071    /**
00072     *  Returns the raw ordinate data.
00073     *
00074     *  The raw ordinate data is returned as an on-disk RasterElement.
00075     *
00076     *  @return  The raw ordinate data.
00077     */
00078    virtual const RasterElement *getOriginalOrdinateData() const = 0;
00079 
00080    /**
00081     *  Returns the raw ordinate data.
00082     *
00083     *  The raw ordinate data is returned as an on-disk RasterElement.
00084     *
00085     *  @return  The raw ordinate data.
00086     */
00087    virtual RasterElement *getOriginalOrdinateData() = 0;
00088 
00089    /**
00090     *  Returns the resampled ordinate data.
00091     *
00092     *  The resampled ordinate data is returned as a single array of doubles
00093     *  with each signature's ordinate data being contiguous. The number of 
00094     *  ordinate samples for each signature will be the same as the number of
00095     *  abscissa values returned from getAbscissa(). If the library has not been
00096     *  resampled, this returns \c NULL.
00097     *
00098     *  @return  The entire resampled signature library's ordinate data.
00099     */
00100    virtual const double *getOrdinateData() const = 0;
00101 
00102    /**
00103     *  Returns the resampled ordinate data of a specified signature.
00104     *
00105     *  The resampled ordinate data is returned as a single array of doubles. 
00106     *  The number of ordinate samples for the signature will be the same as the
00107     *  number of abscissa values returned from getAbscissa(). If the library 
00108     *  has not been resampled, this returns \c NULL.
00109     *
00110     *  @param   index
00111     *           The index of the signature for which the ordinate data is to be
00112     *           retrieved.
00113     *
00114     *  @return  The signature's resampled ordinate data, or \c NULL of the library
00115     *         has not been resampled or the index is invalid.
00116     */
00117    virtual const double *getOrdinateData(unsigned int index) const = 0;
00118 
00119    /**
00120     *  Returns the names of all of the signatures in the library.
00121     *
00122     *  @return  The names of all of the signatures in the library.
00123     */
00124    virtual std::set<std::string> getSignatureNames() const = 0;
00125 
00126    /**
00127     *  Returns the name of the specified signature.
00128     *
00129     *  @param   index
00130     *           The index of the signature for which the name is to be 
00131     *           retrieved.
00132     *
00133     *  @return  The name of the specified signature or an empty string if the
00134     *           index is invalid.
00135     */
00136    virtual std::string getSignatureName(unsigned int index) const = 0;
00137 
00138    /**
00139     *  Returns the specified signature.
00140     *
00141     *  @param   index
00142     *           The index of the signature to be retrieved.
00143     *
00144     *  @return  The specified signature, or \c NULL if the index is invalid.
00145     */
00146    virtual const Signature *getSignature(unsigned int index) const = 0;
00147 
00148    /**
00149     *  Returns the specified signature.
00150     *
00151     *  @param   name
00152     *           The name of the signature to be retrieved.
00153     *
00154     *  @return  The specified signature or \c NULL if the specified signature does
00155     *           not exist in the library.
00156     */
00157    virtual const Signature* getSignature(const std::string& name) const = 0;
00158 
00159    /**
00160     *  Returns the name of the library's abscissa.
00161     *
00162     *  @return  The abscissa name.
00163     */
00164    const std::string& getAbscissaName() const;
00165 
00166    /**
00167     *  Resamples the raw ordinate data to the specified abscissa.
00168     *
00169     *  Resamples the entire raw ordinate data set to the specified abscissa.
00170     *  After calling this, the getOrdinateData() methods will return non-\c NULL
00171     *  pointers to the resampled ordinate data. If the range of the abscissa
00172     *  is greater than the range of the original abscissa, or if the resampling
00173     *  fails for any other reason, this method will fail and will leave the
00174     *  ordinate data unsampled.
00175     *
00176     *  @param   abscissa
00177     *           The abscissa values to resample the ordinate data to. If this 
00178     *           is empty, the ordinate data will not be resampled and 
00179     *           getOrdinateData() will return \c NULL.
00180     *
00181     *  @return  \c True if resampling was successful, or \c false otherwise.
00182     *
00183     *  @notify  This method will notify Subject::signalModified.
00184     */
00185    virtual bool resample(const std::vector<double> &abscissa) = 0;
00186 
00187    /**
00188     *  Frees up all resources associated with resampling the library.
00189     *
00190     *  Frees up all resources associated with resampling the library. The 
00191     *  library is restored to the state it was in immediately after being
00192     *  imported, but before being resampled.
00193     *
00194     *  @notify  This method will notify Subject::signalModified.
00195     */
00196    virtual void desample() = 0;
00197 
00198    /**
00199     *  Imports a new signature library file into the library object.
00200     *
00201     *  This method clears the SignatureLibrary and then imports a new library
00202     *  file into it. The library will be imported as an on-disk RasterElement
00203     *  and will be available via getOriginalOrdinateData().
00204     *
00205     *  @param   filename
00206     *           The full pathname of the file to import.
00207     *  @param   importerName
00208     *           The name of the importer to use to import the library as an
00209     *           on-disk RasterElement.
00210     *  @param   pProgress
00211     *           The progress object to pass into the importer.  If \c NULL is
00212     *           passed in, a progress object is obtained by calling
00213     *           PlugInManagerServices::getProgress().
00214     *
00215     *  @return  \c True if the import succeeded and \c false otherwise.
00216     *
00217     *  @notify  This method will notify Subject::signalModified.
00218     *
00219     *  @see     clear(), getOriginalOrdinateData()
00220     */
00221    virtual bool import(const std::string& filename, const std::string& importerName, Progress* pProgress = NULL) = 0;
00222 
00223    /**
00224     *  Adds an existing signature into the library. 
00225     *
00226     *  Adds an existing signature into an empty library. If the library is not
00227     *  empty, this method will fail.
00228     *
00229     *  @param   pSignature
00230     *           The signature to add to the library.
00231     *
00232     *  @return  \c True if the signature was successfully added to the library, otherwise \c false.
00233     *
00234     *  @notify  This method will notify Subject::signalModified.
00235     */
00236    virtual bool insertSignature(Signature* pSignature) = 0;
00237 
00238    /**
00239     *  Adds several signatures to the library. 
00240     *
00241     *  Adds several signatures into any empty library. The signatures must be 
00242     *  unique. If any of the sigs to add are \c NULL, the method will fail,
00243     *  having done nothing. If the library is not empty, this method will fail.
00244     *
00245     *  @param   signatures
00246     *           A vector of signatures to add to the library
00247     *
00248     *  @return  \c true if the signatures were added, otherwise \c false.
00249     *
00250     *  @notify  This method will notify Subject::signalModified after the 
00251     *           sigs are done being added to the list. Only one notification 
00252     *           will be done. No notification will be done if signatures is empty.
00253     */
00254    virtual bool insertSignatures(const std::vector<Signature*>& signatures) = 0;
00255 
00256    /**
00257     *  Removes a signature from the library.
00258     *
00259     *  Removes a signature from the library. This will only succeed if the 
00260     *  signature is the only signature in the library.
00261     *
00262     *  @param   pSignature
00263     *           The signature to remove from the library.
00264     *
00265     *  @param   bDelete
00266     *           This value is ignored. If the method succeeds, the signatures
00267     *           will be deleted.
00268     *
00269     *  @return  \c True if the signature successfully removed from the library, otherwise
00270     *           \c false.  \c False is also returned if the given signature does not exist
00271     *           in the library.
00272     *
00273     *  @notify  This method will notify Subject::signalModified.
00274     */
00275    virtual bool removeSignature(Signature* pSignature, bool bDelete = false) = 0;
00276 
00277    /**
00278     *  Removes several signatures from the library.
00279     *
00280     *  This method removes several sigs from the library. The list must contain
00281     *  all of the sigs in the library or the method will fail. If the list of 
00282     *  sigs to remove contains sigs not in the library, those sigs will be 
00283     *  ignored.
00284     *
00285     *  @param   signatures
00286     *           A vector of sigs to remove from the library
00287     *
00288     *  @param   bDelete
00289     *           This value is ignored. If the method succeeds, the signatures
00290     *           will be deleted.
00291     *
00292     *  @return  Returns \c true if the list of signatures to remove was not
00293     *           empty and all of the specified signatures were found in the
00294     *           set; otherwise returns \c false.
00295     *
00296     *  @notify  This method will notify Subject::signalModified after the 
00297     *           signatures are done being removed from the list. Only one 
00298     *           notification will be done.
00299     */
00300    virtual bool removeSignatures(const std::vector<Signature*>& signatures, bool bDelete = false) = 0;
00301 
00302    /**
00303     *  Removes all of the signatures from the library.
00304     *
00305     *  This method removes all of the signatures from the library. The 
00306     *  signatures will be deleted in the process.
00307     *
00308     *  @param   bDelete
00309     *           This value is ignored. The signatures will be deleted.
00310     *
00311     *  @notify  This method will notify Subject::signalModified after the signatures are
00312     *           done being removed from the library if the library was not empty.
00313     *           At most one notification will be done.
00314     */
00315    virtual void clear(bool bDelete = false) = 0;
00316 
00317 protected:
00318    /**
00319     * This should be destroyed by calling ModelServices::destroyElement.
00320     */
00321    virtual ~SignatureLibrary() {}
00322 };
00323 
00324 #endif

Software Development Kit - Opticks 4.9.0 Build 16218