QGpCoreTools/CacheProcess.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of QGpCoreTools.
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: 2010-09-07
00022 **  Authors:
00023 **    Marc Wathelet (LGIT, Grenoble, France)
00024 **
00025 ***************************************************************************/
00026 
00027 #ifndef CACHEPROCESS_H
00028 #define CACHEPROCESS_H
00029 
00030 #include <QtCore>
00031 
00032 #include "CacheItem.h"
00033 #include "QGpCoreToolsDLLExport.h"
00034 
00035 namespace QGpCoreTools {
00036 
00037   class QGPCORETOOLS_EXPORT CacheProcess
00038   {
00039   public:
00040     CacheProcess() {_current=0; _start=ApplicationClock::elapsed();}
00041     ~CacheProcess();
00042 
00043     inline void add(const CacheItem * item);
00044     inline void remove(const CacheItem * item);
00045     inline CacheProcess& operator<<(const CacheItem * item);
00046     void next() {_current++;}
00047     void next(int count) {_current+=count;}
00048 
00049     quint64 predictedTime(const CacheItem * item) const;
00050   private:
00051     QHash<const CacheItem *, int> _items;
00052     int _current;
00053     quint64 _start;
00054   };
00055 
00056   inline void CacheProcess::add(const CacheItem * item)
00057   {
00058     _items.insert(item, _items.count());
00059     item->addProcess(this);
00060   }
00061 
00062   inline CacheProcess& CacheProcess::operator<<(const CacheItem * item)
00063   {
00064     _items.insert(item, _items.count());
00065     item->addProcess(this);
00066     return *this;
00067   }
00068 
00069   inline void CacheProcess::remove(const CacheItem * item)
00070   {
00071     _items.remove(item);
00072   }
00073 
00074 } // namespace QGpCoreTools
00075 
00076 #endif // CACHEPROCESS_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines