geopsyarray/SPACLoop.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of geopsyarray.
00004 **
00005 **  This file may be distributed and/or modified under the terms of the
00006 **  GNU General Public License version 2 or 3 as published by the Free
00007 **  Software Foundation and appearing in the file LICENSE.GPL included
00008 **  in the packaging of this file.
00009 **
00010 **  This file is distributed in the hope that it will be useful, but WITHOUT
00011 **  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 **  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
00013 **  more details.
00014 **
00015 **  You should have received a copy of the GNU General Public License
00016 **  along with this program. If not, see <http://www.gnu.org/licenses/>.
00017 **
00018 **  See http://www.geopsy.org for more information.
00019 **
00020 **  Created : 2008-03-03
00021 **  Authors:
00022 **    Marc Wathelet
00023 **    Marc Wathelet (LGIT, Grenoble, France)
00024 **
00025 ***************************************************************************/
00026 
00027 #ifndef SPACLOOP_H
00028 #define SPACLOOP_H
00029 
00030 #include <ArrayCore.h>
00031 
00032 class SPACLoop : public ParallelLoop
00033 {
00034 public:
00035   SPACLoop();
00036   ~SPACLoop();
00037 
00038   void setArray(const ArrayStations * a);
00039   void setLog(QString * l) {_log=l;}
00040   bool setParameters(SPACParameters * p);
00041 
00042   const RingCouples& ring(int index) const {return _param->ring(index);}
00043   const ArrayStations * array() const {return _array;}
00044 
00045   QFile * outputMax() const {return _dotmax;}
00046   void lockOutputMax() const {_outputMutex[3].lock();}
00047   void unlockOutputMax() const {_outputMutex[3].unlock();}
00048 
00049   QFile * outputStmap(int iComp) const {return _dotstmaps[iComp];}
00050   void lockOutputStmap(int iComp) const {_outputMutex[iComp].lock();}
00051   void unlockOutputStmap(int iComp) const {_outputMutex[iComp].unlock();}
00052 
00053   AutocorrCurves * target() const {return _target;}
00054 
00055   void addLog(const QString& s) const;
00056 protected:
00057   virtual LoopTask * newTask();
00058 
00059   const ArrayStations * _array;
00060   const SPACParameters * _param;
00061 private:
00062   void setTarget();
00063   void setStmap();
00064   void setMax();
00065 
00066   mutable QMutex _outputMutex[4];
00067   AutocorrCurves * _target;
00068   QFile * _dotstmaps[3];
00069   QFile * _dotmax;
00070   mutable QMutex _logMutex;
00071   QString * _log;
00072 };
00073 
00074 class SPACLoopTask : public LoopTask
00075 {
00076 public:
00077   SPACLoopTask();
00078   ~SPACLoopTask();
00079 
00080   virtual void setArray(const ArrayStations& array);
00081   void setParameters(const SPACParameters * param);
00082   void setLoop(const SPACLoop * l) {_loop=l;}
00083 protected:
00084   virtual void run(int index);
00085 private:
00086   inline void writeMax(int iComp, int iRing, double value);
00087   void resetStatistics();
00088 
00089   const SPACLoop * _loop;
00090   SPACArrayProcess * _process;
00091   QVector<RingCouplesProcess> _rings;
00092   const TimeRange * _win;
00093   int _nRings, _nComp;
00094   double ** _sum, ** _sum2;
00095 };
00096 
00097 #endif // SPACLOOP_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines