DimensionDescriptor.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 DIMENSIONDESCRIPTOR_H
00011 #define DIMENSIONDESCRIPTOR_H
00012 
00013 #include "AppConfig.h"
00014 #include <string>
00015 
00016 /**
00017  *  Index infomation for a row, column, or band within a data set.
00018  *
00019  *  This class is used to maintain information specific for a particular row,
00020  *  column, or band within a data set.  There will be one instance of this
00021  *  class for each row, column, and band in the data set.
00022  *
00023  *  The object contains three identifying numbers: original, on-disk, and
00024  *  active as described below.  Each number will have a valid or invalid state
00025  *  that indicates whether the get methods should be called.
00026  *
00027  *  <b>Original Number</b><br>
00028  *  The original number represents the row, column, or band number that
00029  *  pertains to the original raw data from the sensor.  This value is set by an
00030  *  importer inside of Importer::getImportDescriptors() or by an object that
00031  *  creates a data set as a result of running an algorithm.  All instances of
00032  *  this object should have a valid original number.
00033  *
00034  *  <b>On-Disk Number</b><br>
00035  *  The on-disk number represents the row, column, or band number as it
00036  *  corresponds to the total number of rows, columns, or bands in a file on
00037  *  disk.  This value is set by an importer inside of
00038  *  Importer::getImportDescriptors().  If the data set for this row, column, or
00039  *  band was created by an object as a result of running an algorithm or
00040  *  otherwise not originally imported from a file, the on-disk number will be
00041  *  invalid.  Each row, column, and band object inside a
00042  *  RasterFileDescriptor should have a valid on-disk number.
00043  *
00044  *  <b>Active Number</b><br>
00045  *  The active number represents the row, column, or band number that is
00046  *  available for processing.  This value is set by the core application just
00047  *  before an importer is executed and after the user has specified an optional
00048  *  subset, or by an object that creates a data set as a result of running an
00049  *  algorithm.  If a subset of a data set has been imported, the active number
00050  *  will be valid only for the rows, columns, and bands that have been
00051  *  imported.  In this case, all rows, columns, and bands in the
00052  *  RasterDataDescriptor will have valid active numbers, and only those rows, 
00053  *  columns, and bands that were imported will have valid active numbers in the 
00054  *  RasterFileDescriptor.
00055  *
00056  *  @see   DataDescriptor, FileDescriptor
00057  */
00058 class DimensionDescriptor
00059 {
00060 public:
00061    /**
00062     * Constructs a DimensionDescriptor that is invalid until one of the set methods
00063     * is called.
00064     */
00065    DimensionDescriptor() :
00066       mOriginalNumber(0),
00067       mOnDiskNumber(0),
00068       mActiveNumber(0),
00069       mOriginalValid(false),
00070       mOnDiskValid(false),
00071       mActiveValid(false)
00072    {
00073    }
00074 
00075    /**
00076     * Assignment operator for DimensionDescriptor.
00077     *
00078     * @param descriptor the right hand side of the assignment.
00079     *
00080     * @return this object.
00081     */
00082    BROKEN_INLINE_HINT DimensionDescriptor& operator =(const DimensionDescriptor& descriptor)
00083    {
00084       if (this != &descriptor)
00085       {
00086          mOriginalNumber = descriptor.mOriginalNumber;
00087          mOnDiskNumber = descriptor.mOnDiskNumber;
00088          mActiveNumber = descriptor.mActiveNumber;
00089          mOriginalValid = descriptor.mOriginalValid;
00090          mOnDiskValid = descriptor.mOnDiskValid;
00091          mActiveValid = descriptor.mActiveValid;
00092       }
00093 
00094       return *this;
00095    }
00096 
00097    /**
00098     * Inequality operator for DimensionDescriptor.
00099     *
00100     * @param dd the object being compared to.
00101     *
00102     * @return True, if any of the original, on-disk, or
00103     *         active numbers are not equal. False, otherwise.
00104     */
00105    bool operator!=(const DimensionDescriptor& dd) const
00106    {
00107       return !(*this == dd);
00108    }
00109 
00110    /**
00111     * Equality operator for DimensionDescriptor.
00112     *
00113     * @param dd the object being compared to.
00114     *
00115     * @return True, if all of the original, on-disk, or
00116     *         active numbers are equal. False, otherwise.
00117     */
00118    bool operator==(const DimensionDescriptor& dd) const
00119    {
00120       if (mOriginalValid != dd.mOriginalValid || mOnDiskValid != dd.mOnDiskValid || mActiveValid != dd.mActiveValid)
00121       {
00122          return false;
00123       }
00124 
00125       return ((!mOriginalValid || (mOriginalNumber == dd.mOriginalNumber)) && 
00126          (!mActiveValid || (mActiveNumber == dd.mActiveNumber)) &&
00127          (!mOnDiskValid || (mOnDiskNumber == dd.mOnDiskNumber)));
00128    }
00129 
00130    /**
00131     * Less than operator for DimensionDescriptor.
00132     * This method provides a guaranteed ordering of DimensionDescriptors.  This operator
00133     * should only be used to perform unique sorting of DimensionDescriptors, ie. the
00134     * kind required to use a DimensionDescriptor as a key of std::map.
00135     *
00136     * @param right
00137     *        the object being compared to.
00138     *
00139     * @return True, if this DimensionDescriptor is less than the right Dimension Descriptor.
00140     *         False, otherwise.
00141     */
00142    bool operator<(const DimensionDescriptor& right) const
00143    {
00144       if ((mOriginalValid == right.mOriginalValid) && (mOriginalNumber == right.mOriginalNumber))
00145       {
00146          if ((mOnDiskValid == right.mOnDiskValid) && (mOnDiskNumber == right.mOnDiskNumber))
00147          {
00148             if ((mActiveValid == right.mActiveValid) && (mActiveNumber == right.mActiveNumber))
00149             {
00150                return false;
00151             }
00152             else
00153             {
00154                if ((mActiveValid == true) && (right.mActiveValid == true))
00155                {
00156                   return mActiveNumber < right.mActiveNumber;
00157                }
00158                else
00159                {
00160                   return false;
00161                }
00162             }
00163          }
00164          else
00165          {
00166             if ((mOnDiskValid == true) && (right.mOnDiskValid == true))
00167             {
00168                return mOnDiskNumber < right.mOnDiskNumber;
00169             }
00170             else
00171             {
00172                return false;
00173             }
00174          }
00175       }
00176       else
00177       {
00178          if ((mOriginalValid == true) && (right.mOriginalValid == true))
00179          {
00180             return mOriginalNumber < right.mOriginalNumber;
00181          }
00182          else
00183          {
00184             return false;
00185          }
00186       }
00187    }
00188 
00189    /**
00190     * Greater than operator for DimensionDescriptor.
00191     * This method provides a guaranteed ordering of DimensionDescriptors.  This operator
00192     * should only be used to perform unique sorting of DimensionDescriptors, ie. the
00193     * kind required to use a DimensionDescriptor as a key of std::map.
00194     *
00195     * @param right
00196     *        the object being compared to.
00197     *
00198     * @return True, if this DimensionDescriptor is greater than the right Dimension Descriptor.
00199     *         False, otherwise.
00200     */
00201    bool operator>(const DimensionDescriptor& right) const
00202    {
00203       if ((mOriginalValid == right.mOriginalValid) && (mOriginalNumber == right.mOriginalNumber))
00204       {
00205          if ((mOnDiskValid == right.mOnDiskValid) && (mOnDiskNumber == right.mOnDiskNumber))
00206          {
00207             if ((mActiveValid == right.mActiveValid) && (mActiveNumber == right.mActiveNumber))
00208             {
00209                return false;
00210             }
00211             else
00212             {
00213                if ((mActiveValid == true) && (right.mActiveValid == true))
00214                {
00215                   return mActiveNumber > right.mActiveNumber;
00216                }
00217                else
00218                {
00219                   return false;
00220                }
00221             }
00222          }
00223          else
00224          {
00225             if ((mOnDiskValid == true) && (right.mOnDiskValid == true))
00226             {
00227                return mOnDiskNumber > right.mOnDiskNumber;
00228             }
00229             else
00230             {
00231                return false;
00232             }
00233          }
00234       }
00235       else
00236       {
00237          if ((mOriginalValid == true) && (right.mOriginalValid == true))
00238          {
00239             return mOriginalNumber > right.mOriginalNumber;
00240          }
00241          else
00242          {
00243             return false;
00244          }
00245       }
00246    }
00247 
00248    /**
00249     *  Sets the original number for the row, column, or band.
00250     *
00251     *  The original number indicates the initial index of the row, column, or
00252     *  band from the dataset generated by the sensor.
00253     *
00254     *  The original number is automatically made valid when this method is
00255     *  called, so there is no need to call setOriginalNumberValid().
00256     *
00257     *  @param   originalNumber
00258     *           The zero-based number of the row, column, or band in the
00259     *           original data set.
00260     */
00261    void setOriginalNumber(unsigned int originalNumber)
00262    {
00263       mOriginalNumber = originalNumber;
00264       mOriginalValid = true;
00265    }
00266 
00267    /**
00268     *  Returns the original number of the row, column, or band.
00269     *
00270     *  To ensure that the number returned is valid, call the
00271     *  isOriginalNumberValid() method before calling this method.
00272     *
00273     *  @return  The zero-based number of the row, column, or band in the
00274     *           original data set.
00275     */
00276    unsigned int getOriginalNumber() const
00277    {
00278       return mOriginalNumber;
00279    }
00280 
00281    /**
00282     *  Queries whether the original number of the row, column, or band is valid.
00283     *
00284     *  @return  Returns \b true if the original number has been set and is
00285     *           valid; otherwise returns \b false.
00286     */
00287    bool isOriginalNumberValid() const
00288    {
00289       return mOriginalValid;
00290    }
00291 
00292    /**
00293     *  Sets whether the original number of the row, column, or band is valid.
00294     *
00295     *  An invalid number is automatically made valid when setOriginalNumber()
00296     *  is called.  Therefore, this method is typically called to invalidate
00297     *  the original number.
00298     *
00299     *  @param   valid
00300     *           The new valid state of the original number.
00301     */
00302    void setOriginalNumberValid(bool valid)
00303    {
00304       mOriginalValid = valid;
00305    }
00306 
00307    /**
00308     *  Sets the on-disk number for the row, column, or band.
00309     *
00310     *  The on-disk number indicates the index of the row, column, or band as it
00311     *  is stored in the file on disk.  The current file may be reduced from the
00312     *  original sensor data file if a subset has been saved.
00313     *
00314     *  The on-disk number is automatically made valid when this method is
00315     *  called, so there is no need to call setOnDiskNumberValid().
00316     *
00317     *  @param   onDiskNumber
00318     *           The zero-based number of the row, column, or band in the file
00319     *           on disk.
00320     */
00321    void setOnDiskNumber(unsigned int onDiskNumber)
00322    {
00323       mOnDiskNumber = onDiskNumber;
00324       mOnDiskValid = true;
00325    }
00326 
00327     /**
00328     *  Returns the on-disk number of the row, column, or band.
00329     *
00330     *  To ensure that the number returned is valid, call the
00331     *  isOnDiskNumberValid() method before calling this method.
00332     *
00333     *  @return  The zero-based number of the row, column, or band as it is
00334     *           stored in the file on disk.
00335     */
00336    unsigned int getOnDiskNumber() const
00337    {
00338      return mOnDiskNumber;
00339    }
00340 
00341    /**
00342     *  Queries whether the on-disk number of the row, column, or band has
00343     *  been set.
00344     *
00345     *  @return  Returns \b true if the on-disk number has been set and is
00346     *           valid; otherwise returns \b false.
00347     */
00348    bool isOnDiskNumberValid() const
00349    {
00350       return mOnDiskValid;
00351    }
00352 
00353    /**
00354     *  Sets whether the on-disk number of the row, column, or band is valid.
00355     *
00356     *  An invalid number is automatically made valid when setOnDiskNumber()
00357     *  is called.  Therefore, this method is typically called to invalidate
00358     *  the on-disk number.
00359     *
00360     *  @param   valid
00361     *           The new valid state of the on-disk number.
00362     */
00363    void setOnDiskNumberValid(bool valid)
00364    {
00365       mOnDiskValid = valid;
00366    }
00367 
00368    /**
00369     *  Sets the active number for the row, column, or band.
00370     *
00371     *  The active number indicates the index of the row, column, or band as it
00372     *  has been imported.
00373     *
00374     *  The active number is automatically made valid when this method is
00375     *  called, so there is no need to call setActiveNumberValid().
00376     *
00377     *  @param   activeNumber
00378     *           The zero-based number of the row, column, or band as it has
00379     *           been imported.
00380     */
00381    void setActiveNumber(unsigned int activeNumber)
00382    {
00383       mActiveNumber = activeNumber;
00384       mActiveValid = true;
00385    }
00386 
00387     /**
00388     *  Returns the active number of the row, column, or band.
00389     *
00390     *  To ensure that the number returned is valid, call the
00391     *  isActiveNumberValid() method before calling this method.
00392     *
00393     *  @return  The zero-based number of the row, column, or band as it has
00394     *           been imported.
00395     */
00396    unsigned int getActiveNumber() const
00397    {
00398       return mActiveNumber;
00399    }
00400 
00401    /**
00402     *  Queries whether the active number of the row, column, or band has been
00403     *  set.
00404     *
00405     *  @return  Returns \b true if the active number has been set and is valid;
00406     *           otherwise returns \b false.
00407     */
00408    bool isActiveNumberValid() const
00409    {
00410       return mActiveValid;
00411    }
00412 
00413    /**
00414     *  Sets whether the active number of the row, column, or band is valid.
00415     *
00416     *  An invalid number is automatically made valid when setActiveNumber() is
00417     *  called.  Therefore, this method is typically called to invalidate the
00418     *  active number.
00419     *
00420     *  @param   valid
00421     *           The new valid state of the active number.
00422     */
00423    void setActiveNumberValid(bool valid)
00424    {
00425       mActiveValid = valid;
00426    }
00427 
00428    /**
00429     * Queries whether this DimensionDescriptor is valid or not.
00430     *
00431     * @return Returns \b true if the any number in the DimensionDescriptor is valid;
00432     *         otherwise returns \b false.
00433     */
00434    bool isValid() const
00435    {
00436       return mOriginalValid || mOnDiskValid || mActiveValid;
00437    }
00438 
00439 private:
00440    unsigned int mOriginalNumber;
00441    unsigned int mOnDiskNumber;
00442    unsigned int mActiveNumber;
00443 
00444    bool mOriginalValid;
00445    bool mOnDiskValid;
00446    bool mActiveValid;
00447 };
00448 
00449 #endif

Software Development Kit - Opticks 4.9.0 Build 16218