QGpCoreWave/ModalFactory.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of QGpCoreWave.
00004 **
00005 **  This library is free software; you can redistribute it and/or
00006 **  modify it under the terms of the GNU Lesser General Public
00007 **  License as published by the Free Software Foundation; either
00008 **  version 2.1 of the License, or (at your option) any later version.
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 Lesser General Public
00013 **  License for more details.
00014 **
00015 **  You should have received a copy of the GNU Lesser General Public
00016 **  License along with this library; if not, write to the Free Software
00017 **  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00018 **
00019 **  See http://www.geopsy.org for more information.
00020 **
00021 **  Created : 2006-09-26
00022 **  Authors :
00023 **    Marc Wathelet
00024 **    Marc Wathelet (LGIT, Grenoble, France)
00025 **
00026 ***************************************************************************/
00027 
00028 #ifndef MODALFACTORY_H
00029 #define MODALFACTORY_H
00030 
00031 #include <QGpCoreTools.h>
00032 
00033 #include "QGpCoreWaveDLLExport.h"
00034 
00035 namespace QGpCoreWave {
00036 
00037 class ModalStorage;
00038 class ModalCurve;
00039 class Mode;
00040 
00041 class QGPCOREWAVE_EXPORT ModalFactory
00042 {
00043   TRANSLATIONS("ModalFactory");
00044 public:
00045   ModalFactory() {}
00046   virtual ~ModalFactory() {}
00047 
00048   void setX (ModalFactory& f);
00049   void setX (const QList<ModalCurve>& curves);
00050   void linkX (QList<ModalCurve>& curves) const;
00051   void setModes (const QList<ModalCurve>& curves);
00052 
00053   void setX (const ModalCurve& c);
00054   void linkX (ModalCurve& c) const;
00055   void setModes (const ModalCurve& c);
00056   void setAngularFrequency();
00057 
00058   virtual void setMode (const Mode& m)=0;
00059   virtual const RealValue * mode(const Mode& m) const=0;
00060   virtual int storageCount() const=0;
00061   virtual void writeReportHeader(QDataStream& ) const {}
00062   virtual ModalStorage * storage(int storageIndex) const=0;
00063 
00064   const QVector<double> * x() const {return &_x;}
00065 protected:
00066   virtual ModalStorage * newStorage(int nModes)=0;
00067   template <class StorageType> void upgrade (StorageType *& s, int requestedMode);
00068 
00069   QVector<double> _x;
00070 };
00071 
00072 template <class StorageType>
00073 void ModalFactory::upgrade (StorageType *& s, int requestedMode)
00074 {
00075   TRACE;
00076   if( !s || requestedMode >= s->modeCount()) {
00077     StorageType * tmp_s=static_cast<StorageType *>(newStorage(requestedMode + 1));
00078     delete s;
00079     s=tmp_s;
00080   }
00081 }
00082 
00083 } // namespace QGpCoreWave
00084 
00085 #endif // MODALFACTORY_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines