GeopsyCore/TimeRangeList.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of GeopsyCore.
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-12-11
00022 **  Authors :
00023 **    Marc Wathelet
00024 **    Marc Wathelet (LGIT, Grenoble, France)
00025 **
00026 ***************************************************************************/
00027 
00028 #ifndef TIMERANGELIST_H
00029 #define TIMERANGELIST_H
00030 
00031 #include <QGpCoreTools.h>
00032 #include "TimeRange.h"
00033 #include "GeopsyCoreDLLExport.h"
00034 
00035 namespace GeopsyCore {
00036 
00037 class WindowingParameters;
00038 class SparseKeepSignal;
00039 
00040 class GEOPSYCORE_EXPORT TimeRangeList: private QList<TimeRange *>
00041 {
00042   TRANSLATIONS("TimeRangeList")
00043 public:
00044   TimeRangeList() {}
00045   TimeRangeList(const TimeRangeList& o, int firstIndex);
00046   virtual ~TimeRangeList();
00047 
00048   void add(double frequency, const WindowingParameters& param, const SparseKeepSignal& keep, const TimeRange& r, QString * log);
00049   void addBlanks(double frequency, const WindowingParameters& param, const SparseKeepSignal& keep, const TimeRange& r, QString * log);
00050   inline TimeRange& addOne(const TimeRange& r);
00051   inline TimeRange& addOne();
00052   void add(QTextStream& s, QString * log);
00053   void add(const TimeRangeList& list);
00054   void remove(const TimeRange& r, QString * log);
00055   void remove(int index, QString * log);
00056   void inverse(double frequency, const WindowingParameters& param, const SparseKeepSignal& keep, const TimeRange& r, QString * log);
00057   QString toString() const;
00058   bool clear();
00059   int count() const {return QList<TimeRange *>::count();}
00060   bool isEmpty() const {return QList<TimeRange *>::isEmpty();}
00061 
00062   typedef QList<TimeRange *>::iterator iterator;
00063   typedef QList<TimeRange *>::const_iterator const_iterator;
00064   iterator begin() {return QList<TimeRange *>::begin();}
00065   iterator end() {return QList<TimeRange *>::end();}
00066   const_iterator begin() const {return QList<TimeRange *>::begin();}
00067   const_iterator end() const {return QList<TimeRange *>::end();}
00068 
00069   const TimeRange& at(int index) const {return *QList<TimeRange *>::at(index);}
00070   TimeRange& at(int index) {return *QList<TimeRange *>::operator[](index);}
00071 
00072   // Query information on list
00073   double longestWindow() const;
00074   TimeRange timeRange() const;
00075 protected:
00076   virtual TimeRange * newTimeRange(double start, double end) {return new TimeRange(start, end);}
00077   virtual TimeRange * cloneTimeRange(TimeRange * r) {return new TimeRange(*r);}
00078   virtual void deleteTimeRange(TimeRange * r) {delete r;}
00079   void internalClear() {QList<TimeRange *>::clear();}
00080 private:
00081   void blanksToKeep(SparseKeepSignal& keep, double overlap) const;
00082 };
00083 
00084 inline TimeRange& TimeRangeList::addOne(const TimeRange& r)
00085 {
00086   TimeRange * rr=newTimeRange(r.start(), r.end());
00087   append(rr);
00088   return *rr;
00089 }
00090 
00091 inline TimeRange& TimeRangeList::addOne()
00092 {
00093   TimeRange * r=newTimeRange(0.0, 0.0);
00094   append(r);
00095   return *r;
00096 }
00097 
00098 } // namespace GeopsyCore
00099 
00100 #endif // TIMERANGELIST_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines