ObjectProducer.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2004 CSIRO ICT Centre
00003  *
00004  * $Id: ObjectProducer.h 587 2004-12-03 15:06:33Z nch $
00005  */
00006 
00007 /*
00008  * A producer of objects. This class uses an ObjectReader
00009  * to create objects uing the hasNext and next methods.
00010  *
00011  * The different constructors are needed for the cases
00012  * where the max SD's are known for the source, when
00013  * they should be read from the source sequentially
00014  * (and the source reopenmed afterwards), or if they are
00015  * not needed.
00016  *
00017  * This class should not be subclassed. Different sources
00018  * are accomodated through the use of different ObjectReaders.
00019  *
00020  * The ObjectReader is "owned" by this class and will be 
00021  * deleted by the destructor.
00022  */
00023 
00024 #ifndef OBJECTPRODUCER_DEFINED
00025 #define OBJECTPRODUCER_DEFINED
00026 
00027 class Object;
00028 class ObjectReader;
00029 
00030 
00031 class ObjectProducer
00032 {
00033   public:
00034     /* Use this constructor when the maximum standard
00035      * deviations in declination and orthogonal to
00036      * declination are not known. If the setMaxSDs flag
00037      * is true, this ObjectProducer will scan the file 
00038      * for maximum standard devation values.
00039      */
00040     ObjectProducer(ObjectReader * reader,
00041                    bool setMaxSDs = false);
00042 
00043     /* Used when only one max SD is needed. */
00044     ObjectProducer(ObjectReader * reader,
00045                    double maxSD);
00046 
00047     /* Used when two max SD values are needed */
00048     ObjectProducer(ObjectReader * reader,
00049                    double maxOrthoSD,
00050                    double maxDecSD);
00051     
00052     ~ObjectProducer();
00053     bool hasNext() const;
00054     Object * next() const;
00055 
00056     double getMaxDecSD()   const { return maxDecSD; };
00057     double getMaxOrthoSD() const { return maxOrthoSD; };
00058     double getMaxSD()      const
00059     {
00060       return (getMaxDecSD() > getMaxOrthoSD()) ? getMaxDecSD() : getMaxOrthoSD();
00061     }
00062 
00063   private:
00064     ObjectReader *   reader;
00065     mutable Object * current;
00066     mutable bool     hasMore;
00067     mutable bool     isCurrent;
00068     mutable double   maxOrthoSD;
00069     mutable double   maxDecSD;
00070 
00071     ObjectProducer();
00072     ObjectProducer(ObjectProducer const &);
00073     ObjectProducer & operator=(ObjectProducer const &);
00074 
00075     void scanForMaxSDs() const;
00076 };
00077 
00078 #endif // ifndef OBJECTPRODUCER_DEFINED
Generated on Mon Oct 4 10:39:55 2010 for Matching.kdevelop by  doxygen 1.6.3