pointage/RecordList.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of pointage.
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: 2013-01-17
00021 **  Authors:
00022 **    Marc Wathelet (ISTerre, Grenoble, France)
00023 **
00024 ***************************************************************************/
00025 
00026 #ifndef RECORDLIST_H
00027 #define RECORDLIST_H
00028 
00029 #include <QGpCoreTools.h>
00030 
00031 #include "Global.h"
00032 #include "AccountingRecord.h"
00033 
00034 class Group;
00035 
00036 class RecordList : public QList<AccountingRecord *>
00037 {
00038   TRANSLATIONS("RecordList")
00039 public:
00040   RecordList();
00041   ~RecordList();
00042 
00043   void setMode(Mode m) {_mode=m;}
00044 
00045   bool read(QString fileName, bool warning, AtomicBoolean &terminate);
00046   void removeNull();
00047   void print() const;
00048   void print(Group::Category c) const;
00049   void match(RecordList& o);
00050   QString report() const;
00051   double countValid() const;
00052   void preprocess(const QString& contract);
00053   bool setSupplierEquivalences(const QString& fileName, bool warning);
00054   void preprocess();
00055   void clear();
00056   QStringList contracts() const;
00057 
00058   static bool write(const QString& fileName, const RecordList &r1, const RecordList& r2);
00059 private:
00060   void setContract(const QString& contract);
00061   void keepContractOnly(const QString& c);
00062   void removeSupplier(const QString& s);
00063   bool readHeaderSifac(QTextStream& s, LineParser& lp, int& lineNumber);
00064   bool readHeaderGeslab(QTextStream& s, LineParser& lp, int& lineNumber);
00065   bool readHeaderSorgho(LineParser& lp, int columnIndex[], const char *columnTitle[]);
00066   bool readSifac(QTextStream& s, LineParser& lp, int& lineNumber, AtomicBoolean& terminate);
00067   bool readGeslab(QTextStream& s, LineParser& lp, int& lineNumber, AtomicBoolean& terminate);
00068   bool readSorgho(QTextStream& s, LineParser& lp, int& lineNumber, AtomicBoolean& terminate);
00069   void sumSifac();
00070   void sumGeslab();
00071   void sumSorgho();
00072   void groupCandidates(Group::Category good, Group::Category ambiguous,
00073                        const QList<AccountingRecord *>& candidates1,
00074                        const QList<AccountingRecord *>& candidates2);
00075 
00076   void setN2();
00077   int indexAfter(double amount) const;
00078 
00079   Mode _mode;
00080   QString _fileName;
00081   int _n2;
00082   QList<Group *> _groups;
00083   QHash<QString, QString> _supplierEquivalence;
00084 };
00085 
00086 #endif // RECORDLIST_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines