diff -r 89c329efa980 -r e48454f237ca ganeswidgets/tsrc/fute/HgWidgetTest/inc/buffermanager.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ganeswidgets/tsrc/fute/HgWidgetTest/inc/buffermanager.h Mon May 03 13:32:54 2010 +0300 @@ -0,0 +1,77 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef BUFFERMANAGER_H_ +#define BUFFERMANAGER_H_ + +class AbstractDataProvider +{ +public: + + enum requestsOrder { + ascending, + descending + }; + + virtual void release(int start, int end) = 0; + virtual void request(int start, int end, requestsOrder order) = 0; +}; + + +class BufferManager +{ +public: + + BufferManager( + AbstractDataProvider* aObserver, + int aBufferSize, + int aBufferTreshold, + int aInitialPosition, + int aTotalCount ); + + ~BufferManager(); + + void setPosition( int aIndex ); + + void resetBuffer( int aPosition, int aTotalCount); + + void itemCountChanged( int aIndex, bool aRemoved, int aNewTotalCount ); + void resizeCache(int newSize, int newTreshold); + +private: + void calculate(); + +private: + AbstractDataProvider* mObserver; + + int mBufferSize; + int mBufferTreshold; + int mBufferPosition; + int mDiff; + int mTotalCount; + + bool mResetOrdered; + + int mRequestStart; + int mRequestCount; + int mReleaseStart; + int mReleaseCount; +}; + + + +#endif /*BUFFERMANAGER_H_*/