All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Public Member Functions
QGpCoreTools::CacheProcess Class Reference

A list of CacheItem to be processed. More...

#include <CacheProcess.h>

Inheritance diagram for QGpCoreTools::CacheProcess:
GeopsyCore::SubSignalPoolProcess

List of all members.

Public Member Functions

void add (const CacheItem *item)
 CacheProcess ()
void next ()
void next (int count)
CacheProcessoperator<< (const CacheItem *item)
quint64 predictedTime (const CacheItem *item) const
void remove (const CacheItem *item)
 ~CacheProcess ()

Detailed Description

A list of CacheItem to be processed.

This list is used to predict the usage of the CacheItem. Each process that uses CacheItem in a known sequence should create such an object and add items in order of their expected usage. Items without CacheProcess are considered in a classical way with their last access time. One CacheItem can have several CacheProcess attached to it. The next predicted time of usage is the minimum returned by all these processes. Inside the list of allocated items the one with the maximum predicted time of usage is selected for deallocation. Items without CacheProcess attached have predicted time of usage set to infinite (maximum integer value).


Constructor & Destructor Documentation

Removes all links to this process

  {
    for(QHash<const CacheItem *, int>::iterator it=_items.begin(); it!=_items.end(); it++) {
      it.key()->removeProcess(this);
    }
  }

Member Function Documentation

void QGpCoreTools::CacheProcess::add ( const CacheItem item) [inline]

Add item. The order must must be the same as the real processing.

See also:
next()

References QGpCoreTools::CacheItem::addProcess().

Referenced by GeopsyGui::SignalLayer::paintData(), and GeopsyCore::SubSignalPoolProcess::SubSignalPoolProcess().

  {
    _items.insert(item, _items.count());
    item->addProcess(this);
  }
void QGpCoreTools::CacheProcess::next ( int  count) [inline]
{_current+=count;}
CacheProcess & QGpCoreTools::CacheProcess::operator<< ( const CacheItem item) [inline]

References QGpCoreTools::CacheItem::addProcess().

  {
    _items.insert(item, _items.count());
    item->addProcess(this);
    return *this;
  }
quint64 QGpCoreTools::CacheProcess::predictedTime ( const CacheItem item) const

Calculated predicted time of usage for item based on past time spent. If no statistics are available, current time is returned.

References QGpCoreTools::ApplicationClock::elapsed(), and MAXIMUM_APPLICATION_LIFETIME.

  {
    int index=_items[item];
    if(index>_current) { // Signal must be still processed
      quint64 now=ApplicationClock::elapsed();
      double rate=now-_start;
      if(rate<1.0) {
        rate=1.0;
      }
      if(_current>1) { // Else, elapsed time is considered as the time of one step
        rate/=(double)_current;
      }
      return now+(quint64)round(rate*(index-_current));
    } else if(index==_current) {
      return ApplicationClock::elapsed();
    } else {
      return MAXIMUM_APPLICATION_LIFETIME;
    }
  }
void QGpCoreTools::CacheProcess::remove ( const CacheItem item) [inline]
  {
    _items.remove(item);
  }

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines